这是回复,我不明白问题出在哪里。
{
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id": "5939e86ea6f6e",
"details": [
{
"field": "/",
"location": "body",
"issue": "MALFORMED_REQUEST_JSON",
"description": "The request JSON is not well formed."
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-MALFORMED_REQUEST_JSON",
"rel": "information_link",
"encType": "application/json"
}
]
}
这段代码,也就是所谓的捕获端点:
$headerForBasicAuth = $this->paypalModel->getBasicAuthHeader();
$http = Http::withHeaders([
'Authorization' => 'Basic '.$headerForBasicAuth,
'Content-Type' => 'application/json'
]);
$response = $http->post($this->paypalModel->getBasePath().'/v2/checkout/orders/'.$request->orderID.'/capture')->body();
如果需要,有代码,我如何创建订单:
$headerForBasicAuth = $this->paypalModel->getBasicAuthHeader();
$http = Http::withHeaders([
'Authorization' => 'Basic '.$headerForBasicAuth,
'Content-Type' => 'application/json'
]);
$body = [
'intent' => "CAPTURE",
'purchase_units' => [
[
'payee' => [
"merchant_id" => "V2B4REMFCWFE6"
],
'amount' => [
'currency_code' => 'USD',
//'value' => $data['price']
'value' => '15'
],
'payment_instruction' => [
'disbursement_mode' => 'INSTANT',
'platform_fees' => [
[
'amount' => [
'currency_code' => 'USD',
'value' => '5'
]
]
]
]
]
],
'application_context' => [
'cancel_url' => 'http://laravel-paypal-example.test',
'return_url' => 'http://laravel-paypal-example.test',
'shipping_preference' => 'NO_SHIPPING'
]
];
$response = $http->post($this->paypalModel->getBasePath().'/v2/checkout/orders', $body)->body();
我正在使用平台费,但在管理菜单中,我无法启用平台费复选框,每次都给予一个错误:“您的设置未保存。请稍后再试。”
orderID没问题,我检查了很多次。所以,当我创建订单时,我可以在PayPal结帐时接受付款,但当交易被批准时,我无法使用orderID捕获它。
1条答案
按热度按时间xhv8bpkk1#
不知何故,在您发布到/capture端点的内容中有一个请求主体。通过查看您的代码,我无法告诉您如何/为什么添加主体,但它实际上正在添加,并且添加的内容不是有效的JSON,因此请求被拒绝。