条纹"trial_period_days" PHP 不起作用



我正在尝试使用条纹API创建订阅。 但是一旦我在代码中包含"trial_period_days_"=> $trial_days,它就不会保存。

$trial_days 包含一个整数,该整数减去当月剩余的天数并加上 14 天。如果您将其回显出来,它将显示数字,这将完美执行。

$trial_days = (date("m", strtotime("-1 months"))+14);

这是我的代码。

$stripe_subscription =   StripeSubscription::create(array(
"customer" => $stripe_customer->id,
"items" => array(
"plan" => $stripe_plan->id,
"trial_period_days" => $trial_days
)
));

这是 API JSON 映射

"items": {
"object": "list",
"data": [
{
"id": "si_DPjpkyc3UVZfuI",
"object": "subscription_item",
"created": 1534221712,
"metadata": {
},
"plan": {
"id": "plan_DPjnUAy2jqHSkS",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 5000,
"billing_scheme": "per_unit",
"created": 1534221598,
"currency": "aud",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": "FPA",
"product": "prod_DPjmRCMbpYGdgJ",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},

请帮忙。谢谢!

当它应该与items处于同一级别时,您必须在itemstrial_period_days,如下所示:

$stripe_subscription =   StripeSubscription::create(array(
"customer" => $stripe_customer->id,
"items" => array(
"plan" => $stripe_plan->id
),
"trial_period_days" => $trial_days
));

这应该可以解决您的问题。

你能尝试使用这样的东西吗

$subscription = StripeSubscription::create([
'customer' => 'cus_4fdAW5ftNQow1a',
'items' => [['plan' => 'plan_CBb6IXqvTLXp3f']],
'trial_end' => 1536048827,
]);

它会起作用。我在当前的组织中使用它。

相关内容

  • 没有找到相关文章

最新更新