簡體   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