【问题标题】:paypal subscription method without the buttons - Javascript/Angular没有按钮的贝宝订阅方法 - Javascript/Angular
【发布时间】:2021-06-25 04:24:33
【问题描述】:

我正在实施支付宝的地方进行付款结账。我使用他们的方法渲染了贝宝按钮,但我想将这些按钮的操作放在我的自定义按钮上,但它不起作用。

我尝试更改功能,但没有成功。

这是呈现按钮和执行结帐操作的函数:

paypal.Buttons({
      style: {
        shape: 'rect',
        color: 'gold',
        layout: 'vertical',
        label: 'subscribe'
      },
      createSubscription(data, actions) {
        return actions.subscription.create({
          /* Creates the subscription */
          plan_id: 'My ID hiden'
        });
      },
      onApprove(data, actions) {
        alert(data.subscriptionID); // You can add optional success message for the subscriber here
      }
    }).render(this.paypalElement2.nativeElement);

我试着做这个:

checkout() {
   paypal.Buttons({
        createSubscription(data, actions) {
          return actions.subscription.create({
            /* Creates the subscription */
            plan_id: ''
          });
        },
        onApprove(data, actions) {
          alert(data.subscriptionID); // You can add optional success message for the subscriber here
        }
      });

}

但是当我按下按钮时没有任何反应。

有没有办法制作这项工作?

【问题讨论】:

    标签: javascript angularjs angular paypal


    【解决方案1】:

    我想将这些按钮的操作放在我的自定义按钮上

    不能用 PayPal JavaScript 完成,paypal.Buttons(...)

    如果您想使用自己的按钮直接开始结帐,您只需与 PayPal REST API(无 JS SDK)集成,并重定向到您通过 API 创建订阅时返回的approve href。不建议这样做,因为它显然涉及从您的网站重定向。使用 PayPal JS 按钮效果更好,因为它可以让您的网站在后台加载并打开一个小窗口进行付款批准。

    【讨论】:

      猜你喜欢
      • 2013-01-24
      • 2012-04-09
      • 2012-10-21
      • 2014-07-27
      • 2012-02-18
      • 2013-06-15
      • 2014-11-30
      • 2015-01-05
      相关资源
      最近更新 更多