Skip to main content

Step2 Get SDK and prepare for button rendering

1. Download SDK

Amazon Pay provides SDK and sample code for PHP, Java, .NET(C#), Node.js, Ruby and Perl. Download SDK.

2. Prepare fundamental parts to put in Amazon Pay button rendering script

Parts sample

OneTime/Recurring x PayAndShip/PayOnly sample parts as below.

caution

Note that payloadJSON should be written in one line, but below sample is broken in line for readbility

{
"merchantId": "xxxxxx",
"ledgerCurrency": "JPY",
"sandbox": true,
"checkoutLanguage": "ja_JP",
"productType": "PayAndShip",
"placement": "Cart",
"buttonColor": "Gold",
"createCheckoutSessionConfig": {
"payloadJSON": {
"webCheckoutDetails": {
"checkoutResultReturnUrl": "http://localhost:3000/result_apb/",
"checkoutCancelUrl": "http://localhost:3000/cancel/",
"checkoutMode": "ProcessOrder"
},
"storeId": "amzn1.application-oa2-client.ccxxxxxx",
"chargePermissionType": "OneTime",
"merchantMetadata": {
"merchantReferenceId": "",
"merchantStoreName": "",
"noteToBuyer": "",
"customInformation": ""
},
"deliverySpecifications": {
"addressRestrictions": {
"type": "Allowed",
"restrictions": {
"JP": {
"statesOrRegions": ["東京都"],
"zipCodes": ["1530064"]
}
}
}
},
"paymentDetails": {
"paymentIntent": "Authorize",
"canHandlePendingAuthorization": false,
"chargeAmount": {
"amount": "700",
"currencyCode": "JPY"
},
"allowOvercharge": false,
"extendExpiration": false
},
"scopes": ["name","email","phoneNumber","billingAddress"],
"addressDetails": {
"name": "テスト太郎",
"addressLine1": "目黒区下目黒1-8-1",
"stateOrRegion": "東京都",
"postalCode": "123-4567",
"countryCode": "JP",
"phoneNumber": "09012345678"
}
},
"signature": "xxxxxx",
"publicKeyId": "SANDBOX-xxxxxx"
}
}
  • merchantId: Set merchantId you get from Step1 Get storeId, merchantId, publicKey and privateKey
  • ledgerCurrency: Always set "JPY".
  • sandbox: Set true if you are using sandbox
  • checkoutLanguage: Always set "ja_JP"
  • productType: Set "PayAndShip" in case shipping of goods is involved, or set "PayOnly" in case of digital contents.
  • See placement
    Regardless of which value you set in placement, Amazon Pay button look and its behavior won't change. However, we use placement value to understand which Amazon Pay button on your site is used to initaite respective checkout, and may use such metrics to provide you with further insights and improvement proposal in the future. So please use different plamcent value for each Amazon Pay button depending on the button location or checkout scenario. If you need any advise on placement value, please kindly contact Amazon Pay members.
  • See buttonColor
  • webCheckoutDetails
    • checkoutResultReturnUrl: Set URL where Amazon Pay redirects buyer when Amazon payment preparation is ready.
    • checkoutCancelUrl: Set URL where Amazon Pay redirects buyer when buyer clicks on "cancel" link on Amazon hosted page.
    • checkoutMode: Always set "ProcessOrder"
  • storeId: Set store ID you got from Step1 Get storeId, merchantId, publicKey and privateKey.
  • chargePermissionType: OneTime or Recurring
  • See deliverySpecification
  • paymentDetails
  • scopes: Set scopes if you want to get such data during checkout session
  • recurringMetadata: Only in case of Recurring checkout. See this page
  • See addressDetails
  • signature: Set signature for payload. There are two ways to generate signature which is explained in "Sign the payload" below.
  • publicKeyId: Set publicKeyId you got from Step1 Get storeId, merchantId, publicKey and privateKey.


Sign the payload

payload is the part shown below within Parts sample.

{
"webCheckoutDetails": {
.
.
.
"scopes": ["name","email","phoneNumber","billingAddress"]
}

You must secure the payload using a signature. The payload does not include a timestamp so you can re-use the signature as long as the payload does not change.

There are two ways to generate signature.

  1. Generate a signature using the helper function provided in the Amazon Pay SDKs: Integration Guide - Sign the payload
  2. Build the signature manually: Integration Guide - Signing requests