我试图使用skipcash作为我的支付网关,但当我试图张贴付款,它返回和一个错误,不知道这是从哪里来的。
这是我的代码结构
$formData = [
"uid" => Str::uuid()->toString(),
"keyId" => $skipCashKeyId,
"amount" => number_format($order->total_amount, 2),
"firstName" => $order->user->first_name,
"lastName" => $order->user->last_name,
"phone" => $order->user->phone_number,
"email" => $order->user->email,
"street" => "CA",
"city" => "TempCity",
"state" => "00",
"country" => "00",
"postCode" => "01238",
"transactionId" => $order->reference_no,
"orderId" => $order->id
];
$query = http_build_query($formData, "", ",");
$signature = hash_hmac('sha256', json_encode($query), $skipCashSecretKey);
$headers = [
'Authorization: ' . base64_encode($signature),
'Content-Type: application/json;charset=UTF-8',
'x-client-id: ' . $skipCashClientId
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $skipCashUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formData);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
但回应是这样的:
"data": {
"$": [
"'-' is invalid within a number, immediately after a sign character ('+' or '-'). Expected a digit ('0'-'9'). Path: $ | LineNumber: 0 | BytePositionInLine: 1."
]
},
我不知道这个问题是在SkipCash API还是什么,但是他们的文档有点不完整,所以也许有些人有SkipCash的经验,你如何格式化你的有效载荷和授权。
谢谢
1条答案
按热度按时间qgzx9mmu1#
我已经修好这个了。
这里的问题是字段没有正确地与需求对齐。