已批准的订单未显示在PayPal交易历史记录中。

huangapple go评论79阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年5月25日 00:40:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76325745.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定