Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to unset the payment_method_types parameter #1379

Closed
jacob418 opened this issue Jun 17, 2022 · 8 comments
Closed

Ability to unset the payment_method_types parameter #1379

jacob418 opened this issue Jun 17, 2022 · 8 comments

Comments

@jacob418
Copy link

Stripe offers the ability to manage supported payment methods from the dashboard. However within \Laravel\Cashier\Checkout::create this parameter is hardcoded. There should be an option, to make Cashier obmit this parameter completely so the full potential of stripe can be used. For example: \Laravel\Cashier\Cashier::configurePaymentMethodsViaDashboard(true).

@driesvints
Copy link
Member

Yes, we should make this configurable somehow. Maybe adding an array_filter around the options so you can pass in 'payment_method_types' => [] might be a good intermediate fix.

@ffeytons
Copy link

For a project of mine, I have the exact same need coming.
@driesvints You have set the "help wanted" flag, I'm willing to contribute for this feature -- is there some place in which you synchronize / assign tasks for this project?

@driesvints
Copy link
Member

Would appreciate a PR to 13.x for the array filter thing 👍

@ffeytons
Copy link

Alright, will work on it somewhere this week!

@ffeytons
Copy link

Hi,

I've just done a few tests, passing 'payment_method_types' => [] is already working, so there is no intermediate fix needed over here.

This is because Checkout::create in Cashier's code does this:

$session = $owner->stripe()->checkout->sessions->create(array_merge([
            'customer' => $customer->id,
            'mode' => 'payment',
            'success_url' => $sessionOptions['success_url'] ?? route('home').'?checkout=success',
            'cancel_url' => $sessionOptions['cancel_url'] ?? route('home').'?checkout=cancelled',
            'payment_method_types' => ['card'],
        ], $sessionOptions));

The parameters we pass to Cashier from the app are stored in $sessionOptions.
As per array_merge documentation, if both arrays have the same key, the value of the later overwrites the former.

@jacob418 could you confirm passing 'payment_method_types' => [] to the checkout([...]) method works for you?

@driesvints
Copy link
Member

@ffeytons hah, you're right, that should indeed already work.

@jacob418 jacob418 changed the title Abilitz to unset the payment_method_types parameter Ability to unset the payment_method_types parameter Jul 4, 2022
@jacob418
Copy link
Author

jacob418 commented Jul 4, 2022

The parameters we pass to Cashier from the app are stored in $sessionOptions. As per array_merge documentation, if both arrays have the same key, the value of the later overwrites the former.

@jacob418 could you confirm passing 'payment_method_types' => [] to the checkout([...]) method works for you?

I can confirm that the proposed empty array parameter ('payment_method_types' => [],) will be accepted by Stripe API and seems to enable the dashboard-managed payment methods. I should have tried it in the first place but only came up with null wich was rejected by stripe API. 🤦‍♂️ Ty for your help.

@driesvints
Copy link
Member

I've sent in a PR for this for the next major version. Unfortunately there isn't a good way to integrate this in v13. In v14, this will be the new default: #1400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants