Skip to content

PaymentCallback & Status ​

On error the result is nil. A field the gateway didn't send is "".

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 ​

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().

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, and decodes the query string like a form body (see ParsedBody()). A body over MaxCallbackBodyBytes (64 KiB) returns an error wrapping ErrCallbackBodyTooLarge
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 "". A repeated header's values are joined with ", "
ParsedBody()map[string]anyThe body decoded as JSON (when it is a JSON object) or a urlencoded form; JSON numbers become json.Number. Only ASCII whitespace around the body is trimmed. A form splits on & and the first =, + is a space, an invalid % escape is kept as is, ; is no separator, names stay as sent and the first value of a repeated name wins
Input()map[string]anyThe body merged over the query string
QueryInput()map[string]anyThe query string merged over the body

PaymentStatus ​

type PaymentStatus string; the values and their meanings are in Callbacks & Status. myanmarpayments.PaymentStatuses() lists every status, and ResolveStatus(statuses, gatewayStatus) maps a gateway value trimmed of ASCII whitespace through a map[string]PaymentStatus and returns StatusUnknown when it is not listed.