如何激活PayPal订阅?

问题描述 投票:1回答:1

我已经使用PayPalSmartButtons实现了定期付款系统。客户可以通过我的系统创建订阅,在结帐时,我将创建订阅:

{
    "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”,详细信息:[[Object]],httpStatusCode:400},httpStatusCode:400}

[我发送给executeAgreement的subscriptionId,但我想问题是,在创建的订阅中,我只收到订阅的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
1个回答
0
投票

实际上,I-J8CHJ9UKB8JU已经创建并处于活动状态,您无需执行任何操作。

执行计费协议的概念来自于Subscriptions API之前的旧文档。

在当前的Sbscriptions API中,您只需创建并激活订阅:

https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create

接着重定向到批准URL,或使用智能付款按钮(这会更好,因为它打开了“上下文”批准-无需任何重定向)

所以无论如何,您都有有效的订阅ID:I-J8CHJ9UKB8JU

© www.soinside.com 2019 - 2024. All rights reserved.