'2Checkout Authorization Failed 600 Code Legacy code

Since 2Checkout removed sandbox mode, nothing works properly in DEMO modein legacy code that is written in their official GitHub repo :

https://github.com/2Checkout/2checkout-php, you can also find 2nd issue speaking about this and NONE answers.

Keys are properly set up and I am using DEMO => true for calling DEMO mode.

BUT I am repedetely getting 600 ERROR code which means Credit Card not authorized, even in DEMO mode and with suggested testing card data.

Somebody struggling about this?

I think that JS code they provided in:

https://www.2checkout.com/checkout/api/2co.min.js

is broken and that's the reason why we get 600 error code card not authorized even if we get TOKEN properly and send it to the backend auth.

JS CODE FOR CARD VERIFICATION

var successCallback = function(data) {
    console.log("test");
    var myForm = document.getElementById('myCCForm');
    myForm.token.value = data.response.token.token;
    console.log(data.response.token.token);
    myForm.submit();
};

var errorCallback = function(data) {
    if (data.errorCode === 200);
    else alert(data.errorMsg);
};

var tokenRequest = function() {
    var args = {
        sellerId: "1111111111111",
        publishableKey: "2222222-222222-22222-B57C-C62D1893D2C7",
        ccNo: $("#ccNo").val(),
        cvv: $("#cvv").val(),
        expMonth: $("#expMonth").val(),
        expYear: $("#expYear").val()
    };
    TCO.requestToken(successCallback, errorCallback, args);
};

$(function() {
    TCO.loadPubKey();

    $("#myCCForm").submit(function(e) {
        // Call our token request function
        tokenRequest();

        // Prevent form from submitting
        return false;
    });
});

PHP LARAVEL BACKEND CODE

    Twocheckout::privateKey('MY PRIVATE KEY');
    Twocheckout::sellerId('SELLER ID');
    Twocheckout::username('USERNAME');
    Twocheckout::password('PW');

    Twocheckout::verifySSL(false);
    Twocheckout::format('json');

    try {
        $charge = \Twocheckout_Charge::auth(array(
            "sellerId" => "SELLER ID",
            "merchantOrderId" => "1",
            "token" => $request->token,
            "currency" => 'USD',
            "total" => '4.99',
            "billingAddr" => array(
                "name" => 'John Doe',
                "addrLine1" => '123 Test St',
                "city" => 'Columbus',
                "state" => 'Ohio',
                "zipCode" => '43123',
                "country" => 'USA',
                "email" => '[email protected]',
                "phoneNumber" => '5555555555'
            ),
            "demo" => true
        ));

        dd($charge);
    }catch (\Twocheckout_Error $e)
    {
        dd($e);
    }

This image is what I get as response



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source