Skip to content

CPM

CPM

Customer-Presented-Mode QR (the customer shows a QR, the merchant scans it): generate, pay, query, cancel, refund; payment results also arrive as an inbound notification.

resp, err := transferdebit.CPMPayment(ctx, transport, hb, transferdebit.CPMPaymentRequest{
	PartnerReferenceNo: "2020102900000000000001",
	QRContent: "...",
	MerchantID: "...",
})
if err != nil {
	// errors.Is(err, snap.ErrBadRequest), snap.ErrUnauthorized, etc.
}

CPMGenerateQR

CPMGenerateQR calls the SNAP Generate QR CPM endpoint (Service Code 59, HTTP POST). Pass hb with everything except Body already set — CPMGenerateQR marshals the request itself and uses those exact bytes for both signing and the wire body.

This operation is not idempotent and this package does not retry. Callers that retry a failed or timed-out call should reuse the same X-EXTERNAL-ID, since the server’s own duplicate-detection keys on it.

func CPMGenerateQR(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req CPMGenerateQRRequest) (CPMGenerateQRResponse, error)

Request — CPMGenerateQRRequest

CPMGenerateQRRequest is the request body for Generate QR CPM. partnerTrxDate is the only Mandatory field.

FieldTypePresence
partnerReferenceNostringOptional
userAccessTokenstringOptional
merchantIdstringOptional
subMerchantIdstringOptional
partnerTrxDatestringMandatory
additionalInfojson.RawMessageOptional

Response — CPMGenerateQRResponse

CPMGenerateQRResponse is the response body for Generate QR CPM. expiryTime is the only other Mandatory field; qrContent/qrUrl are both plain Optional (no one-of-many rule between them).

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
referenceNostringOptional
partnerReferenceNostringOptional
qrContentstringOptional
qrUrlstringOptional
expiryTimestringMandatory
additionalInfojson.RawMessageOptional

CPMPayment

CPMPayment calls the SNAP CPM Payment endpoint (Service Code 60, HTTP POST). Pass hb with everything except Body already set — CPMPayment marshals the request itself.

This operation is not idempotent and this package does not retry. Callers that retry a failed or timed-out call should reuse the same X-EXTERNAL-ID, since the server’s own duplicate-detection keys on it.

func CPMPayment(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req CPMPaymentRequest) (CPMPaymentResponse, error)

Request — CPMPaymentRequest

CPMPaymentRequest is the request body for CPM Payment. partnerReferenceNo, qrContent, and merchantId are Mandatory.

items has no fixed schema in the standard, so it’s typed json.RawMessage — the same treatment as additionalInfo and every other genuinely untyped field.

FieldTypePresence
partnerReferenceNostringMandatory
qrContentstringMandatory
amount*snap.MoneyOptional
feeAmount*snap.MoneyOptional
merchantIdstringMandatory
subMerchantIdstringOptional
titlestringOptional
expiryTimestringOptional
itemsjson.RawMessageOptional
externalStoreIdstringOptional
merchantNamestringOptional
merchantLocationstringOptional
acquirerNamestringOptional
terminalIdstringOptional
scannerInfo*CPMPaymentScannerInfoOptional
additionalInfojson.RawMessageOptional
CPMPaymentScannerInfo fields

CPMPaymentScannerInfo is the optional scannerInfo object describing the device that scanned the QR. All four fields are Optional.

FieldTypePresence
deviceIdstringOptional
deviceVersionstringOptional
deviceModelstringOptional
deviceIpstringOptional

Response — CPMPaymentResponse

CPMPaymentResponse is the response body for CPM Payment. referenceNo is Conditional — present only on success. No other field is Mandatory.

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
referenceNostringOptional
partnerReferenceNostringOptional
transactionDatestringOptional
additionalInfojson.RawMessageOptional

CPM Payment Notification

Inbound only — this package does not call an endpoint for this. A partner/switcher POSTs it to your callback URL; unmarshal the body into CPMPaymentNotificationRequest after verifying it with snap.ServerVerifier (see Verifying inbound requests), then reply with the shape below.

Received — CPMPaymentNotificationRequest

CPMPaymentNotificationRequest is the request body for Payment Notification (Service Code 79) — a settlement callback the PJP receives, not a call this package makes. Wire your own HTTP handler for this path, authenticate the inbound call with ServerVerifier.VerifyTransactionRequest, then json.Unmarshal the body into this type.

merchantId and latestTransactionStatus are Mandatory; every other field is Optional.

