【发布时间】:2021-09-07 22:56:05
【问题描述】:
我正在通过以下方式集成 afterpay 支付网关 https://developers.afterpay.com/afterpay-online/reference#create-checkout-1这个页面。 我在 curl 标头中添加了所有必需的参数。但我在卷曲响应中遇到错误。 我搜索了很多但没有得到任何解决方案,请建议任何正常工作的教程或提供任何解决方案。 这是我的卷曲代码
private function requestCurl($data){
$array = array(
'amount' => [
'amount' => number_format((float)$data['amount'], 2, '.', ''),
'currency' => 'USD'
],
'consumer' => [
'givenNames' => $data['first_name'],
'surname' => $data['last_name'],
'email' => $data['email']
],
'billing' => [
'name' => $data['first_name'] . ' '. $data['last_name'],
'line1' => $data['address'],
"area1" => "San Francisco",
"region"=> "CA",
"countryCode"=> "US",
'postcode' => $data['zip_code']
],
'shipping' => [
'name' => $data['first_name'] . ' '. $data['last_name'],
'line1' => $data['address'],
"area1" => "San Francisco",
"region"=> "CA",
"countryCode"=> "US",
'postcode' => $data['zip_code']
],
'merchant' => [
'redirectConfirmUrl' => 'https://localhost/beauty/public/checkout/success',
'redirectCancelUrl' => 'https://localhost/beuty/public/cart'
],
'taxAmount' => [
'amount' => 0.00,
'currency' => 'USD'
],
'shippingAmount' => [
'amount' => 5.00,
'currency' => 'USD'
]
);
$_h = curl_init();
curl_setopt_array($_h, [
CURLOPT_URL => "https://api.us-sandbox.afterpay.com/v2/checkouts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($array),
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Basic MYID",
"Content-Type: application/json",
"User-Agent: Readme.io API Simulator"
],
]);
echo "<pre>", print_r(curl_exec($_h));
}
我得到了回应
{
"errorCode" : "error",
"errorId" : "f91a4cc29d926c20",
"message" : "An error occurred processing your request",
"httpStatusCode" : 500
}
谢谢。
【问题讨论】:
-
如果是错误 500,那就是他们的错误。另外,您泄露了您的客户 ID(或类似的东西。编辑问题并考虑寻找 http 状态解释。
-
客户 ID 是虚拟文本,不是我的 ID :-)