如何激活贝宝订阅? [英] How to activate a PayPal subscription?
问题描述
我已经使用PayPal
和SmartButtons
实现了定期付款系统.客户可以通过我的系统创建订阅,在结帐时,我将创建订阅:
I've implemented a recurring payments system using PayPal
and the SmartButtons
. The customer is able to create the subscription through my system, at the end of the checkout I get the subscription created:
{
"orderID": "3JR7411152833961C",
"subscriptionID": "I-J8CHJ9UKB8JU",
"facilitatorAccessToken": "A21AAElq71jrRrKHzaxxOeA4o7cOie83F_N-LKMZoAe2mhmaANy-a784yj9DUbSlQPIxtu_O-7XyzHWab23gKVgwhqK9Hjaow"
}
为了激活订阅并获得付款,我需要执行它,因此我编写了此方法:
in order to activate the subscription and get the payment I need to execute it, so I wrote this method:
let executeAgreement = (paymentToken) => {
paypal.billingAgreement.execute(paymentToken, {}, function (error, billingAgreement) {
if (error) {
console.log(error);
throw error;
}
else {
console.log('Billing Agreement Execute Response');
console.log(JSON.stringify(billingAgreement));
}
});
}
问题出在我身上
响应:{ 名称:"BUSINESS_VALIDATION_ERROR", debug_id:'82426af46aee4', 消息:验证错误.", information_link:" https://developer.paypal.com/docs/api /payments.billing-agreements#errors ", 详细信息:[[Object]], httpStatusCode:400 }, httpStatusCode:400 }
response: { name: 'BUSINESS_VALIDATION_ERROR', debug_id: '82426af46aee4', message: 'Validation Error.', information_link: 'https://developer.paypal.com/docs/api/payments.billing-agreements#errors', details: [ [Object] ], httpStatusCode: 400 }, httpStatusCode: 400 }
我将executeAgreement
,但是我想的问题是,在创建的订阅中,我只能获得订阅的ID,而不是paymentToken
,我该如何解决?
I send to executeAgreement
the subscriptionId, but I guess the problem it's just that, in the created subscription I only reiceve the id of the subscription not the paymentToken
, how can I fix?
本质上:如果我只有以下方法返回的订阅ID,如何执行/激活订阅:
Essentially: how can I execute/activate the subscription if I've only the subscription id returned by the following method:
opts.createSubscription = function (data, actions) {
that.step = that.steps.PAYPAL_EXTERNAL_WINDOW;
return actions.subscription.create({
plan_id: that.paymentData.plan.id,
application_context: {
user_action: "CONTINUE",
shipping_preference: 'NO_SHIPPING'
}
});
}
上面的方法返回orderId - subscriptionId - facilitatorAccessToken
,似乎在用户通过智能付款按钮批准了周期性付款后,我无法激活订阅ID.
the method above return orderId - subscriptionId - facilitatorAccessToken
, seems I'm not able to activate the subscription id after the user as approved the recurring payment through the smart payment buttons.
推荐答案
实际上,I-J8CHJ9UKB8JU
已经创建并处于活动状态,您无需执行任何操作.
Actually, I-J8CHJ9UKB8JU
is already a created and active subscription and you don't need to execute anything.
执行帐单协议的概念来自于Subscriptions API之前的旧文档.
The notion of executing a billing agreement is something from old documentation that predates the Subscriptions API.
在当前的Sbscriptions API中,您只需创建并激活订阅:
In the current Sbscriptions API, you would simply create and activate a subscription:
https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create
接着重定向到批准URL,或使用智能付款"按钮(这样做会更好,因为它打开了上下文"批准-无需任何重定向)
Followed by either a redirection to an approval URL, or use of the Smart Payment Button (which is much better, since it opens up an "in context" approval -- no need for any redirect)
因此,无论如何,您都有有效的订阅ID:I-J8CHJ9UKB8JU
So anyway, you have your active Subscription ID: I-J8CHJ9UKB8JU
现在只需保存该对象并将其与客户对象相关联.
Now just save this object and associate it with your customer object.
这篇关于如何激活贝宝订阅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!