Skip to content

Direct Debit

Direct Debit

Standard direct-debit payment, its inbound notification, and status/cancel/refund.

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

DirectDebitPayment

DirectDebitPayment calls the SNAP Direct Debit Payment endpoint (Service Code 54, HTTP POST). Pass hb with everything except Body already set — DirectDebitPayment 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 DirectDebitPayment(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req DirectDebitPaymentRequest) (DirectDebitPaymentResponse, error)

Request — DirectDebitPaymentRequest

DirectDebitPaymentRequest is the request body for Direct Debit Payment. partnerReferenceNo is the only Mandatory field.

FieldTypePresence
partnerReferenceNostringMandatory
bankCardTokenstringOptional
chargeTokenstringOptional
otpstringOptional
otpTrxCodestringOptional
merchantIdstringOptional
terminalIdstringOptional
journeyIdstringOptional
subMerchantIdstringOptional
amount*snap.MoneyOptional
urlParams[]DirectDebitPaymentURLParamOptional
externalStoreIdstringOptional
validUpTostringOptional
pointOfInitiationstringOptional
feeTypestringOptional
disabledPayMethodsstringOptional
payOptionDetails[]DirectDebitPayOptionDetailOptional
additionalInfojson.RawMessageOptional
DirectDebitPaymentURLParam fields

DirectDebitPaymentURLParam is one entry in the request’s urlParams[] array — a redirect URL and how to use it. isDeeplink is a "Y"/"N" flag.

FieldTypePresence
urlstringMandatory
typestringMandatory
isDeeplinkstringMandatory
DirectDebitPayOptionDetail fields

DirectDebitPayOptionDetail is one entry in the request’s payOptionDetails[] array, describing one available payment method.

FieldTypePresence
payMethodstringMandatory
payOptionstringMandatory
transAmount*snap.MoneyOptional
feeAmount*snap.MoneyOptional
cardTokenstringOptional
merchantTokenstringOptional
additionalInfojson.RawMessageOptional

Response — DirectDebitPaymentResponse

DirectDebitPaymentResponse is the response body for Direct Debit Payment. referenceNo is Conditional — present only on success.

appRedirectUrl and webRedirectUrl come straight from the server with no validation. Before opening either in a WebView or browser, check the scheme yourself (https:// or your app’s own registered scheme) — a tampered or spoofed response could otherwise hand you an attacker-controlled URL.
FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
referenceNostringOptional
partnerReferenceNostringOptional
approvalCodestringOptional
appRedirectUrlstringOptional
webRedirectUrlstringOptional
additionalInfojson.RawMessageOptional

Direct Debit 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 DirectDebitPaymentNotificationRequest after verifying it with snap.ServerVerifier (see Verifying inbound requests), then reply with the shape below.

Received — DirectDebitPaymentNotificationRequest

DirectDebitPaymentNotificationRequest is the request body for Direct Debit Payment Notification (Service Code 56) — 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.

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

FieldTypePresence
originalPartnerReferenceNostringOptional
originalReferenceNostringMandatory
originalExternalIdstringOptional
merchantIdstringOptional
subMerchantIdstringOptional
amount*snap.MoneyOptional
latestTransactionStatusstringMandatory
transactionStatusDescstringOptional
createdTimestringOptional
finishedTimestringOptional
externalStoreIdstringOptional
additionalInfojson.RawMessageOptional

Your handler replies with — DirectDebitPaymentNotificationResponse

DirectDebitPaymentNotificationResponse has one field beyond the envelope, approvalCode, and it’s Optional.

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
approvalCodestringOptional

DirectDebitPaymentStatus

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

func DirectDebitPaymentStatus(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req DirectDebitPaymentStatusRequest) (DirectDebitPaymentStatusResponse, error)

Request — DirectDebitPaymentStatusRequest

DirectDebitPaymentStatusRequest is the request body for Direct Debit Payment Status. serviceCode is the only Mandatory field — pair it with whichever reference you have.

FieldTypePresence
originalPartnerReferenceNostringOptional
originalReferenceNostringOptional
originalExternalIdstringOptional
serviceCodestringMandatory
transactionDatestringOptional
amount*snap.MoneyOptional
merchantIdstringOptional
subMerchantIdstringOptional
externalStoreIdstringOptional

Response — DirectDebitPaymentStatusResponse

DirectDebitPaymentStatusResponse is the response body for Direct Debit Payment Status. latestTransactionStatus is the only Mandatory field beyond the envelope.

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
originalPartnerReferenceNostringOptional
originalReferenceNostringOptional
originalExternalIdstringOptional
serviceCodestringOptional
transactionDatestringOptional
amount*snap.MoneyOptional
approvalCodestringOptional
latestTransactionStatusstringMandatory
transactionStatusDescstringOptional
originalResponseCodestringOptional
originalResponseMessagestringOptional
sessionIdstringOptional
requestIdstringOptional
refundHistory[]DirectDebitRefundHistoryItemOptional
transAmount*snap.MoneyOptional
feeAmount*snap.MoneyOptional
paidTimestringOptional
DirectDebitRefundHistoryItem fields

DirectDebitRefundHistoryItem is one entry in the response’s refundHistory[] array — a past refund against this payment. refundStatus is one of 00, 03, or 06.

FieldTypePresence
refundNostringOptional
partnerRefundNostringMandatory
refundAmount*snap.MoneyOptional
refundStatusstringMandatory
refundDatestringOptional
reasonstringOptional

DirectDebitPaymentCancel

DirectDebitPaymentCancel calls the SNAP Direct Debit Payment Cancel endpoint (Service Code 57, HTTP POST). Pass hb with everything except Body already set — DirectDebitPaymentCancel 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 DirectDebitPaymentCancel(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req DirectDebitPaymentCancelRequest) (DirectDebitPaymentCancelResponse, error)

Request — DirectDebitPaymentCancelRequest

DirectDebitPaymentCancelRequest is the request body for Direct Debit Payment Cancel. originalPartnerReferenceNo is the only Mandatory field.

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

Response — DirectDebitPaymentCancelResponse

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

FieldTypePresence
responseCodestringMandatory
responseMessagestringMandatory
originalPartnerReferenceNostringOptional
originalReferenceNostringOptional
originalExternalIdstringOptional
cancelTimestringOptional
transactionDatestringOptional
additionalInfojson.RawMessageOptional

DirectDebitPaymentRefund

DirectDebitPaymentRefund calls the SNAP Direct Debit Payment Refund endpoint (Service Code 58, HTTP POST). Pass hb with everything except Body already set — DirectDebitPaymentRefund 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 DirectDebitPaymentRefund(ctx context.Context, t *snap.Transport, hb snap.HeaderBuilder, req DirectDebitPaymentRefundRequest) (DirectDebitPaymentRefundResponse, error)

Request — DirectDebitPaymentRefundRequest

DirectDebitPaymentRefundRequest is the request body for Direct Debit Payment Refund. originalPartnerReferenceNo and partnerRefundNo are Mandatory.

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

Response — DirectDebitPaymentRefundResponse

DirectDebitPaymentRefundResponse is the response body for Direct Debit Payment Refund. originalReferenceNo is Conditional — present only on success. refundNo, partnerRefundNo, and refundTime are Mandatory.

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