2

この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」のようなエラーが表示されます。これを修正する方法

4

4 に答える 4

1

twocheckout のユーザー名とパスワードを設定すると、問題なく動作します。

この行の下に次の行を追加します。

require_once("lib/Twocheckout.php");

// Your username and password are required to make any Admin API call.
Twocheckout::username('username');
Twocheckout::password('password');
于 2015-05-22T10:30:25.023 に答える
0

2Checkout サンドボックスは、TLS 1.1 および 1.2 プロトコルのみをサポートします。このライブラリには、これらのプロトコルをサポートする問題はありません。実行している のバージョンを確認できますPHPOpenSSL? php -vopenssl version

OpenSSL は、v1.0.1 で TLS v1.1 および TLS v1.2 のサポートを追加しました。OpenSSL 1.0.0h と OpenSSL 1.0.1 の間の主な変更点

thx :クレイグクリステンソン

于 2016-02-18T10:20:18.160 に答える