且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

贝宝智能订阅服务器端

更新时间:2023-11-27 22:22:04

我不知道演示示例,但是 createSubscription 部分可以通过这个 API 调用完成:https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create

设置application_context ->user_action 值到 其他内容SUBSCRIBE_NOW 如果您不希望 PayPal 自动激活订阅.

然后你需要调用这个 API 来激活订阅:https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_activate

为了触发这两个 API 调用,您需要分别从 createSubscriptiononApprove(类似于 一次结帐演示您链接到)

hello in trying to convert my PayPal smart subscription button javascript into the server-side particularly on PHP. But I keep looking online and PayPal documentation still can't find and sources. It is similar to this PayPal demo of server-side.

<div id="paypal-button-container"></div>
    <script src="https://www.paypal.com/sdk/js?client-id=Subscription_id&vault=true" data-sdk-integration-source="button-factory"></script>
    <script>
      paypal.Buttons({
          style: {
              shape: 'rect',
              color: 'gold',
              layout: 'horizontal',
              label: 'subscribe'
          },
          createSubscription: function(data, actions) {
            return actions.subscription.create({
              'plan_id': 'Plan_id'
            });
          },
          onApprove: function(data, actions) {
            alert(data.subscriptionID);
          }
      }).render('#paypal-button-container');
    </script>

I'm not aware of a demo sample, but the createSubscription portion can be be done via this API call: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create

Set the application_context -> user_action value to something other than SUBSCRIBE_NOW if you don't want PayPal to automatically activate the subscription.

Then you'll need this API call to activate the subscription: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_activate

In order to trigger these two API calls you'll want fetch commands to two routes on your server, from createSubscription and onApprove respectively (similar to the one time checkout demo you linked to)