complete()
complete() closes the merchant and consumer sessions (where applicable) and returns a payment identifier and, when requested, the card details needed to process the payment transaction.
If both the merchant and consumer sessions have timed out without receiving valid input, complete() should not be invoked. If it is invoked in this state, an INCOMPLETE_CHECKOUT error is returned.
The merchant is responsible for obtaining card-on-file consent in their own digital experiences if they intend to use card-on-file functionality with complete().
Card networks handle card-on-file differently. Refer to individual network documentation for the most up-to-date guidance. For example:
- Visa allows merchants or their payment service providers to perform a token-for-token swap with a previous payment token.
- Discover does not support
CARD_ON_FILE. OnlyPURCHASEis supported for Discover cards.
For a complete listing see Objects.
Request Parameters
Merchant-generated session identifier. If provided, it is returned in the completeResponse and can be used to correlate merchant session or transaction information with the payloadId. Both sessionId and payloadId are available in the signed completeResponse and the B2B getPayload() API.
Max: 255 characters
Note: This field is required when transactionType is PURCHASE or BOTH and the merchant is enrolled in the Paze Fraud Liability Shift Program.
transactionType enum required
Type of transaction.
Valid values:
PURCHASECARD_ON_FILEBOTH
Note: When a Discover card is selected in checkout(), the merchant must provide PURCHASE or BOTH only, because Discover does not support CARD_ON_FILE. When BOTH is used, only dynamicDataType: "PURCHASE" is returned.
transactionOptions Object(TransactionOptions) conditional
Client configuration data related to the transaction.
Note: Required when transactionType is PURCHASE or BOTH.
transactionValue Object(TransactionValue) conditional
Currency code and the amount of the transaction.
Note: Required when transactionType is PURCHASE or BOTH.
enhancedTransactionData Object(EnhancedTransactionData) optional
Merchant-provided parameters that may impact fraud decisioning.
Response Attributes
completeResponse Object(CompleteResponse) required
This is the JWS of the complete response.
Promise – Resolve and Reject
resolve()
This is the JS Promise (fulfilled) call when the request is successfully processed by the Paze SDK. The resolved JSON contains the completeResponse JWS.
reject()
This is the JS Promise call when there is an error. The object passed in is an error object as defined in the Errors section.
Business Errors
ACCT_INACCESSIBLE
The wallet account exists but is not currently accessible (for example, it is suspended).
INCOMPLETE_CHECKOUT
complete() was called before checkout() finished successfully.
Code Example
await complete({
sessionId: "YSr6zUH6gsAs3riQMhTL", // string (conditional)
transactionType: "BOTH", // enum (required) — PURCHASE | CARD_ON_FILE | BOTH
transactionOptions: {
merchantCategoryCode: "5193", // string (optional)
billingPreference: "ZIP_COUNTRY", // enum (optional) — ALL | ZIP_COUNTRY | NONE
payloadTypeIndicator: "ID" // enum (optional) — ID | PAYMENT
},
transactionValue: {
transactionCurrencyCode: "USD", // string (required for PURCHASE or BOTH)
transactionAmount: "73.29" // string (required for PURCHASE or BOTH)
},
enhancedTransactionData: {
ecomData: {
cartContainsGiftCard: true, // boolean (optional)
orderForPickup: true, // boolean (optional)
orderQuantity: "3", // string (optional)
orderHighestCost: "54.17", // string (optional)
finalShippingAddress: {
name: "Another Customer", // string (optional)
line1: "1234 Main St.", // string (required)
line2: "Apt. 3A", // string (optional)
city: "Evansville", // string (required)
state: "Indiana", // string (required)
zip: "47705", // string (required)
countryCode: "US" // string (required)
}
},
processingNetwork: ["VISA"] // string[] (optional)
}
});
Response
completeResponse is a JWS (JSON Web Signature) containing the signed response payload.
{
completeResponse: "eyJhdWQiOiJmaWxlOlwvXC…..yzt9iIGnde__dSiw4iTvYAJtMqzq8DggFD_URzvdPA" // JWS — always present on success
}
Decoded completeResponse
After receiving the completeResponse JWS, first decode it with a Base64 decoder to extract the JSON payload containing payloadId, sessionId, and optionally securedPayload.
{
"payloadId": "txn-YSr6zUH6gsAs3riQMhTL-001", // string (required) — payment identifier
"sessionId": "YSr6zUH6gsAs3riQMhTL", // string (optional) — echoed from request if provided
"securedPayload": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXRSJ9..." // string (conditional) — JWE<JWS<Payload>>
}
Decrypted securedPayload
Decrypt the securedPayload using your merchant's private key. The decrypted payload contains sensitive information necessary for you to process the transaction.
{
"clientId": "merchant-12345", // string (required)
"profileId": "profile-6789", // string (required)
"eci": "05", // string (optional) — ECI code
"consumer": {
"fullName": "Another Customer", // string (required)
"emailAddress": "[email protected]" // string (required; RFC 5322)
},
"billingAddress": {
"line1": "1234 Main St.", // string (required)
"line2": "Apt. 3A", // string (optional)
"city": "Evansville", // string (required)
"state": "Indiana", // string (required)
"zip": "47705", // string (required)
"countryCode": "US" // string (required; ISO 3166-1 alpha-2)
},
"token": {
"paymentToken": "[Network token value]", // string (required) — network token
"tokenExpirationMonth": "12", // string (required; MM)
"tokenExpirationYear": "2028", // string (required; YYYY)
"paymentAccountReference": "PAR1234567890" // string (required; PAR)
},
"paymentCardNetwork": "VISA", // enum (required) — VISA | MASTERCARD | DISCOVER
"dynamicData": [
{
"dynamicDataType": "PURCHASE", // enum (required) — PURCHASE | CARD_ON_FILE
"dynamicData": "CiAgICAgQ3J5cHRvZ3JhbUhlcmVEYXRh...", // string (required) — cryptogram (not decrypted by merchant)
"dynamicDataExpiration": "2025-12-31T23:59:59Z" // string (optional; ISO 8601)
}
]
}
Updated 4 days ago