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
SignIn sample parts as below.
{
"merchantId": "xxxxxx",
"ledgerCurrency": "JPY",
"sandbox": true,
"checkoutLanguage": "ja_JP",
"productType": "SignIn",
"placement": "Home",
"buttonColor": "Gold",
"signInConfig": {
"payloadJSON": {
"signInReturnUrl": "http://localhost:3000/getBuyer/",
"storeId": "amzn1.application-oa2-client.ccxxxxxx",
"signInScopes": ["name","email","postalCode","shippingAddress","billingAddress","phoneNumber"]
},
"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 "SignIn"
- 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
- signInReturnUrl: Set URL where Amazon Pay redirects buyer when buyer completes login on Amazon hosted page.
- storeId: Set store ID you got from Step1 Get storeId, merchantId, publicKey and privateKey.
- signInScopes: Set scopes if you want to get such data after signIn.
- 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.
{
"signInReturnUrl":
.
.
.
"signInScopes": ["name","email","postalCode","shippingAddress","billingAddress","phoneNumber"]
}
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.
- Generate a signature using the helper function provided in the Amazon Pay SDKs: Integration Guide - Sign the payload
- Build the signature manually: Integration Guide - Signing requests