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

Return Stripe checkout URL from checkout method #1636

Closed
sts-ryan-holton opened this issue Jan 23, 2024 · 5 comments
Closed

Return Stripe checkout URL from checkout method #1636

sts-ryan-holton opened this issue Jan 23, 2024 · 5 comments

Comments

@sts-ryan-holton
Copy link

Cashier Stripe Version

15.2.0

Laravel Version

10.41.0

PHP Version

8.2.*

Database Driver & Version

MySQL

Description

I'd like to migrate my subscription checkout process over to the Stripe checkout for better maintainability. My Laravel project serves as an API for a Nuxt JS front-end, this means I need to return the URL of the Stripe checkout to redirect the user to in my axios response in my front-end.

The checkout method appears to do something with the redirect method as I see a 303 response code in my browser. I've tried attaching the toResponse method to just get the URL with no luck.

I just need some guidance in returning a URL from the checkout method please here:

Steps To Reproduce

$subscription->create($request->input('token'), [], $subscriptionOptions);

return $subscription->checkout([
    'success_url' => 'http://localhost:3005/account/subscriptions/',
    'cancel_url' => 'http://localhost:3005/account/subscriptions/',
])->toResponse($request);
@crynobone
Copy link
Member

Hi there,

Thanks for reporting the problem you are encountering, but it looks like this is a question which may be better suited for a support channel. We only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repository you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

@sts-ryan-holton
Copy link
Author

Duplicated over to: laravel/framework#49801

@sts-ryan-holton
Copy link
Author

Just wondering if anyone from the Cashier team is able to point me in the right direction here? I don't know the codebase or methods, you guys do 🤣

@stuartcusackie
Copy link

A toArray() function is available on the Checkout class. It contains a url to stripe checkout.

I haven't used it yet but I'll find out how useful it is soon.

@sts-ryan-holton
Copy link
Author

@stuartcusackie That's what I ended up using. My front-end is separated from the backend. Turns out the checkout method returns a url key that I can use Arr::get() to redirect to. Didn't even need the toResponse()

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

No branches or pull requests

3 participants