【发布时间】:2020-08-14 20:08:42
【问题描述】:
我已经使用PayPal 和SmartButtons 实施了一个定期支付系统。客户可以通过我的系统创建订阅,在结帐结束时我会创建订阅:
{
"orderID": "3JR7411152833961C",
"subscriptionID": "I-J8CHJ9UKB8JU",
"facilitatorAccessToken": "A21AAElq71jrRrKHzaxxOeA4o7cOie83F_N-LKMZoAe2mhmaANy-a784yj9DUbSlQPIxtu_O-7XyzHWab23gKVgwhqK9Hjaow"
}
为了激活订阅并获得付款我需要执行它,所以我写了这个方法:
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', 详细信息:[[对象]], http状态码:400 }, http状态码:400 }
我将subscriptionId 发送到executeAgreement,但我想问题在于,在创建的订阅中,我只收到了订阅的id 而不是paymentToken,我该如何解决?
本质上:如果我只有以下方法返回的订阅 ID,我该如何执行/激活订阅:
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。
【问题讨论】:
标签: paypal paypal-sandbox paypal-rest-sdk paypal-subscriptions