Step 5: Set purchase details and confirm the purchase
Before you can request payment, you need to set and confirm the order using the orderReferenceId provided in the AddressBook or Wallet widget step.
- Make a call to the SetOrderReferenceDetails API. In the request, set the following attributes in the OrderReferenceAttributes:
- Amazon Order Reference ID
- Order Total (the order amount and currency code)
- Store Name
- Seller Order ID
- Seller Note
Note: If you cannot provide Store Name, Seller Order ID, Seller Note, Platform ID, or Customer Information before the order is placed, you can set this data after the purchase is completed by using the SetOrderAttributesAPI call. For more information, see Adding order attributes after purchase.
- Make a call to the ConfirmOrderReference API. If the SetOrderReferenceDetails API call was successful, confirm the Order Reference object by making a call to the ConfirmOrderReference API call.
This step informs Amazon that the buyer has placed the order on your site. If the call to ConfirmOrderReference was successful, the Order Reference object is set to an Open state and Amazon will send the buyer a Payment initiated email to confirm that they have authorized payment for a purchase using Amazon Pay. If the response returns a constraint, make attempts to remedy it. For example, in the case of a PaymentPlanNotSet constraint, inform the buyer that they must make a different payment selection. You can do this either by showing an on-screen message or by redirecting the buyer to an appropriate page to make the selection.
Note: The Payment initiated email is not sent in two cases:
- When the merchant cancels the transaction (CancelOrderReference) within 5 minutes of confirmation (ConfirmOrderReference).
- When OrderReference is closed within 5 minutes of confirmation of the OrderReference (ConfirmOrderReference).
- Make a call to the GetOrderReferenceDetails. After you successfully confirm the order reference, you should call the GetOrderReferenceDetails API to get the remaining buyer information, like name and shipping address, to ensure that you retrieved the latest address.
Note: You must implement error handling with your API calls, and you must test the results of the API response. For more information, see Handling errors.
Order Reference States and Reason Codes in the Amazon Pay API reference guide