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

tehseen's avatar

Stripe subscription with custom order amount.

Hello,

Please guide me. I need to make a subscription payments with stripe, So the thing is we have two option one is simple order place with one time payment and the other one is 6 month subscription so we need to charge the customer every 6 months with same order amount he just created.

For the simple order i do this and its working fine.

\Stripe\Stripe::setApiKey("sk_test_exshEdOigYxgh2Fsr5qxpxQf");

// Token is created using Checkout or Elements!
// Get the payment token ID submitted by the form:
$token = $_POST['stripeToken'];
$charge = \Stripe\Charge::create([
    'amount' => 999,
    'currency' => 'usd',
    'description' => 'Example charge',
    'source' => $token,
]);

so if customer click on subscription then this order make as subscription and we charge the customer every 6 month and we ship the order.

I did not user any or package i am developing it custom way in laravel.

What information i need when i charge customer every month, I don't want to use plan and defualt stripe subscription.

Please help

thanks in advance

0 likes
14 replies
tehseen's avatar

But as i asked i dont have any of packages used in my project.

Need to done with custome way.

Please advice.

tehseen's avatar

We don't need the fixed price subscription with stripe i need the same order amount a user can create.

D9705996's avatar

@tehseen - why are you unable to to use other packages? If they are not installed you can do so with composer e.g for cashier

composer require "laravel/cashier":"~7.0"

Otherwise you are going to have to write your own code to replicate the functionality the package provides for you.

tehseen's avatar

@D9705996 my scenario is that when a order is make we have the check either its a order with subscription or simple. So for simple order i already did the solution and charge the customer but if the order is make with subscription when the total amount of the order and that specific order is made for subscription.

Please advice.

D9705996's avatar

@tehseen - That doesn't answer the question I asked.

why are you unable to to use other packages?

tehseen's avatar

Because i already create the normal payment with custom way like i mentioned in my question. So if i used package then i need to change my all code.

D9705996's avatar

Not sure I follow why you need to amend you existing code to add new subscription functionality using cashier? I would also suggest that you could simplify you existing code (from the examples above) by replacing with cashier code.

I understand this works now but going forward it will be much easier if you replace this using the official packages. there will be less code that is more readable and is built by Stripe experts to make our life easier!

If you still want to roll your own then you are going to have to look through the Stripe API documentation to find exactly how to code your custom solution. I don't have enough expertise to help as I have always used cashier to simplify my life.

1 like
tehseen's avatar

Great, Okay so i have use two methods in my application, the cashier also work with paypal recurring payment that made with subscriptions ?

D9705996's avatar

Yes you can but not the best idea. I would stick to one provider if you can. Certainly until you are happy that you can take one off and subscription payments with one provider e.g. Stripe.

Please or to participate in this conversation.