我正在尝试使用条纹API创建订阅。 但是一旦我在代码中加入了 “ trial_period_days_” => $ trial_days ,它就无法保存。
$ trial_days 包含一个整数,该整数减去当月剩余的天数并加14天。如果您将其回显,它将显示数字。这是完美的执行。
$trial_days = (date("m", strtotime("-1 months"))+14);
这是我的代码。
$stripe_subscription = \Stripe\Subscription::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"
},
请帮助。谢谢!
答案 0 :(得分:1)
当trial_period_days
与items
处于同一级别时,您在items
下有 $stripe_subscription = \Stripe\Subscription::create(array(
"customer" => $stripe_customer->id,
"items" => array(
"plan" => $stripe_plan->id
),
"trial_period_days" => $trial_days
));
,就像这样:
{{1}}
这应该可以解决您的问题。
答案 1 :(得分:0)
您可以尝试使用类似的东西
<spinner></spinner>
它将起作用。我正在当前的组织中使用它。