Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kyos's avatar
Level 6

Stripe Multiple Charges

I guys how can I perform multiple charges against one Customer with Stripe.js

0 likes
12 replies
kyos's avatar
Level 6

For example if I have 3 packages with 3 different prices. And when the client "register" we choose the package that he want.

My code:

        $customer = Stripe_Customer::create([
            'card' => $data ['token'],
            'description' => $data ['name']
        ]);

        Stripe_Charge::create([
            'customer' => $customer->id,
            'amount' => 1000,
            'currency' => 'eur'
        ]);

        return $customer->id;

Should this "amount" value change if the package change?

MThomas's avatar
MThomas
Best Answer
Level 35

If you are using Laravel, checkout Laravel Cashier, this might make your life a lot easier if you will use plans :)

1 like
kyos's avatar
Level 6

Oh my god much more cleaner and simple! your right man tanks!

kyos's avatar
Level 6

Just one more question @MThomas I need to install "stripe" package for example("stripe/stripe-php": "1.17.2") in my json file or "cashier" have all Stripe features?

MThomas's avatar

@kyos, no Cashier will pull that in for you (it is an dependency for that package) so you don't need to worry about it.

kyos's avatar
Level 6

@MThomas just one simple question and I finish this. Cashier have any option to attach plans to "forms". Ive created 3 plans with stripe but in terms of security its better create manually in my form "registration"?

kyos's avatar
Level 6

I think "subscription plan" should be inserted manually because someone change the values.

MThomas's avatar

@kyos, no problem at all!

If you are asking if the form stripe plan_id's that are used to populate the select box are stored locally on your app the answer is no, they are received from stripe.

You could save them if you want, take a look at webhooks, using them you can be informed if a new plan is created an you could store them in the database.

An other option might be that you cache the value received from stripe containing the subscription ID's (Cashier might do this already, I don't know).

There is no danger in retrieving the plan_id's directly from Stripe, this is only a lot slower then retrieving them from your own Database. And if you are afraid that someone might change the post data you can always check (using webhooks) if the details of the payment send to stripe match your own database.

And the select box should be populated with the plan_id, and this ID is send to stripe, not the amount someone has to pay to you, so they can't 'manipulate' the form (easy) that they pay 5 dollar for the 50 dollar plan.

Update: There are a couple of lessons on Laracast about Stripe, even if you will use Cashier, watch all those lessons, it will give you a much better idea on how stripe works: https://laracasts.com/search?q=stripe

1 like

Please or to participate in this conversation.