在 PayPal 上修改订阅新计划时,如何在不试用的情况下覆盖计划?

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

我们可以通过使用

/v1/billing/subscriptions/{id}/revise
端点更改同一产品中的计划来升级或降级订阅。我们必须在帖子正文中为产品中现有的订阅提供新的计划 ID。

我当前的申请中有两个计划

Basic
Professional
。这是创建后他们的计费周期的样子。

// Billing Cycle for Basic
[
  {
    frequency: {
      interval_unit: 'DAY',
      interval_count: 7,
    },
    sequence: 1,
    tenure_type: 'TRIAL',
    pricing_scheme: {
      fixed_price: {
        value: '0',
        currency_code: 'USD',
      },
    },
    total_cycles: 1,
  },
  {
    frequency: {
      interval_unit: 'MONTH',
      interval_count: 1,
    },
    sequence: 2,
    tenure_type: 'REGULAR',
    pricing_scheme: {
      fixed_price: {
        value: '10',
        currency_code: 'USD',
      },
    },
    total_cycles: 0, // 0 means infinite
  },
];

// Billing Cycle for Premium
[
  {
    frequency: {
      interval_unit: 'DAY',
      interval_count: 7,
    },
    sequence: 1,
    tenure_type: 'TRIAL',
    pricing_scheme: {
      fixed_price: {
        value: '0',
        currency_code: 'USD',
      },
    },
    total_cycles: 1,
  },
  {
    frequency: {
      interval_unit: 'MONTH',
      interval_count: 1,
    },
    sequence: 2,
    tenure_type: 'REGULAR',
    pricing_scheme: {
      fixed_price: {
        value: '20',
        currency_code: 'USD',
      },
    },
    total_cycles: 0, // 0 means infinite
  },
];

我想要什么

我想要的是,一旦用户购买了

Basic
计划,3天后他想将其升级到
Premium
,那么我不想从高级计划中的
free trial
开始,而是作为
Regular
计费周期,这意味着当用户升级他/她的订阅时我想跳过试用部分。

我研究过的内容

我发现在 revise-endpoint 中,您还可以发送一个

plan
对象来自定义订阅,请参阅此处:https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_revise

PayPal documentation for customise subscription in revise request

因此,当提出请求时,我通过了这样的计划:

// making request using Paypal SDK, I know it's deprecated but I will change that later
  request.requestBody({
    plan_id: priceId,
    application_context: {
     ....// info here
    },
    plan: {
      billing_cycles: [
        {
          sequence: 1,
          total_cycles: 0,  // I was thinking it would remove trial, I know for regular one this is interpreted as infinity
        },
        {
          sequence: 2,
          total_cycles: 0,
          frequency: {  
            interval_unit: "DAY",  
            interval_count: 1  
          }
        }
      ]  
    },  
  });

//But I got this error from the PayPal
{"name":"UNPROCESSABLE_ENTITY","issue":"INVALID_TRIAL_BILLING_TOTAL_CYCLES",
"description":"Total cycles for trial billing must be greater than '0'."}]....]}


// other attempt I made is to start from sequence 2 directly but this doesn't work
// I didn't got the error using below but it I think included trial from existing
// price_id I am passing as a plan_id
  request.requestBody({
    plan_id: priceId,
    application_context: {
     ....// info here
    },
    plan: {
      billing_cycles: [
        {
          sequence: 2,
          total_cycles: 0,
          frequency: {  
            interval_unit: "DAY",  
            interval_count: 1  
          }
        }
      ]  
    },  
  });

我还阅读了此社区论坛:https://www.paypal-community.com/t5/REST-APIs/subscription-create-override-plan-Frequency-interval/td-p/3033004

看起来我必须创建一个不同的计划,但仍然想知道是否有人在他们的应用程序中遇到过这种问题。

参考文献

paypal paypal-sandbox paypal-rest-sdk paypal-subscriptions
1个回答
0
投票

创建不同的计划或使用total_cycles:1进行试用

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