我们可以通过使用
/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
因此,当提出请求时,我通过了这样的计划:
// 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
}
}
]
},
});
看起来我必须创建一个不同的计划,但仍然想知道是否有人在他们的应用程序中遇到过这种问题。
参考文献
创建不同的计划或使用total_cycles:1进行试用