英文:
Approved Orders Not Showing Up in PayPal Transaction History
问题
我正在使用PayPal API来处理我的网站上的付款(目前是在本地托管)。
我使用CAPTURE
作为意图创建订单,一旦付款成功提交,我会收到一个APPROVED
的响应。然而,我的PayPal账户余额没有更新,我的PayPal交易历史中也没有添加订单(即使过了几天)。我正在使用LIVE凭据而不是沙箱,所以这不应该是个问题。
我在PayPal论坛上找到了一个完全相同的问题,但没有回应。
这是我检查客户端提交的订单是否已被批准的后端代码:
$orderId = $_POST['orderId'];
$url = "https://api.paypal.com/v2/checkout/orders/$orderId";
$headers = array(
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode($clientId . ':' . $clientSecret),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
if ($response) {
$responseData = json_decode($response, true);
$orderStatus = $responseData['status'];
if ($orderStatus === 'APPROVED') {
// 这部分会运行,但我的PayPal余额不会改变
echo 'SUCCESS';
}
}
英文:
I am using the PayPal API to process payments on my website (it is hosted locally for now).
I create the order with CAPTURE
as the intent and once the payment is successfully submitted I get back an APPROVED
response. However, the balance on my PayPal account has not been updated nor have the orders been added to my PayPal transaction history (even after days). I am using my LIVE credentials and not the sandbox so that shouldn't be an issue.
I found someone on the PayPal forums with the exact same problem but no response.
Here is my backend code that checks if the order submitted on the client has been approved:
$orderId = $_POST['orderId'];
$url = "https://api.paypal.com/v2/checkout/orders/$orderId";
$headers = array(
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode($clientId . ':' . $clientSecret),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
if ($response) {
$responseData = json_decode($response, true);
$orderStatus = $responseData['status'];
if ($orderStatus === 'APPROVED') {
// this part runs but my PayPal balance does not change
echo 'SUCCESS';
}
}
答案1
得分: 2
以下是已翻译的内容:
完成详细步骤,请参阅标准集成指南。
订单获得批准后,必须进行捕获。捕获请求可能成功或失败。根据此响应,您应向付款人显示成功或失败消息。
在onApprove
函数中使用JS SDK进行批准。
英文:
For complete steps, see the standard integration guide.
After an order is approved it must be captured. The capture request may succeed or fail. You should display a success or failure message to the payer based on this response.
Use the JS SDK for approval and do this from the onApprove
function.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论