【问题标题】:"cUrl call failed" using 2checkout“cUrl 调用失败”使用 2checkout
【发布时间】:2015-05-22 10:18:03
【问题描述】:

安装后从这个github下载的包。

https://github.com/2checkout/2checkout-php

require_once("lib/Twocheckout.php");

Twocheckout::privateKey('privatekey'); //Private Key

Twocheckout::sellerId('sellerid'); // 2Checkout Account Number

// If you want to turn off SSL verification (Please don't do this in your production environment)

Twocheckout::verifySSL(false);  // this is set to true by default
// To use your sandbox account set sandbox to true
Twocheckout::sandbox(true);
// All methods return an Array by default or you can set the format to 'json' to get a JSON response.

Twocheckout::format('json');

try {
$charge = Twocheckout_Charge::auth(array(
    "merchantOrderId" => "123",
    "token"      => $_POST['token'],
    "currency"   => 'USD',
    "total"      => '10.00',
    "billingAddr" => array(
        "name" => 'Joe Flagster',
        "addrLine1" => '123 Main Street',
        "city" => 'Townsville',
        "state" => 'OH',
        "zipCode" => '43206',
        "country" => 'USA',
        "email" => 'testingemail@gmail.com',
        "phoneNumber" => '555-555-5555'
    )
));

if ($charge['response']['responseCode'] == 'APPROVED') {
    echo "Thanks for your Order!";
    echo "<h3>Return Parameters:</h3>";
    echo "<pre>";
    print_r($charge);
    echo "</pre>";

}
} catch (Twocheckout_Error $e) {
print_r($e->getMessage());
}

使用沙盒模式提交表单后,它会显示类似“cUrl call failed”的错误。如何解决这个问题

【问题讨论】:

    标签: 2checkout


    【解决方案1】:

    添加下一行

    Twocheckout::verifySSL(false);
    

    【讨论】:

    • 这一点都不清楚,已被标记为待审核。 在哪里你会添加这条线? 它对改进代码有什么作用?
    • 在 require 语句之后和 try 块之前的任何位置添加此行。
    • 这行得通。记得在必要时也重新启用 SSL。
    【解决方案2】:

    如果我们为 twocheckout 设置用户名和密码,它将正常工作。

    在此行下方添加此行:

    require_once("lib/Twocheckout.php");
    
    // Your username and password are required to make any Admin API call.
    Twocheckout::username('username');
    Twocheckout::password('password');
    

    【讨论】:

      【解决方案3】:

      2Checkout 沙盒仅支持 TLS 1.1 和 1.2 协议。这个库应该没有支持这些协议的问题。你能检查一下你正在运行的PHP 和OpenSSL 的版本吗? php -v 和 openssl version

      OpenSSL 在 v1.0.1 中添加了对 TLS v1.1 和 TLS v1.2 的支持。 OpenSSL 1.0.0h 和 OpenSSL 1.0.1 之间的主要变化

      谢谢:craigchristenson

      【讨论】:

        【解决方案4】:

        我使用的是 Wamp64。当我添加 apache->modules->ssl 时,我的这个错误得到了解决。虽然我做到了

        Twocheckout::verifySSL(false);
        

        但如果不启用 ssl 就无法正常工作。

        【讨论】:

          猜你喜欢
          • 2016-04-24
          • 1970-01-01
          • 2016-08-15
          • 1970-01-01
          • 2013-11-30
          • 2014-02-16
          • 2023-03-10
          • 2016-10-05
          • 2021-12-07
          相关资源
          最近更新 更多