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

christogonus's avatar

Manage Subscription With Multiple Payment Gateway Options

In an app, I have used Cashier Stripe and everything works fine until now that I want to accept payment from Paypal too.

I am not looking to get rid of Stripe. I only want payment option to be switchable.

How can I have a client switch payment from stripe to paypal, can can switch back to stripe if need be.

What is on my mind is to have my system generate invoices and have Stripe and Paypal as Payment button. But I am afraid of breaking things as the website is LIVE.

Please advise me how you'd handle a situation as this.

Thanks.

0 likes
4 replies
LaryAI's avatar
Level 58

To manage subscription with multiple payment gateway options, you can follow these steps:

  1. Add the necessary configuration for PayPal in your Laravel application. You can refer to the Laravel documentation for integrating PayPal: https://laravel.com/docs/8.x/billing#paypal

  2. Create a new payment method option in your user interface to allow users to switch between Stripe and PayPal. This can be a dropdown or a toggle button.

  3. When the user selects PayPal as the payment method, update the user's payment method in your database or user profile to reflect the change.

  4. Modify your billing logic to handle the selected payment method. You can use conditional statements to determine which payment gateway to use for processing payments.

  5. Update your invoice generation logic to include both Stripe and PayPal payment buttons. You can conditionally display the appropriate button based on the selected payment method.

  6. Test the changes thoroughly in a development or staging environment before deploying to your live website. This will help ensure that everything works as expected and minimize the risk of breaking anything.

Here's an example of how you can handle the payment method switching logic in your code:

// Get the current user
$user = Auth::user();

// Get the selected payment method from the user interface
$selectedPaymentMethod = request('payment_method');

// Update the user's payment method in the database
$user->payment_method = $selectedPaymentMethod;
$user->save();

// Process the payment based on the selected payment method
if ($selectedPaymentMethod === 'stripe') {
    // Process payment using Stripe
    // ...
} elseif ($selectedPaymentMethod === 'paypal') {
    // Process payment using PayPal
    // ...
} else {
    // Handle invalid payment method
    // ...
}

Remember to replace the placeholder code with your actual implementation and adapt it to fit your specific application structure.

Note: It's always a good practice to backup your live website before making any significant changes to ensure you can revert back if anything goes wrong.

MohamedTammam's avatar
Level 51

You need to write everything related to payment for PayPal and then handle both cases separately.

I would suggest to move to Laravel Cashier paddle. It works with PayPal, credit cards and other options.

3 likes
christogonus's avatar

@MohamedTammam Thanks for your suggestion of Paddle.

My team do not like Paddle because of inconsistent charges: for instance, a client subscribes for $17.month plan. They charge $2 fee in the first month, second month can be $1.7 for same client and third month will be $4.

But, it might be the last option though.

Please or to participate in this conversation.