2Checkout:错误请求 - 参数错误

时间:2014-08-10 09:59:33

标签: payment-gateway 2checkout

我发送以下数据。

array (size=7)
  'sellerId' => string '901252608' (length=9)
  'privateKey' => string '4A8093AA-6DC9-449B-BA7E-C9819ABB79D7' (length=36)
  'merchantOrderId' => string '12312' (length=5)
  'token' => string 'NTE0NTc5OTMtNWJmOC00YmE0LTkwN2YtNzg4MTNiN2QzNzI4' (length=48)
  'currency' => string 'USD' (length=3)
  'total' => string '10.00' (length=5)
  'billingAddr' => 
    array (size=6)
      'name' => string 'Joe Flagster' (length=12)
      'addrLine1' => string '123 Main Street' (length=15)
      'city' => string 'Townsville' (length=10)
      'state' => string 'Ohio' (length=4)
      'zipCode' => string '43206' (length=5)
      'country' => string 'USA' (length=3)

我得到了回应 错误请求 - 参数错误

为什么我收到错误回复

3 个答案:

答案 0 :(得分:2)

回答这个问题,也是成功完成第一次2checkout的完整指南。 Download 2检查来自github的lib文件

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example Form</title>
    <script type="text/javascript" src="https://www.2checkout.com/checkout/api/2co.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
    <form id="myCCForm" action="" method="post">
        <input name="token" type="hidden" value="" />
        <input id="ccNo" type="text" value="4000000000000002" autocomplete="off" required />
        <input id="expMonth" type="text" size="2" required value="12"/>
        <input id="expYear" type="text" size="4" required value="2016"/>
        <input id="cvv" type="text" value="123" autocomplete="off" required />
        <input type="submit" value="Submit Payment" />
    </form>
<script>
var successCallback = function(data) {
    var myForm = document.getElementById('myCCForm');
    myForm.token.value = data.response.token.token;
    myForm.submit();
};

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

var tokenRequest = function() {
    var args = {
        sellerId: "901294338",
        publishableKey: "D0E54E96-FBB9-4A9C-98F0-81359D3FE574",
        ccNo: $("#ccNo").val(),
        cvv: $("#cvv").val(),
        expMonth: $("#expMonth").val(),
        expYear: $("#expYear").val()
    };
    TCO.requestToken(successCallback, errorCallback, args);
};

$(function() {
    TCO.loadPubKey('sandbox');
    $("#myCCForm").submit(function(e) {
        tokenRequest();
        return false;
    });
});

</script>
</body>
</html>
<?php
if(isset($_POST['token'])){
    require_once("lib/Twocheckout.php");
    Twocheckout::privateKey('7EF672B0-9F5E-499E-B4AE-6CBEC67277E1');
    Twocheckout::sellerId('901294338');
    Twocheckout::verifySSL(false);  // this is set to true by default
    Twocheckout::sandbox(true);
    Twocheckout::format('json');
    try {
        $charge = Twocheckout_Charge::auth(array(
            "sellerId" => "901294338",
            "merchantOrderId" => "123",
            "token" => $_POST['token'],
            "currency" => 'USD',
            "total" => '10.00',
            "billingAddr" => array(
                "name" => 'Testing Tester',
                "addrLine1" => '123 Test St',
                "city" => 'Columbus',
                "state" => 'OH',
                "zipCode" => '43123',
                "country" => 'USA',
                "email" => 'testingtester@2co.com',
                "phoneNumber" => '555-555-5555'
            ),
            "shippingAddr" => array(
                "name" => 'Testing Tester',
                "addrLine1" => '123 Test St',
                "city" => 'Columbus',
                "state" => 'OH',
                "zipCode" => '43123',
                "country" => 'USA',
                "email" => 'testingtester@2co.com',
                "phoneNumber" => '555-555-5555'
            )
        ));
        echo '<pre>';print_r(json_decode($charge));echo'</pre>';
    } catch (Twocheckout_Error $e) {echo $e->getMessage();}
}
?>

您需要更改YOUR_SELLER_IDYOUR_PUBLIC_KEYYOUR_PRIVATE_KEY。如果生成sandbox

,请将production替换为else keep sandbox

答案 1 :(得分:1)

页面加载后是否设置了公钥?因为我有同样的问题,但那是因为我忘了在TCO变量中设置公钥。

您必须设置公钥,请尝试以下代码:

if 'CustomStack' in stack:
    # do your thing

请记住将此函数放在jQuery(function($)中,因为当您尝试访问TCO变量时必须加载twocheckout.js。

答案 2 :(得分:-1)

2checkout阻止您的帐户时出现

Bad request - parameter error错误。请检查并确保您拥有已批准帐户的2Checout销售许可