贝宝智能订阅服务器端 [英] PayPal Smart Subscribe server side
问题描述
你好,我试图将我的 PayPal 智能订阅按钮 javascript 转换为服务器端,特别是在 PHP 上.但我一直在网上查找,PayPal 文档仍然找不到和来源.它类似于这个服务器端的PayPal演示.>
<script src=https://www.paypal.com/sdk/js?client-id=Subscription_id&vault=true";data-sdk-integration-source=button-factory"></script><脚本>贝宝.按钮({风格: {形状:'矩形',颜色:金色",布局:'水平',标签:'订阅'},创建订阅:函数(数据,动作){返回 actions.subscription.create({'计划_id':'计划_id'});},onApprove:函数(数据,动作){警报(数据.订阅ID);}}).render('#paypal-button-container');
我不知道演示示例,但是 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 调用,您需要分别从 createSubscription
和 onApprove
(类似于 一次结帐演示您链接到)
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)
这篇关于贝宝智能订阅服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!