Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error completeCheckoutSession #16

Open
ducgeniee opened this issue Jun 29, 2022 · 0 comments
Open

Error completeCheckoutSession #16

ducgeniee opened this issue Jun 29, 2022 · 0 comments

Comments

@ducgeniee
Copy link

ducgeniee commented Jun 29, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant