Skip to content

Add support to specify custom stripe API version (or add version suffix) #1775

@dvigueras

Description

@dvigueras

Cashier Stripe Version

16.0.0

Laravel Version

12.31.1

PHP Version

8.4

Database Driver & Version

No response

Description

Hi,

I'm using Stripe Managed Payments (which is currently in Private Preview).

In order to use this Stripe feature, there are two steps that must be done:

  1. Pass the 'managed_payments' => ['enabled' => true], option in the array when creating a new Checkout session. This can currently be done by passing this option as the first argument of the checkout( Cashier method.

  2. Add ; managed_payments_preview=v1 as a suffix to the stripe_version option:

$stripe = new \Stripe\StripeClient([
  'api_key' => 'sk_test_51S2nRFLfdT6DuBGAS9gO29AaQ7kFK1xMF583jjSMqZz10bxGrw47S2DCnzZWyMXVZ7gb6IPLUNWyNoJHCb3zV9FW00QQJEHIri',
  'stripe_version' => '2025-08-27.basil; managed_payments_preview=v1',
]);

Right now, Cashier uses a fixed Stripe version (which is the one that in bundled in the Stripe PHP package):

    public static function stripe(array $options = [])
    {
        $config = array_merge([
            'api_key' => $options['api_key'] ?? config('cashier.secret'),
            'stripe_version' => static::STRIPE_VERSION,
            'api_base' => static::$apiBaseUrl,
        ], $options);

        return app(StripeClient::class, ['config' => $config]);
    }

When invoking the stripe() method from my code, I could override the $options array and set my custom stripe_version (which will be the same but with the suffix added).

However, when using the `checkout()' method, I can't override this option.

I could submit a PR with one of these two options, but before coding I want to hear your feedback and if you would be open to accept the PR:

  • Option 1: Be able to override the stripe_version option. A new setting in Cashier's configuration file would be added to allow this: stripe_version
  • Option 2: Be able to add a string suffix to the stripe_version option. Those suffixes would be added to the stripe_version option used in Cashier. A new setting in Cashier's configuration file would be added to allow this: e.g. stripe_version_suffix

Let me know what you think about this and I'll be happy to submit a PR if you think it's a good idea.

Steps To Reproduce

Enroll in the managed payments private preview and try to use Laravel Cashier

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions