enupal / stripe

Allows customers sign up for recurring and one-time payments with Stripe, perfect for orders, donations, subscriptions, and events. Create simple payment forms in seconds easily without coding. For Craft CMS
https://enupal.com/craft-plugins/stripe-payments/
Other
33 stars 19 forks source link

Change Subscription Grant Action To User ID Instead Of Email #206

Open theskyfloor opened 3 years ago

theskyfloor commented 3 years ago

Description

I had a user subscribe but in the process they changed their email address via checkout, this made it so that the grant did not process, would it be possible to change line 229 of src/services/Subscriptions.php from:

$user = Craft::$app->getUsers()->getUserByUsernameOrEmail($order->email);

to

$user = Craft::$app->users->getUserById($order->userId);

So that in the off chance this happens the membership grant processes... plus if a user changes their email in Craft it then gets out sync with Stripe, this edit should prevent that right?

Steps to reproduce

  1. Create subscription grant
  2. Use subscription with checkout
  3. Checkout and change email
  4. Stripe and Craft disconnect
andrelopez commented 3 years ago

Hi @theskyfloor I see the issue here, this workflow was thinking also on guest users that's why we use the email. If you go to Stripe Payments -> Settings -> Defaults and enable Email address of the logged-in user it will populate the email of the user on the checkout however the user can still update their email on the checkout page. I'll add some logic to get the user from their Id if the user was logged in.

cloudgrayau commented 2 years ago

@andrelopez Can you please push this update ASAP? It is important because if you change the email address on the Stripe checkout page doesn't match the users email address, then the order subscription fails.