简体   繁体   English

获取具有试用期的 PayPal 订阅的订阅 ID

[英]Get Subscription ID of a PayPal subscription with a trial period

I need to implement a system in which users will have a trial period in their subscription and after that period the user should resume their subscription, I have achieved the same but when a user needs to be deleted the subscription has to be terminated for that when i researched I got an API to cancel a subscription via我需要实施一个系统,在该系统中,用户将在订阅中有一个试用期,在此之后用户应该恢复订阅,我已经实现了同样的效果,但是当需要删除用户时,必须终止订阅我研究了我得到了一个 API 来取消订阅

https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEG1P/cancel https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEG1P/cancel

where I-BW452GLLEG1P in the above is the subscription id, but I don't get a subscription id when I create a subscription via the method suggested on the reference page其中上面的I-BW452GLLEG1P是订阅 ID,但是当我通过参考页面上建议的方法创建订阅时,我没有得到订阅 ID

https://developer.paypal.com/docs/business/subscriptions/customize/trial-period/ https://developer.paypal.com/docs/business/subscriptions/customize/trial-period/

please share your thoughts if you encountered similar issues thanks如果您遇到类似问题,请分享您的想法谢谢

The page you reference is to create a plan.您引用的页面是创建一个计划。 Plans are then used to create subscriptions.然后使用计划来创建订阅。

To create a subscription using a plan, you can use an API call or a JS button.要使用计划创建订阅,您可以使用 API 调用或 JS 按钮。 The JS button is generally best since you need a buyer to approve the subscription anyway for it to be useful. JS 按钮通常是最好的,因为无论如何您都需要买家批准订阅才能使其有用。

The documentation for creating a button is at https://developer.paypal.com/docs/business/subscriptions/integrate/#3-create-payment-button创建按钮的文档位于https://developer.paypal.com/docs/business/subscriptions/integrate/#3-create-payment-button

Here is the relevant HTML/JS from there.这是那里的相关HTML/JS。

  <script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&vault=true&intent=subscription">
  </script> // Add your client_id

  <div id="paypal-button-container"></div>

    <script>
      paypal.Buttons({
        createSubscription: function(data, actions) {
          return actions.subscription.create({
            'plan_id': 'YOUR_PLAN_ID' // Creates the subscription
          });
        },
        onApprove: function(data, actions) {
          alert('You have successfully created subscription ' + data.subscriptionID); // Optional message given to subscriber
        }
      }).render('#paypal-button-container'); // Renders the PayPal button
    </script>

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

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