FieldTypePresence
originalPartnerReferenceNostringOptional
originalReferenceNostringOptional
merchantIdstringMandatory
subMerchantIdstringOptional
externalStoreIdstringOptional
amount*snap.MoneyOptional
latestTransactionStatusstringMandatory
transactionStatusDescstringOptional
customerNumberstringOptional
accountTypestringOptional
destinationNumberstringOptional
destinationAccountNamestringOptional
sessionIdstringOptional
bankCodestringOptional
additionalInfojson.RawMessageOptional

Your handler replies with — CPMPaymentNotificationResponse

CPMPaymentNotificationResponse is envelope-only — just responseCode and responseMessage, no other fields.

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory

CPMQueryPayment

CPMQueryPayment calls the SNAP Query Payment endpoint (Service Code 61, HTTP POST) to check a previous CPM payment’s status. Pass hb with everything except Body already set — CPMQueryPayment marshals the request itself. This is a read-only lookup, safe to retry freely.

func CPMQueryPayment(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req CPMQueryPaymentRequest) (CPMQueryPaymentResponse, error)

Request — CPMQueryPaymentRequest

CPMQueryPaymentRequest is the request body for Query Payment. No field is Mandatory — query by whichever reference, merchant, or store ID you have.

FieldTypePresence
originalReferenceNostringOptional
originalPartnerReferenceNostringOptional
originalExternalIdstringOptional
merchantIdstringOptional
subMerchantIdstringOptional
externalStoreIdstringOptional
additionalInfojson.RawMessageOptional

Response — CPMQueryPaymentResponse

CPMQueryPaymentResponse is the response body for Query Payment. latestTransactionStatus and paidTime are Mandatory; originalReferenceNo is Conditional — present only on success.

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
originalReferenceNostringOptional
originalPartnerReferenceNostringOptional
originalExternalIdstringOptional
titlestringOptional
latestTransactionStatusstringMandatory
transactionStatusDescstringOptional
paidTimestringMandatory
additionalInfojson.RawMessageOptional

CPMCancelPayment

CPMCancelPayment calls the SNAP Cancel Payment endpoint (Service Code 62, HTTP POST). Pass hb with everything except Body already set — CPMCancelPayment marshals the request itself.

This operation is not idempotent and this package does not retry. Callers that retry a failed or timed-out call should reuse the same X-EXTERNAL-ID, since the server’s own duplicate-detection keys on it.

func CPMCancelPayment(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req CPMCancelPaymentRequest) (CPMCancelPaymentResponse, error)

Request — CPMCancelPaymentRequest

CPMCancelPaymentRequest is the request body for Cancel Payment. originalPartnerReferenceNo is the only Mandatory field.

FieldTypePresence
originalPartnerReferenceNostringMandatory
originalReferenceNostringOptional
originalExternalIdstringOptional
merchantIdstringOptional
subMerchantIdstringOptional
externalStoreIdstringOptional
amount*snap.MoneyOptional
reasonstringOptional
additionalInfojson.RawMessageOptional

Response — CPMCancelPaymentResponse

CPMCancelPaymentResponse is the response body for Cancel Payment. originalReferenceNo and cancelTime are Conditional — present only on success.

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
originalPartnerReferenceNostringOptional
originalReferenceNostringOptional
originalExternalIdstringOptional
cancelTimestringOptional
transactionDatestringOptional
additionalInfojson.RawMessageOptional

CPMRefundPayment

CPMRefundPayment calls the SNAP Refund Payment endpoint (Service Code 80, HTTP POST). Pass hb with everything except Body already set — CPMRefundPayment marshals the request itself.

This operation is not idempotent and this package does not retry. Callers that retry a failed or timed-out call should reuse the same X-EXTERNAL-ID, since the server’s own duplicate-detection keys on it.

func CPMRefundPayment(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req CPMRefundPaymentRequest) (CPMRefundPaymentResponse, error)

Request — CPMRefundPaymentRequest

CPMRefundPaymentRequest is the request body for Refund Payment. originalPartnerReferenceNo and partnerRefundNo are Mandatory.

FieldTypePresence
merchantIdstringOptional
subMerchantIdstringOptional
externalStoreIdstringOptional
originalPartnerReferenceNostringMandatory
originalReferenceNostringOptional
originalExternalIdstringOptional
partnerRefundNostringMandatory
refundAmount*snap.MoneyOptional
reasonstringOptional
additionalInfojson.RawMessageOptional

Response — CPMRefundPaymentResponse

CPMRefundPaymentResponse is the response body for Refund Payment. refundNo and refundTime are Mandatory; partnerRefundNo is Optional here (unlike Direct Debit Payment Refund’s own response, where it’s Mandatory).

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
originalPartnerReferenceNostringOptional
originalReferenceNostringOptional
originalExternalIdstringOptional
refundNostringMandatory
partnerRefundNostringOptional
refundAmount*snap.MoneyOptional
refundTimestringMandatory
additionalInfojson.RawMessageOptional