generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
This is my code:
const fs = require('fs');
const uuidv4 = require('uuid/v4');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: ‘xxxxxxx’,
privateKey: fs.readFileSync('./keys/AmazonPay_xxxxx.pem'),
region: 'jp',
sandbox: true
};
const payload = {
chargeAmount: {
amount: 50,
currencyCode: 'JPY'
}
};
const checkoutSessionId = ‘xxxxxx’;
const testPayClient = new Client.WebStoreClient(config);
testPayClient.completeCheckoutSession(checkoutSessionId, payload).then((apiResponse: any) => {
const response = apiResponse;
console.log(response['data']);
});
This is error:
/Users/ducbui/src/amazonPayment/test/node_modules/axios/lib/core/createError.js:16
var error = new Error(message);
^
Error: Request failed with status code 422
at createError (/Users/ducbui/src/amazonPayment/test/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users/ducbui/src/amazonPayment/test/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/Users/ducbui/src/amazonPayment/test/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (node:events:538:35)
at IncomingMessage.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
......
data: {
reasonCode: 'InvalidCheckoutSessionStatus',
message: 'You tried to call an operation on a Checkout Session that is in a state where that operation is not allowed'
}
Anyone have any ideas to fix this error?
Metadata
Metadata
Assignees
Labels
No labels