繁体   English   中英

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

[英]Paypal Checkout - Payment always on pending

三天以来,我一直在尝试让 Paypal 结账工作,但我总是遇到订单已创建并且资金从购买账户中消失但没有到达收款人账户的问题。 所以这是我的设置:

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 会被回调,并且我也得到了该 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

在卖家账户上,我不能 select 像“批准”这样的东西。 我找到了一个 paypal 结帐 api 的示例,它的工作原理相似,并试图将其复制到我的代码中,但是是的……同样的故事。 然后我认为问题可能出在卖家沙盒帐户上,但如果我尝试使用 paypal 教程创建和提供的沙盒帐户,则它也表示挂起。

请帮忙!

付款待处理,因为没有沙盒帐户 email sb-2xact2876961@business.example.com已确认,因此付款在无人认领的 Z9ED39E2EA931586B6EZ92576A 中如果无人认领,待处理的无人认领款项将在 30 天后自动退回。

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/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM