三天以来,我一直在努力让 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'
)
到目前为止一切正常。我得到一个 OrderId,我返回到 AJAX 调用,然后我能够插入凭据并支付给定的价格。
之后钱从买家账户中消失,但显示“待定”,这里是截图(但是德语) payment_is_pending.png
在卖家帐户上,我无法选择“批准”之类的任何内容。我找到了一个类似 paypal checkout api 的例子,并试图将它复制到我的代码中,但是是的......同样的故事。然后我想问题可能出在卖家沙盒帐户上,但如果我尝试它,那么由 paypal 教程创建和提供的沙盒帐户也会显示待处理。
请帮忙!
素胚勾勒不出你
相关分类