Documentation ¶
Index ¶
- Constants
- Variables
- func NewPrepaidGateway(db *sql.DB, instanceID string, initConf interface{}) (payment.PrepaidGateway, error)
- type PrepaidGateway
- func (pg *PrepaidGateway) CheckoutForm(pr payment.PaymentRequest) (HTMLCheckoutForm string, err error)
- func (pg *PrepaidGateway) IsRefundable(referenceID string) bool
- func (pg *PrepaidGateway) OnStatusChange(UpdateHandler *func(referenceID string, newResult payment.PaymentResult)) error
- func (pg *PrepaidGateway) PaymentResult(referenceID string) (result payment.PaymentResult, err error)
- func (pg *PrepaidGateway) Refund(rr payment.RefundRequest) error
Constants ¶
View Source
const ( PREPAID_GATEWAY uint = iota BILLINGAGREEMENT_GATEWAY )
Variables ¶
View Source
var ( // success (200 OK) PAYMENT_OK = api.MessageResponse(api.SUCCESS, "PAYMENT_OK") // cancel (200 OK) BUYER_PAYPAL_CANCEL = api.MessageResponse(api.CANCELED, "BUYER_PAYPAL_CANCEL") // error // 400 Bad Request BAD_REQUEST = api.MessageResponse(api.ERROR, "BAD_REQUEST") // 503 Service Unavailable BUYER_PAYPAL_ERROR = api.MessageResponse(api.ERROR, "BUYER_PAYPAL_ERROR") // 409 Conflict PAYMENT_NOT_APPROVED = api.MessageResponse(api.ERROR, "PAYMENT_NOT_APPROVED") // 500 Internal Server Error SERVER_BAD_DATABASE = api.MessageResponse(api.ERROR, "SERVER_BAD_DATABASE") // 500 Internal Server Error SERVER_PAYPAL_BAD_AUTH = api.MessageResponse(api.ERROR, "SERVER_PAYPAL_BAD_AUTH") // PayPal gives a bad order according to the user-reported order ID // reason could be: // - Can't get such order from PayPal (500) // - The order is not intact: payment item or price tainted (400) // - ReferenceID not match (400) // - Price can't be parsed to float (500) SERVER_PAYPAL_BAD_ORDER = api.MessageResponse(api.ERROR, "SERVER_PAYPAL_BAD_ORDER") )
View Source
var ( ErrBadInitConf error = errors.New("paypal: bad initConf") ErrOrderNotPaid error = errors.New("paypal: order is not in paid state") ErrRepeatedRefund error = errors.New("paypal: refund amount exceeds paid amount") ErrNoCaptureID error = errors.New("paypal: no capture ID associated or there was an error when fetching capture ID") ExampleInitConf = map[string]string{ "clientID": `ABCD`, "secretID": `EFGHIJKLMNOPQRST`, "apiBase": `https://api-m.sandbox.paypal.com`, "orderSqlTable": `prepaid_paypal_orders_2`, "returnURL": `https://ulysses.tunnel.work/billing.html`, } )
Functions ¶
func NewPrepaidGateway ¶
func NewPrepaidGateway(db *sql.DB, instanceID string, initConf interface{}) (payment.PrepaidGateway, error)
NewPrepaidGateway() is a payment.PrepaidGatewayGen
Types ¶
type PrepaidGateway ¶
type PrepaidGateway struct { // Handler func used to notify the Ulysses server UpdateHandler *func(referenceID string, newResult payment.PaymentResult) // contains filtered or unexported fields }
func (*PrepaidGateway) CheckoutForm ¶
func (pg *PrepaidGateway) CheckoutForm(pr payment.PaymentRequest) (HTMLCheckoutForm string, err error)
CheckoutForm() is called when frontend requests a Checkout Form to be rendered
func (*PrepaidGateway) IsRefundable ¶
func (pg *PrepaidGateway) IsRefundable(referenceID string) bool
IsRefundable() checks if an order is eligible for at least a partial refund.
func (*PrepaidGateway) OnStatusChange ¶
func (pg *PrepaidGateway) OnStatusChange(UpdateHandler *func(referenceID string, newResult payment.PaymentResult)) error
func (*PrepaidGateway) PaymentResult ¶
func (pg *PrepaidGateway) PaymentResult(referenceID string) (result payment.PaymentResult, err error)
PaymentResult() is called by Ulysses to ACTIVELY verify an order's payment status on the contradictory, please see OnStatusChange() where Ulysses waits for payment gateway to report the payment result.
func (*PrepaidGateway) Refund ¶
func (pg *PrepaidGateway) Refund(rr payment.RefundRequest) error
Refund the transaction according to a request built by caller
Source Files ¶
Click to show internal directories.
Click to hide internal directories.