Step4 Operation after Amazon Pay button click
Buyer experience after Amazon Pay button click
Please ignore "shipping" part in below description if you implement productType=PayOnly
When buyer clicks Amazon Pay button that you rendered in Step3, buyer is redireted to Amazon hosted page, and signs in with Amazon.
Once buyer signs in, a buyer reviews shipping address and amount, and choose payment instrument, and finally clicks "Pay Now" button (meaning proceeding payment with Amazon Pay) on Amazon hosted page.
A buyer is redirected to Amazon hosted page and waits till payment is ready.
Once ready, a buyer is redireted to merchant's result page.
Merchant operation occurs at this timing
- Merchant shows sucess or failure page depending on payment result.
See APB flow if you want to review in a diagram.
Merchant Operation
(between #4 and #5 above)
Call Complete Checkout Session API
After you redirect to URL (in webCheckoutDetails.amazonPayRedirectUrl), Amazon Pay will start final step for payments, and once ready, Amazon Pay redirects buyer to checkoutResultReturnUrl
provided in Update Checkout Session API.
When redirecting, checkoutSessionId
is added as URL parameter.
i.e. https://anyurl.com/result/ ?amazonCheckoutSessionId=26be7331-7dc2-4722-be22-f7e75582d3ef
When redirected, get checkoutSessionId
from URL parameter, (in sample case, it's "26be7331-7dc2-4722-be22-f7e75582d3ef") and use it as parameter to call Complete Checkout Session
API to complete payment.
Complete Checkout Session API request body sample as below.
{
"chargeAmount": {
"amount": "1000",
"currencyCode": "JPY"
}
}
- See chargeAmount
- See Complete Checkout Session API
- If you are using SDK, you can find function by name like completeCheckoutSession.
In case API response was success (HTTP status code: 200 or 202)
You will find chargePermissionId
and chargeId
in API resopnse, so save these Ids with your order data.
chargeId
isn't returned in API response if paymentDetails.paymentIntent is set to Confirm in Update Checkout Session API (because Amazon Pay doesn't obtain Authorization when paymentIntent=Confirm)
- See chargePermissionId
- See chargeId
HTTP status code: 200
When process is complete, shows order confirmation page.
HTTP status code: 202
Wnen canHandlePendingAuthorization is set to true, and charge is in AuthorizationInitiated state, Amazon Pay returns HTTP status code 202.
In this case, Authorization is performed asynchronously. It takes up to 24 hours to obtain Authorization, so you need to call Get Charge API at a certain interval to get final authorization status.
When you receive HTTP status code 202, it means respective order is not fully accepted yet, so please show appropriate information to a buyer on order confirmation page.
In case API response was error
Handle errors appropriately. See Integration Guide - Manage Errors
- When Complete Checkout Session was not succesfully performed regardless of sucessfull completion of Update Checkout Session or redirect, it means respective payment was failed. Make sure to create order on your end upon successful completion of Complete Checkout Session API.
- Checkout Session represents a single active session (or engagement) for the buyer on your website. So once checkout session is finished (regardless of success or error), Checkout Session finishes its job and is deleted after a certain period. When checkout is completed successfully, information held by Checkout Session is replicated to Charge Permission object. So if you need to get buyer or payment information after checkout, call Get Charge Permission API instead of Get Checkout Session API.
- You can only retrieve details from Charge Permission for 30 days after the time that the Charge Permission was created.