Skip to content

Error completeCheckoutSession #16

Description

@ducgeniee

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions