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

Mick79's avatar

Pass payment type into laravel cashier's checkoutCharge

I am trying to create a simple payment page for a client. They need to be able to direct THEIR customers to a link and have them pay an ad-hoc amount.

I can do this using the checkoutCharge function and this code all works fine

$user = User::query()->where('id', $request->id)->first();
        return $user->checkoutCharge($request->humanamount, 'Pay');

But in my Stripe dashboard I have "Klarna" enabled. This is not showing on my stripe checkout page and I am surmising it's because I would need to pass in the 'Klarna' payment type. Is there a way to do this with 'checkoutCharge'?

0 likes
1 reply
Braunson's avatar

The code in question is here https://github.com/laravel/cashier-stripe/blob/f0bdbbcb7a67b860895fddfd217dfa99d9fbbc41/src/Concerns/PerformsCharges.php#L106-L123

Seems there are 5 parameters that the method accepts

  • $amount
  • $name
  • $quantity = 1
  • array $sessionOptions = []
  • array $customerOptions = [].

Depending on what you want to do, you can pass payment_method_types in the $sessionOptions to specify which payment methods are available (See https://stripe.com/docs/api/checkout/sessions/create)

From the docs:

ID of an existing Customer, if one exists. In payment mode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page. In subscription mode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address, billing name and billing email are required on the payment method for Checkout to prefill the customer’s card details.

I would suggest hopping on the Stripe IRC if you had any more questions relating to their API.

Please or to participate in this conversation.