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

proboy's avatar

Best approach for multi payment methods (Stripe/Cashier and others)

I have a boilerplate where Stripe/Cashier is already implemented, so I am done with users who can pay with cards, but I also have some users from some countries where they don't have credit cards, where I have to use a payment method from that country (cardless, with cash), so I want to ask about the best approach to implement Cashier and another payment method. Thanks in advance.

0 likes
2 replies
tisuchi's avatar

@proboy I think using a common interface will fix the issue for you. Here is my plan:

interface PayableMethod
{
    public function charge(int $amount, array $options = []);
}

// CashPayment utilize PayableMethod
class StripePayment implements PayableMethod
{
    public function charge(int $amount, array $options = [])
    {
        // your code
    }
}

// CashPayment utilize PayableMethod
class CashPayment implements PayableMethod
{
    public function charge(int $amount, array $options = [])
    {
        // code for your cash payment
    }
}

// In your controller
class PaymentController
{
    private $paymentMethod;

    // Utilize interface here so that you can interchange easily
    public function __construct(PayableMethod $paymentMethod)
    {
        $this->paymentMethod = $paymentMethod;
    }

    public function charge(int $amount, array $options = [])
    {
        return $this->paymentMethod->charge($amount, $options);
    }
}
``
proboy's avatar

@tisuchi Thanks for your answer. That is helpful but that's not what I really need help with, as I said Cashier/Stripe is already implemented, so it is responsible for managing Clients, payments, subscriptions, subscriptions automatic payments, invoices... so by adding a new payment method, I have to rethink about all those stuff, that's why am asking about the best approach for that

Please or to participate in this conversation.