laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.39k stars 679 forks source link

Allow SetupIntent creation without a Billable #797

Closed netpok closed 5 years ago

netpok commented 5 years ago

Currently there is no way to create a SetupIntent without a Billable object, this means we need to use something like (new User())->createSetupIntent() to pass an intent to the registration page.

My proposal:

These changes should not be breaking changes so it could be merged to this version. If needed I can make a pull request.

driesvints commented 5 years ago

Heya, thanks for proposing but I don't feel that this is necessary. Like you said you can just do (new User())->createSetupIntent() just like you can do (new User())->charge() if you want.

We also explicitly removed the passing of the customer id to the setup intent from the first implementation because people were experiencing issues with that. I can't seem to find the exact issue about that anymore right now.

HadiNiazi commented 2 years ago

@driesvints Cashier is requiring that return an intent from the view like this

'intent' => auth()->user()->createSetupIntent()

But I am charging my user for the registration. So how can I get rid of this intent? I just want to collect a one-time payment.

Xoshbin commented 2 years ago

Hi 👋 , Did anyone able to solve this, I want my users to be able to checkout out as guest users without registration. When I do it like (new User())->charge it's giving: The provided PaymentMethod cannot be attached. To reuse a PaymentMethod, you must attach it to a Customer first.

HadiNiazi commented 2 years ago

Hello, For this you can use stripe api 2 which is used to single charge the customer without any registration.

On Sun., 15 May 2022, 13:35 Khoshbin Ali Ahmed, @.***> wrote:

Hi 👋 , Did anyone able to solve this, I want my users to be able to checkout out as guest users without registration. When I do it like (new User())->charge it's giving: The provided PaymentMethod cannot be attached. To reuse a PaymentMethod, you must attach it to a Customer first.

— Reply to this email directly, view it on GitHub https://github.com/laravel/cashier-stripe/issues/797#issuecomment-1126886934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMXMWHTB27EMPQIPGSB5OXLVKCZMHANCNFSM4I7YI5EQ . You are receiving this because you commented.Message ID: @.***>

salahWD commented 6 months ago

I know this is mostly too late but I think I have a simple answer which I use (but I was searching for a better way) ... it goes like this: if (!auth()->check()) { $user = new User(); }

return view("???")->with([ "intent" => auth()->check() ? auth()->user()->createSetupIntent() : $user->createSetupIntent(), ]);

and for your case (using it to charge on registrations) you can just make a new user object and use its intent without saving the user ... after payment, you make a new user and save it. i am sorry if I did not understand your case fully

HadiNiazi commented 5 months ago

Yes, it's depends upon your logic, and how you write it, it's good to not create the variable and achieve the task without it.

On Tue, May 14, 2024 at 12:37 PM salah bakhash @.***> wrote:

I know this is mostly too late but I think I have a simple answer which I use (but I was searching for a better way) ... it goes like this: if (!auth()->check()) { $user = new User(); }

return view("???")->with([ "intent" => auth()->check() ? auth()->user()->createSetupIntent() : $user->createSetupIntent(), ]);

and for your case (using it to charge on registrations) you can just make a new user object and use its intent without saving the user ... after payment, you make a new user and save it. i am sorry if I did not understand your case fully

— Reply to this email directly, view it on GitHub https://github.com/laravel/cashier-stripe/issues/797#issuecomment-2111005903, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMXMWHSEKRXSTLIOFOPB42DZCJRX3AVCNFSM4I7YI5E2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJRGEYDANJZGAZQ . You are receiving this because you commented.Message ID: @.***>