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

Subscription grants do not update when subscription updated in customer portal #374

Closed
splendidrob opened this issue Nov 7, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@splendidrob
Copy link

splendidrob commented Nov 7, 2023

Description

Subscription grants don't respond to updates made in the Stripe Customer Portal. Similar here: (#240)

Steps to reproduce

  1. Create subscription grants linking a product in Stripe to a user group in Craft
  2. Subscription grants work when creating the subscription - the user is added to the correct user group as per the subscription selection, or when cancelling subscriptions - the user is removed from the group
  3. Update subscription via the Stripe Customer Portal to a new subscription plan
  4. The user remains in the original user group and is not updated - the user should be removed from the original user group and added to the new user group as per the subscription grant settings

Additional info

  • Craft version: Craft Pro 4.5.9
  • PHP version: 8.0.30
  • Database driver & version: MySQL 5.7.43
  • Plugin version: 5.5.0
  • Is SCA and Stripe Checkout enabled?: YES
@andrelopez
Copy link
Member

Hi @splendidrob are you testing locally? if so, could you please confirm that you're using the Stripe CLI and you're running the following command to redirect to your local webhook URL?
stripe listen --forward-to YOUR_WEBHOOK_URL

@splendidrob
Copy link
Author

@andrelopez Have tested both locally and on a staging server. Locally is using the Stripe CLI and is working for creating and cancelling subscriptions fine, just not for updating subscriptions. Staging server is using the Stripe webhook directly and again is working for creating and cancelling subscriptions but not for updating.

@andrelopez andrelopez self-assigned this Nov 7, 2023
@mark-chief
Copy link

Hey @splendidrob , just looking to use this plugin for a project I am on and saw your post, did you solve this or get a workaround? The Subscription Grants are crucial for us. Cheers!

@splendidrob
Copy link
Author

splendidrob commented Feb 19, 2024

@mark-chief I ended up ditching the plugin all together and building my own integration with Stripe as there were too many bugs causing issues for me across the board. It was fairly easy to create a module that listens for Stripe webhooks and then add's or removes a user from a group depending on various actions. sorry thats not a simpler solution!

Webhook eg:

                case 'customer.subscription.created':
                $subscription = $event->data->object;
                $customerId = $subscription->customer;

                $stripeCustomer = $stripe->customers->retrieve($customerId, []);
                $user = Craft::$app->users->getUserByUsernameOrEmail($stripeCustomer->email);
                Craft::$app->users->assignUserToGroups($user->id, [1]);

                $userRenewal = $subscription->current_period_end;
                $user->setFieldValue('userRenewal', $userRenewal);

                Craft::$app->elements->saveElement($user);

                break;

@andrelopez andrelopez added enhancement New feature or request and removed need more info labels Feb 19, 2024
@mark-chief
Copy link

@splendidrob Thanks!
@andrelopez What is the likelihood of this being possible soon? Thanks

@andrelopez
Copy link
Member

@mark-chief absolutely, I am on it.

Thanks for sharing @splendidrob !

andrelopez added a commit that referenced this issue Feb 26, 2024
andrelopez added a commit that referenced this issue Feb 26, 2024
@andrelopez
Copy link
Member

Hi this issue is fixed on v5.5.1, thank you all for reporting!

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

No branches or pull requests

3 participants