Set payment info
[Step 4 of 9] To complete checkout, set payment info., and redirect to AmazonPayRedirectUrl
.
1. Set payment info.
Update Checkout Session to set payment info, and transaction metadata. Note that you can only set payment info, while the Checkout Session object is in an Open state and before the buyer is redirected to the Amazon Pay Payments Processing page.
Use the checkoutResultReturnUrl
parameter to specify the URL the buyer is redirected to after the Amazon Pay Payments Processing page.
Request
curl "https://pay-api.amazon.com/:environment/:version/checkoutSessions/:checkoutSessionId" \
-X PATCH
-H "x-amz-pay-authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-d @request_body
Request body
{
webCheckoutDetail: {
checkoutResultReturnUrl:"https://a.com/merchant-confirm-page"
},
paymentDetail: {
paymentIntent: "Confirm",
},
merchantMetadata: {
merchantReferenceId: "Merchant reference ID",
merchantStoreName: "Merchant store name",
noteToBuyer: "Note to buyer",
customInformation: "Custom information"
},
platformId: "SPId"
}
}
Request parameters
Name
|
Location
|
Description
|
checkoutSessionId (required) Type: string |
Path parameter
|
Checkout Session identifier
|
webCheckoutDetail Type: webCheckoutDetail |
Body
|
Checkout result URL provided by the merchant. Amazon Pay will redirect to this URL after completing the transaction Modifiable: Multiple times before the buyer is redirected to the AmazonPayReturnUrl |
paymentDetail Type: paymentDetail |
Body
|
Payment details specified by the merchant. Integrating with your acquirer, please set the PaymentIntent value only, always to the value "Confirm". Modifiable: Multiple times before the buyer is redirected to the AmazonPayReturnUrl
|
merchantMetadata Type: merchantMetadata |
Body
|
External order details provided by the merchant Modifiable: Multiple times before the buyer is redirected to the AmazonPayReturnUrl
|
platformId Type: string |
Body
|
Merchant identifier of the Solution Provider (SP). Only SPs should use this field. Modifiable: Multiple times before the buyer is redirected to the AmazonPayReturnUrl
|
providerMetadata Type: providerMetadata |
Body
|
Transaction identifier created by the Payment Service Provider (PSP). Only PSPs should use these fields. Modifiable: Multiple times before the buyer is redirected to the AmazonPayReturnUrl .
|
Response
{
checkoutSessionId: "bd504926-f659-4ad7-a1a9-9a747aaf5275",
webCheckoutDetail: {
checkoutReviewReturnUrl: "https://a.com/merchant-review-page",
checkoutResultReturnUrl:"https://a.com/merchant-confirm-page",
amazonPayRedirectUrl: "https://pay.amazon.com/redirect/checkoutId-1"
},
productType: "PayAndShip",
paymentDetail: {
paymentIntent: "Confirm",
},
merchantMetadata: {
merchantReferenceId: "Merchant reference ID",
merchantStoreName: "Merchant store name",
noteToBuyer: "Note to buyer",
customInformation: "Custom information"
},
supplementaryData: null,
buyer: {
buyerId:"amzn1.account.AH34VHFHHYL4YMBuyerId",
name:"name-1",
email:"name@amazon.com"
},
paymentPreferences: [
{
paymentDescriptor:"AmazonPay",
billingAddress:{ // Only available in EU
name:"Work",
addressLine1:"440 Terry Ave",
addressLine2:"",
addressLine3:"",
city:"Seattle",
county:"King",
district:"Seattle",
stateOrRegion:"WA",
postalCode:"98121",
countryCode:"US"
}
}
],
statusDetail: {
state: "Open",
reasonCode: null,
reasonDescription: null,
lastUpdatedTimestamp: "20191015T195703Z"
},
"shippingAddress": {
name: "Susie Smith",
addressLine1: "10 Ditka Ave",
addressLine2: "Suite 2500",
addressLine3: null,
city: "Chicago",
county: null,
district: null,
stateOrRegion: "IL",
postalCode: "60611",
countryCode: "US",
phoneNumber: "800-000-0000"
},
platformId: "AEMGQX8TKDO54",
chargePermissionId: null,
chargeId: null,
constraints: [],
creationTimestamp: "20191015T195655Z",
expirationTimestamp: "20191016T195655Z",
storeId: "amzn1.application-oa2-client.8b5e45312b5248b69eeaStoreId",
providerMetadata: {
providerReferenceId: null
},
releaseEnvironment: "Sandbox"
}
2. Redirect to AmazonPayRedirectUrl
Update Checkout Session response will include a Constraint object, until all mandatory parameters are provided. The mandatory parameters are:
checkoutResultReturnUrl
paymentIntent
Once there are no constraints, the response will return a unique amazonPayRedirectUrl
. Redirect the buyer to that URL to complete checkout.