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

[13.x] Server side Checkout redirect #1218

Merged
merged 2 commits into from
Jul 9, 2021

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Jul 8, 2021

This PR implements some nice API's to Stripe's recent addition of exposing the Checkout url on its session object. This will greatly simplify the workflow for a library like Cashier to use redirects instead of doing it through Stripe.js

Before:

$checkoutBtn = Auth::user()->checkout('price_tshirt')->button();

return view('checkout', compact('checkoutBtn'));

And have the customer click a button. Now:

return Auth::user()->checkout('price_tshirt');

I've deprecated the button method because I think that from now on that's going to be a very rare use case.

@driesvints driesvints force-pushed the server-side-checkout-redirect branch from 9d10c83 to 805797e Compare July 8, 2021 19:55
*/
public function redirect()
{
return Redirect::to($this->session->url, 303);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose 303 on purpose here because Stripe recommends it in their docs (and @cjavilla-stripe did in one of his video tutorials): https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#redirect-customers

@taylorotwell taylorotwell merged commit 973ba2d into 13.x Jul 9, 2021
@taylorotwell taylorotwell deleted the server-side-checkout-redirect branch July 9, 2021 13:54
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

Successfully merging this pull request may close these issues.

2 participants