To checkout when create payment this error appear "Bad request - parameter error"

1.4k Views Asked by At

When create payment this error appear "Bad request - parameter error" as below. I define all checkout configuration. Please anyone has this problem or have idea for this problem

    var params = {
        "merchantOrderId": "123",
        "token": "MWQyYTI0ZmUtNjhiOS00NTIxLTgwY2MtODc3MWRlNmZjY2Jh",
        "currency": "USD",
        "total": "10.00",
        "billingAddr": {
            "name": "Testing Tester",
            "addrLine1": "123 Test St",
            "city": "Columbus",
            "state": "Ohio",
            "zipCode": "43123",
            "country": "USA",
            "email": "[email protected]",
            "phoneNumber": "5555555555"
        }
    };

    // Make the call using the authorization object and your callback function
    tco.checkout.authorize(params, function (error, data) {
        if (error) {
            console.log('error ',error.message);
        } else {
            console.log('success ',JSON.stringify(data));
        }
    });
2

There are 2 best solutions below

1
On BEST ANSWER

The error Bad request - parameter error throws due to the following reasons

  1. Your account is not yet approved by 2Checkout authorities
  2. You have been blocked by 2Checkout
0
On
    var Twocheckout = require('2checkout-node');

    var tco = new Twocheckout({
        apiUser: "your_username",                              
        apiPass: "your_password",
        sellerId: 'your_seller_id',                             
        privateKey: "your_private_key",
        demo: true,
        sandbox: true
    });

    var params = {
            "merchantOrderId": "001",
            "token": "gener",
            "currency": "USD",
            "total": "10.00",
            "billingAddr": {
                "name": "Testing Tester",
                "addrLine1": "123 Test St",
                "city": "Columbus",
                "state": "Ohio",
                "zipCode": "43123",
                "country": "USA",
                "email": "[email protected]",
                "phoneNumber": "5555555555"
            }
        };

   tco.checkout.authorize(params, (error, data) => {

      if (error) {
        return res.status(401).end()
      } else {
        return res.json(data)
        console.log(JSON.stringify(data));
      }

    });

generate token every new transition generate token