我能够创建客户并将其添加到订阅计划中;以下代码有效:
\Stripe\Stripe::setApiKey("sk_test_tz7AKV73RPCd7p**********");
// create Customer
$customer = \Stripe\Customer::create(array(
"email" => $email,
"plan" => $plan_id,
"source" => $token,
"metadata" => array(
"nome" => $name,
"tel" => $tel,
"indirizzo" => $indirizzo,
"città" => $address_city,
"provincia" => $address_state,
"cap" => $address_zip
),
));
然后,如果我添加trial_period_days" => 30
选项,我会收到以下错误:
1个异常:异常#0(Stripe \ Error \ InvalidRequest):已收到 未知参数:trial_period_days
我将它添加到选项哈希中,如下所示:
// create Customer
$customer = \Stripe\Customer::create(array(
"email" => $email,
"plan" => $plan_id,
"trial_period_days" => 30,
"source" => $token,
"metadata" => array(
"nome" => $name,
"tel" => $tel,
"indirizzo" => $indirizzo,
"città" => $address_city,
"provincia" => $address_state,
"cap" => $address_zip
),
));
答案 0 :(得分:0)
trial_period_days
是应在Subscription
创建期间使用的参数,因此我编辑了我的代码如下:
// create Customer
$customer = \Stripe\Customer::create(array(
"email" => $email,
"source" => $token,
"metadata" => array(
"nome" => $name,
"tel" => $tel,
"indirizzo" => $indirizzo,
"città" => $address_city,
"provincia" => $address_state,
"cap" => $address_zip
),
));
// associate Customer to the Plan
\Stripe\Subscription::create(array(
"customer" => $customer,
"plan" => $plan_id,
"trial_period_days" => 30,
));