安装从这个 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”之类的错误。如何解决这个问题