Skip to content

PaymentCallback & Status ​

PaymentCallback ​

Returned by every gateway's HandleCallback() (and AYA's VerifyRedirect()) once the signature is verified.

Field / MethodTypeDescription
OrderIDstringYour order ID
StatusPaymentStatusThe status mapped onto this package's statuses
GatewayStatusstringThe gateway's own status value, unmapped
GatewayReferencestringThe gateway's ID for the payment
AmountstringThe amount the gateway reports, exactly as it sent it
Rawmap[string]anyThe verified payload, as decoded JSON (json.Number, never float64)
AcknowledgementAcknowledgementThe response the gateway expects
IsSuccessful()boolStatus == StatusSuccessful

Build one yourself to test your own fulfillment code, as a struct literal: &myanmarpayments.PaymentCallback{OrderID: …, Status: …, GatewayStatus: …}. Fields you leave out are zero values, so set Acknowledgement to myanmarpayments.DefaultAcknowledgement() when your code writes it.

Acknowledgement ​

A struct.

Field / MethodTypeDescription
StatusintHTTP status; 0 is written as 200
BodystringResponse body, e.g. KBZ Pay's success; empty by default
Headersmap[string]stringResponse headers, {"Content-Type": "text/plain"} by default
Write(w)errorWrites the headers, status and body to an http.ResponseWriter

DefaultAcknowledgement() is an empty 200 with Content-Type: text/plain. Write it with your framework's response writer, see Acknowledging.

PaymentStatusResult ​

Returned by kbz.Status(), aya.Status() and yoma.Status(). A struct.

Field / MethodTypeDescription
OrderIDstringYour order ID; "" for Yoma, which returns only the reference
StatusPaymentStatusThe mapped status
GatewayStatusstringThe gateway's own status value
GatewayReferencestringThe gateway's ID for the payment
AmountstringThe amount the gateway reports
Rawmap[string]anyThe gateway's response
IsSuccessful()boolStatus == StatusSuccessful

CallbackRequest ​

MemberTypeDescription
NewCallbackRequestFromHTTP(r)(*CallbackRequest, error)From an *http.Request: reads the body once and restores it
NewCallbackRequest(body, header, query)*CallbackRequestFrom the raw parts: the body as []byte, the headers as an http.Header, the query string as url.Values; nil header and query are allowed
NewCallbackRequestFromJSON(payload, header)(*CallbackRequest, error)From a decoded payload, encoded as a JSON body with Content-Type: application/json
Body[]byteThe raw body, exactly as received
Headerhttp.HeaderThe request headers
Queryurl.ValuesThe query string values
HeaderValue(name)stringOne header, case-insensitively, or ""
ParsedBody()map[string]anyThe body decoded as JSON (when it is a JSON object) or a urlencoded form; JSON numbers become json.Number
Input()map[string]anyThe body merged over the query string
QueryInput()map[string]anyThe query string merged over the body

PaymentStatus ​

type PaymentStatus string: constants are strings, so they compare equal to their values and string(status) is the value.

ConstantValue
StatusSuccessfulsuccessful
StatusPendingpending
StatusFailedfailed
StatusCanceledcanceled
StatusExpiredexpired
StatusUnknownunknown

myanmarpayments.PaymentStatuses() lists every status. status.IsFinal() is false for StatusPending and StatusUnknown. ResolveStatus(statuses, gatewayStatus) maps a trimmed gateway value through a map[string]PaymentStatus and returns StatusUnknown when it is not listed.

Released under the MIT License, except where a package says otherwise.