繁体   English   中英

没有按钮的 paypal 订阅方法 - Javascript/Angular

[英]paypal subscription method without the buttons - Javascript/Angular

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

我试图改变 function 但它没有用。

这是 function 呈现按钮并执行结帐操作:

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
        }
      });

}

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

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

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

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

If you want to use your own button to directly start the checkout, you need to integrate only with the PayPal REST API (no JS SDK) and redirect to the approve href returned when you create a subscription via API. 不建议这样做,因为它显然涉及从您的网站重定向。 使用 PayPal JS 按钮效果更好,因为它可以让您的网站在后台加载,并打开一个小的 window 用于付款批准。

暂无
暂无

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

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