Paypal Checkout - 付款始终处于待处理状态

2023-06-24php开发问题
118

本文介绍了Paypal Checkout - 付款始终处于待处理状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

自从三天以来,我一直试图让 Paypal Checkout 工作,但我总是遇到订单已创建且资金从购买帐户中转入但未到达收款人帐户的问题.所以这是我的设置:

Since three days i am trying to get the Paypal Checkout to work but i always have the problem that the order is created and the money in gone from the buying account but not reaching the payee account. So here is my setup:

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 调用,然后我可以插入凭据并支付给定的价格.

Everything works so far to this point. I get a OrderId back which i return to the AJAX call and then i am am able to insert credentials and pay the given price.

当我完成支付时,JS 文件中智能按钮的 onApprove 被回调,我也得到了正确的 actions.order.capture() 响应:

When i finish the payment the onApprove of the smart buttons in the JS file get called back and i also get the correct response of that actions.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

Afterwards the money is gone from the buyer account but it says "pending", here a screenshot (but in german) payment_is_pending.png

在卖家帐户中,我无法选择批准"之类的选项.我找到了一个paypal checkout api的例子,它的工作原理类似,并试图将它复制到我的代码中,但是是的……同样的故事.然后我想问题可能出在卖家沙箱帐户上,但如果我尝试一下,哪个由贝宝教程创建和提供的沙箱帐户也说待处理.

On the seller account i cant select anything like "approve". I found an example of the paypal checkout api which works similar and tried to copy it into my code but yeah... same story. Then i thought maybe the problem is the seller sandbox account, but if i try it which an sandbox account created and given by a paypal tutorial is says pending as well.

请帮忙!

推荐答案

付款正在等待中,因为没有电子邮件 sb-2xact2876961@business.example.com confirmed 的沙箱帐户,因此付款处于无人认领状态.如果无人认领,待处理的无人认领款项将在 30 天后自动退还.

The payments are pending because there is no sandbox account with the email sb-2xact2876961@business.example.com confirmed, so the payments are in an unclaimed state. Pending unclaimed payments will be automatically returned after 30 days if left unclaimed.

要领取付款,必须通过 https://www.sandbox.paypal.com/businessprofile/settings/email 和 https://developer.paypal.com/developer/notifications/

To claim the payments, the email sb-2xact2876961@business.example.com must be confirmed on a sandbox account, via https://www.sandbox.paypal.com/businessprofile/settings/email and https://developer.paypal.com/developer/notifications/

这篇关于Paypal Checkout - 付款始终处于待处理状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17