由于三天以来,我一直在尝试使Paypal Checkout正常工作,但我始终遇到这样的问题,即订单已创建,并且钱从购买帐户中走了,但没有到达收款人帐户。 所以这是我的设置:
JavaScript中的智能按钮整数:
paypal.Buttons({
env: enviroment,
// Set up the transaction
createOrder: function() {
let formData = new FormData();
formData.append('bookingId', bookingId);
return fetch (url_createOrder, {
method: 'POST',
body: formData
}).then(response => {
console.log(response);
return response.json()
})
.then(function(res) {
console.log(res);
return res.result.id;
});
},
// Finalize the transaction
onApprove: function(data, actions) {
console.log(data);
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
console.log(details);
// This function shows a transaction success message to your buyer
// window.location.href = 'danke.php';
});
}
}).render('#paypal-button-container');
您会看到 createOrder启动对此脚本的AJAX调用:
[...]
$client = new PayPalHttpClient($environment);
$request = new OrdersCreateRequest();
$request->prefer('return=representation');
$request->body = self::buildRequestBody($price);
// 3. Call PayPal to set up a transaction
$response = $client->execute($request);
echo json_encode($response, JSON_PRETTY_PRINT);
// 4. Return a successful response to the client.
return $response;
}
private static function buildRequestBody($price) {
return array(
'intent' => 'CAPTURE',
'application_context' => array(
'brand_name' => 'Example',
'cancel_url' => 'http://localhost/example/abbruch.php',
'return_url' => 'http://localhost/example/danke.php'
),
'purchase_units' => array(
0 => array(
'reference_id' => 'example_addr',
'description' => 'example Address',
'amount' => array(
'currency_code' => 'EUR',
'value' => $price
)
)
)
);
[...]
到目前为止,一切正常。我得到一个OrderId,返回到AJAX调用,然后我可以插入凭据并支付给定的价格。
当我完成付款后,JS文件中的智能按钮的onApprove会被调回,并且我也会收到正确的 action.order.capture()响应:
{create_time: "2020-08-14T19:37:59Z", update_time: "2020-08-14T19:38:20Z", id: "6FP46164U47878440", intent: "CAPTURE", status: "COMPLETED", …}
create_time: "2020-08-14T19:37:59Z"
id: "6FP46164U47878440"
intent: "CAPTURE"
links: [{…}]
payer:
address:
country_code: "DE"
__proto__: Object
email_address: "sb-ughwh2901918@personal.example.com"
name: {given_name: "John", surname: "Doe"}
payer_id: "8Z5RM2ERW6VTL"
__proto__: Object
purchase_units: [{…}]
status: "COMPLETED"
update_time: "2020-08-14T19:38:20Z"
__proto__: Object
此后,钱从买家帐户中扣除,但显示为“待处理”,此处为屏幕截图(但德语) payment_is_pending.png
在卖方帐户上,我无法选择“批准”之类的内容。我找到了一个与Paypal Checkout API相似的示例,并试图将其复制到我的代码中,但是是的。 然后我认为问题可能出在卖方沙箱帐户上,但是如果我尝试使用,则由贝宝教程创建并给出的沙箱帐户也将处于待处理状态。
请帮助!
答案 0 :(得分:0)
付款正在处理中,因为没有沙盒帐户的电子邮件sb-2xact2876961@business.example.com 已确认,因此付款处于无人认领状态。如果无人认领,待处理的无人认领付款将在30天后自动退还。
要申领付款,必须在沙箱帐户上通过https://www.sandbox.paypal.com/businessprofile/settings/email和https://developer.paypal.com/developer/notifications/确认电子邮件sb-2xact2876961@business.example.com