我正在使用 2checkout api 进行网站产品销售。因此,我调用 2checkout api 来创建销售,我可以在其中调用 api 与单个产品的总金额。它看起来像流动:
try {
$charge = Twocheckout_Charge::auth(array(
"merchantOrderId" => "123",
"token" => $_POST['token'],
"currency" => 'USD',
"total" => $first_bill['amount'],
"billingAddr" => array(
"name" => $_POST['b_name'],
"addrLine1" => $_POST['b_address'],
"city" => 'Columbus',
"state" => 'OH',
"zipCode" => '43123',
"country" => $_POST['b_country'],
"email" => $_POST['b_emaill'],
"phoneNumber" => $_POST['b_phone']
),
"shippingAddr" => array(
"name" => 'Testing Tester',
"addrLine1" => '123 Test St',
"city" => 'Columbus',
"state" => 'enter code hereOH',
"zipCode" => '43123',
"country" => 'USA',
"email" => 'example@2co.com',
"phoneNumber" => '555-555-5555'
)
));
if ($charge['response']['responseCode'] == 'APPROVED') {
echo $response;exit;
// echo "Thanks for your Order!";
// echo "<h3>Return Parameters:</h3>";
// echo "<pre>";
// print_r($charge);
// echo "</pre>";
}
else
{
$this->Registrationmodel->delete_account($accounts_id);
echo $charge['response']['responseCode'];
exit;
}
}
catch (Twocheckout_Error $e)
{
echo $e->getMessage();
exit;
}
}
因此,当我尝试单独设置行项目时,如下所示:
try {
$charge = Twocheckout_Charge::auth(array(
"merchantOrderId" => "123",
"token" => $_POST['token'],
"currency" => 'USD',
//"total" => $first_bill['amount'],
"billingAddr" => array(
"name" => $_POST['b_name'],
"addrLine1" => $_POST['b_address'],
"city" => 'Columbus',
"state" => 'OH',
"zipCode" => '43123',
"country" => $_POST['b_country'],
"email" => $_POST['b_emaill'],
"phoneNumber" => $_POST['b_phone']
),
"LineItem" => array(
"duration" => 'Forever',
"price" => '10',
"productId" =>'1235',
"quantity" => '1',
"recurrence" => '1 Month',
"tangible" => 'N',
"type"=>'product'
),
"shippingAddr" => array(
"name" => 'Testing Tester',
"addrLine1" => '123 Test St',
"city" => 'Columbus',
"state" => 'OH',
"zipCode" => '43123',
"country" => 'USA',
"email" => 'example@2co.com',
"phoneNumber" => '555-555-5555'
)
));
if ($charge['response']['responseCode'] == 'APPROVED') {
$response = $this->return_information($charge['response']['orderNumber']);
echo $response;exit;
// echo "Thanks for your Order!";
// echo "<h3>Return Parameters:</h3>";
// echo "<pre>";
// print_r($charge);
// echo "</pre>";
}
else
{
$this->Registrationmodel->delete_account($accounts_id);
echo $charge['response']['responseCode'];
exit;
}
}
catch (Twocheckout_Error $e)
{
$this->Registrationmodel->delete_account($accounts_id);
echo $e->getMessage();
exit;
}
}
它给了我参数错误。请问有人可以帮忙吗?如何使用 api 调用设置订单项?