Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

php - PayPal Smart Subscribe server side

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

For subscriptions, by default the subscription will be activated automatically on approval, before onApprove is called.

You can set the application_context -> user_action to something other than SUBSCRIBE_NOW if you want to show a review step and activate with an API call.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...