php - Stripe Plan, Customer, Subscription creation. Doesn't it create duplicates?
Get the solution ↓↓↓i'm building a payment flow using Stripe. The payment will result in a Subscription using Stripe APIs, but there is something I don't understand. Every tutorial includes first creating a Plan using stripe APIs, then a Customer, then the Subscription with the plan and customer responses.
My question is, do I need to send to Stripe the Plan and the Customer every time i submit a new subscription? More likely the Plan. There is just 1 plan and it never changes. If I send a new Plan (which is always the same) to stripe every time, doesn't it complain about it? Is this really the right way to do it? Or maybe I should send a plan just one time, save the returned ID and send that for subsequent subscriptions.
Fast demo about what every example i found is doing:
$customer = \Stripe\Customer::create(array(
'email' => $email,
'source' => $token
));
$plan = \Stripe\Plan::create(array(
"product" => [
"name" => $planName
],
"amount" => $priceCents,
"currency" => $currency,
"interval" => $planInterval,
"interval_count" => 1
));
$subscription = \Stripe\Subscription::create(array(
"customer" => $customer->id,
"items" => array(
array(
"plan" => $plan->id,
),
),
));
So as you can see Plan and Customer gets created for every subscription. What if I already sent that plan to Stripe during the last subscription activation?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type bool in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.