我有一个情况,我必须切换价格ID,一旦试用已在条带API结束。
到目前为止,我试图创建一个时间表,但它创建了一个新的订阅。这是我的代码如下。
$data = [
'customer' => $stripeCustomer->id,
'items' => [
['price' => $priceId],
],
'collection_method' => 'charge_automatically',
'cancel_at' => Carbon::now()->addYears(1)->timestamp,
'description' => $description,
];
$subscription = $this->stripe->subscriptions->create($data);
$schedule = $this->stripe->subscriptionSchedules->create([
'from_subscription' => $subscription->id,
//'customer' => $stripeCustomer->id,
//'start_date' => Carbon::now()->addYears(1)->timestamp,
'start_date' => Carbon::now()->addSeconds(60)->timestamp,
'end_behavior' => 'release',
'phases' => [
[
'items' => [
[
'price' => $product['product']->metadata->schedule_price,
'quantity' => 1,
],
],
//'end_date' => Carbon::now()->addYears(20)->timestamp,
],
],
]);c
字符串
1条答案
按热度按时间aoyhnmkz1#
在创建订阅计划时使用
from_subscription
参数时,您将无法使用大多数其他参数。您需要将当前订阅计划创建请求拆分为两个单独的请求。第一个请求应仅使用
from_subscription
参数创建订阅计划。创建订阅计划后,您可以发出另一个请求以更新它并进行所需的更改。来源:https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-from_subscription