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

Feature/guest checkout #9

Merged
merged 13 commits into from
Jun 14, 2024
Merged

Feature/guest checkout #9

merged 13 commits into from
Jun 14, 2024

Conversation

i-just
Copy link
Contributor

@i-just i-just commented Jun 5, 2024

Description

This PR addresses a few bugs and slightly changes the behaviour of the src\services\Checkout->getCheckoutUrl() method to allow truly anonymous checkout.

  • Fixed a bug where it wasn’t possible to use the checkout controller unless you were logged in to Craft
  • Fixed a bug where we were attempting to set customer_email to null, causing a Stripe API error
  • Fixed a few bugs in the README doc
  • The src\services\Checkout->getCheckoutUrl() now accepts false as the $user parameter too. If null is passed (or the parameter is not explicitly used, in which case it’ll default to null), the method will continue to attempt to get the currently logged-in user. If false is passed, no such attempt will be made, the checkout URL will be anonymous, and the customer will have to fill out their email address on Stripe’s checkout page. (README adjusted accordingly.)
  • The src\elements\Price->getCheckoutUrl() now accepts parameters ($customer, $successUrl, $cancelUrl, $params), all defaulting to null, and no longer assumes that the current user should always be used when generating the checkout URL.

Related issues

n/a

README.md Outdated Show resolved Hide resolved
@i-just i-just requested a review from brandonkelly June 5, 2024 12:13
@i-just i-just mentioned this pull request Jun 13, 2024
@i-just
Copy link
Contributor Author

i-just commented Jun 14, 2024

As per our discussions, I went back to accepting false and leaving the null behaviour as it was when generating checkout URLs.

This means that if you don’t pass anything as a $customer parameter, the default null value will be used, and the method will continue to attempt to get the currently logged-in user. However, if you pass false, the checkout URL will be anonymous (even if a user is currently logged in).

I also unified how the checkout is generated in all 3 cases: via controller action (stripe/checkout), twig function (stripeCheckoutUrl()) and price element method (price.getCheckoutUrl()).

@i-just i-just requested a review from nfourtythree June 14, 2024 09:19
@i-just i-just merged commit 6ea85a7 into 1.x Jun 14, 2024
5 checks passed
@i-just i-just deleted the feature/guest-checkout branch June 14, 2024 12:52
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