【问题标题】:PayPal Smart Button Payment Not Going ThroughPayPal 智能按钮付款未通过
【发布时间】:2020-07-17 02:41:42
【问题描述】:

我的 Angular 网页上有一个 PayPal 智能按钮,如下所示:

paypal.Buttons({
      createOrder: (data, actions) => {
        return actions.order.create({
          purchase_units: [
            {
              description: this.product.description,
              amount: {
                currency_code: 'USD',
                value: this.product.price,
              }
            },
          ],

          application_context: {
            shipping_preference: 'NO_SHIPPING'
          }
        });
      },

      onApprove: async (data, actions) => {
        this.dataService.reserveReservation();
        const order = actions.order.capture();
        alert('Transaction Completed!');
      }
    }).render(this.paypalElement.nativeElement);

95% 的时间完成了购买,但偶尔会在没有付款的情况下调用 dataService.reserveReservation。如果付款失败,actions.order.capture() 是否会返回一些错误时间,或者为什么在付款未通过且未显示在我的 PayPal 主页活动选项卡中的任何位置时调用 onApprove 回调?如何确保每次都进行付款?

【问题讨论】:

    标签: angular paypal


    【解决方案1】:

    捕获可能会失败; https://developer.paypal.com/docs/checkout/integration-features/funding-failure/ 列出了一些失败场景的示例——因此,您的代码属于捕获解析之后。

    具体而言,请参阅https://developer.paypal.com/demo/checkout/#/pattern/client 的示例——在actions.order.capture() 成功完成付款后,您的代码应该在.then() 承诺链中。

    并确保将结果正确返回给 onApprove 的调用者。

    【讨论】:

    • 感谢您的回答,这是救命稻草。我确实有一个问题,为什么我们要返回 actions.order.capture() 的结果?如果是这样,如果我使用 await/async 而不是 .then,我将真正返回什么
    • 除了示例中的内容之外,我不知道正确的实现
    猜你喜欢
    • 2019-11-16
    • 2020-03-23
    • 1970-01-01
    • 2012-09-26
    • 2020-06-02
    • 2020-08-13
    • 2018-10-27
    • 2014-09-17
    • 2014-02-27
    相关资源
    最近更新 更多