Merci de votre visite. Cette page est disponible en anglais uniquement.

Display shipping and payment info

[Step 3 of 9] The buyer is redirected to checkoutReviewReturnUrl after they select their preferred shipping address and payment instrument. The Amazon Pay checkout session ID will be included as a query parameter.

In this step, you will use the checkout session ID to get checkout info (such as shipping address and payment instrument) and to enable checkout preference updates. At the end of this step, you will be able to present the buyer with an order summary and give them the option of updating their preferred shipping and payment instrument before they complete checkout.


1. Get shipping and payment info

Get Checkout Session to retrieve checkout info, such as buyer email, shipping address, and payment information. Use the response to display checkout information, offer shipping options if applicable, and calculate additional costs.

Note that you can only retrieve checkout info using Get Checkout Session while the Checkout Session object is in an Open state. Additionally, shipping address will only be returned if the Checkout Session has PayAndShip product type. After a successful checkout, you can use Get Charge Permission to retrieve checkout info.

Important:

  • For protection against buyer disputes, you should display the shipping address that you receive from Amazon Pay as read-only text. Enable shipping and payment updates so that buyers can select a different shipping address from their Amazon address book. More information about Amazon Pay Payment Protection Plan here: US, UK, EU, JP.
  • Use the paymentDescriptor value returned in Get Checkout Session response to represent the buyer-selected payment instrument. Amazon Pay may dynamically return a different value to optimize checkout conversion.
  • Verify the address returned in the Get Checkout Session is supported by your business requirements even if you use the deliverySpecifications parameter to limit which addresses your buyer can select from their Amazon address book. If the address returned is not supported, please ask the buyer to select a different one.
  • Do not display checkout info such as shipping address or buyer email to anyone besides the buyer who initiated checkout. Implement validation (for example: browser session verification) in case someone besides the buyer gains access to the Checkout Session ID.

Request

Request parameters

Name
Location
Description
CheckoutSessionId
(required)

Type: string
Path Parameter
Checkout session identifier

Sample Code

Response

{
    "checkoutSessionId": "bd504926-f659-4ad7-a1a9-9a747aaf5275",
    "webCheckoutDetails": {
        "checkoutReviewReturnUrl": "https://a.com/merchant-review-page",
        "checkoutResultReturnUrl": null,
        "checkoutCancelUrl": null,
        "amazonPayRedirectUrl": null
    },
    "productType": "PayAndShip",
    "paymentDetails": {
        "paymentIntent": null,
        "canHandlePendingAuthorization": false,
        "chargeAmount": null,
        "totalOrderAmount": null,
        "softDescriptor": null,
        "presentmentCurrency": null,
        "allowOvercharge": null,
        "extendExpiration": null
    },
    "merchantMetadata": {
        "merchantReferenceId": null,
        "merchantStoreName": null,
        "noteToBuyer": null,
        "customInformation": null
    },
    "supplementaryData": null, // Amazon Pay system data
    "buyer": {
        "buyerId": "buyerId",
        "name": "name-1",
        "email": "name@amazon.com",
        "phoneNumber": "800-000-0000",
        "primeMembershipTypes": null
    },
    "billingAddress":{ 
        "name": "Work",
        "addressLine1": "440 Terry Ave",
        "addressLine2": "",
        "addressLine3": "",
        "city": "Seattle",
        "county": "King",    
        "district": "Seattle",
        "stateOrRegion": "WA",
        "postalCode": "98121",
        "countryCode": "US",
        "phoneNumber": "800-000-0000"
    },
    "paymentPreferences": [
        {
            "paymentDescriptor": "Visa ****1111 (Amazon Pay)"
        }
    ],
    "statusDetails": {
        "state": "Open",
        "reasonCode": null,
        "reasonDescription": null,
        "lastUpdatedTimestamp": "20191015T204327Z"
    },
    "shippingAddress": {  // Null for PayOnly product type
        "name": "Susie Smith",
        "addressLine1": "10 Ditka Ave",
        "addressLine2": "Suite 2500",
        "addressLine3": null,
        "city": "Chicago",
        "county": null,
        "district": null,
        "stateOrRegion": "IL",
        "postalCode": "60602",
        "countryCode": "US",
        "phoneNumber": "800-000-0000"
    },
    "platformId": null,
    "chargePermissionId": null,
    "chargeId": null,
    "constraints": [
        {
            "constraintId": "ChargeAmountNotSet",
            "description": "chargeAmount is not set."
        },
        {
            "constraintId": "CheckoutResultReturnUrlNotSet",
            "description": "checkoutResultReturnUrl is not set."
        },
        {
            "constraintId": "PaymentIntentNotSet",
            "description": "paymentIntent is not set."
        }
    ],
    "creationTimestamp": "20191015T204313Z",
    "expirationTimestamp": "20191016T204313Z",
    "storeId": "amzn1.application-oa2-client.8b5e45312b5248b69eeaStoreId",
    "deliverySpecifications": {
        "specialRestrictions": ["RestrictPOBoxes"],
        "addressRestrictions": {
            "type": "Allowed",
            "restrictions": {
                "US": {
                    "statesOrRegions": ["WA"],
                    "zipCodes": ["95050", "93405"]
                },
                "GB": {
                    "zipCodes": ["72046", "72047"]
                },
                "IN": {
                    "statesOrRegions": ["AP"]
                },
                "JP": {}
          }
        }
    },
    "providerMetadata": {
        "providerReferenceId": null
    },
    "checkoutButtonText": null,
    "releaseEnvironment": "Sandbox"
}

2. Enable shipping and payment updates

Use amazon.Pay.bindChangeAction() to bind click events to HTML elements, so that when the element is clicked, the buyer can select a different shipping address or payment method. Be sure to Get Checkout Session after the buyer returns to your site to retrieve updated checkout info.

Step 1. Add the Amazon Pay script to your HTML file. Be sure you select the correct region.

<script src="https://static-na.payments-amazon.com/checkout.js"></script>
<script src="https://static-eu.payments-amazon.com/checkout.js"></script>
<script src="https://static-fe.payments-amazon.com/checkout.js"></script>

Step 2. Use amazon.Pay.bindChangeAction() to bind click events to HTML elements on your page. You can specify whether the buyer is editing shipping address or payment method by using the changeAction parameter.

Changing address (only relevant if Checkout Session product type is PayAndShip):

<script type="text/javascript" charset="utf-8">
  amazon.Pay.bindChangeAction('#changeButton1', {
    amazonCheckoutSessionId: 'xxxx',
    changeAction: 'changeAddress'
  });
</script>

Changing payment instrument:

<script type="text/javascript" charset="utf-8">
  amazon.Pay.bindChangeAction('#changeButton2', {
    amazonCheckoutSessionId: 'xxxx',
    changeAction: 'changePayment'
  });
</script>

Function parameters

Parameter
Description
amazonCheckoutSessionId
(required)

Type: string
Amazon Pay Checkout Session identifier
changeAction
(required)

Type: string
Update requested by the buyer

Supported values: 'changeAddress', 'changePayment'

3. Update estimated order amount

This step is only required if you’ve set the estimatedOrderAmount parameter and if buyers can change the order total after starting checkout (for example, if they can remove items from the cart on the checkoutReviewReturnUrl page.

Use updateButtonInfo() to update the estimatedOrderAmount any time the estimated order amount changes.

<script type="text/javascript" charset="utf-8">
  amazonPayButton.updateButtonInfo({"amount":"120.99","currencyCode":"USD"});
</script>