Skip to content

Commit 4021c19

Browse files
author
Shangamesh T
committed
Amazon Pay NodeJS 2.2.0
1 parent d7bac4b commit 4021c19

6 files changed

Lines changed: 27 additions & 12 deletions

File tree

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### Version 2.2.0 - January 2022
2+
* Migrated signature generating algorithm from AMZN-PAY-RSASSA-PSS to AMZN-PAY-RSASSA-PSS-V2 & increased salt length from 20 to 32
3+
* Note : From this SDK version, "algorithm" need to be provided as additional field in "createCheckoutSessionConfig" while rendering Amazon Pay button.
4+
15
#### Version 2.1.5 - October 2021
26
* Fixed Security Vulnerabilities by upgrading 'axios' library version
37
* ReadMe file updates

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,17 @@ Example call to generateButtonSignature function:
384384
};
385385
const signature = testPayClient.generateButtonSignature(payload);
386386
```
387+
Note :
388+
As part of signature button integration, "algorithm" need to be provided as additional field in "createCheckoutSessionConfig" while rendering Amazon Pay button.
389+
390+
Example of "createCheckoutSessionConfig" :
391+
``` js
392+
createCheckoutSessionConfig: {
393+
payloadJSON: '{"webCheckoutDetails":{"checkoutReviewReturnUrl":"https://localhost/test/checkoutReview.html"},"storeId": "amzn1.application-oa2-client.xxxxx","scopes": ["name", "email", "phoneNumber", "billingAddress"]}',
394+
signature: 'SIGNATURE', // Signature Obtained by calling "generateButtonSignature(payload)" method
395+
algorithm: 'AMZN-PAY-RSASSA-PSS-V2' // This Parameter is mandatory
396+
}
397+
```
387398

388399
## Manual Signing (Advanced Use-Cases Only)
389400
This SDK provides the ability to help you manually sign your API requests if you want to use your own code for sending the HTTPS request over the Internet.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@amazonpay/amazon-pay-api-sdk-nodejs",
3-
"version": "2.1.5",
3+
"version": "2.2.0",
44
"description": "Amazon Pay Checkout V2 Integration",
55
"main": "src/client.js",
66
"directories": {},

src/clientHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function sign(privateKey, stringToSign) {
8686
return sign.sign({
8787
key: privateKey,
8888
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
89-
saltLength: 20
89+
saltLength: 32
9090
}, 'base64');
9191
}
9292

@@ -141,7 +141,7 @@ function signHeaders(configArgs, options) {
141141

142142
Object.assign(headers, options.headers);
143143

144-
headers['x-amz-pay-region'] = configArgs.region;
144+
headers['x-amz-pay-region'] = constants.REGION_MAP[configArgs.region.toLowerCase()];
145145
headers['x-amz-pay-host'] = getAPIEndpointBaseURL(configArgs);
146146
headers['x-amz-pay-date'] = getTimestamp();
147147
headers['content-type'] = 'application/json';

src/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
module.exports = {
4-
SDK_VERSION: '2.1.5',
4+
SDK_VERSION: '2.2.0',
55
API_VERSION: 'v2',
66
RETRIES: 3,
77
API_ENDPOINTS: {
@@ -17,5 +17,5 @@ module.exports = {
1717
eu: 'eu',
1818
jp: 'jp'
1919
},
20-
AMAZON_SIGNATURE_ALGORITHM: 'AMZN-PAY-RSASSA-PSS'
20+
AMAZON_SIGNATURE_ALGORITHM: 'AMZN-PAY-RSASSA-PSS-V2'
2121
};

0 commit comments

Comments
 (0)