This project is not covered by Drupal’s security advisory policy.
The modified version of the 'Stripe Registration' module for resolving the issues with roles update.
The main differences:
1. If a user cancel a subscription then roles related with it removed immediately.
2. If administrator remove a subscription then roles related with it removed immediately.
3. Canceled subscriptions do not removed and users can see them.
4. Users can't reactivate canceled subscription but they need to resubscribe.
5. Was added the views relationship betwen stripe_subscription and stripe_plan entities. It enables to display in a view info about subscriptions such as subscription's plan name, plan roles etc.
6. The hardcoded 'My subscriptions' table was replaced with the view.
7. Was added the view with the subscription plans and 'Checkout' links that redirect a user to 'Subscribe' page and prepopulate the form with corresponding plan name.
Dependencies
Configuration
1. Add _access: 'TRUE' to the 'stripe_api.webhook' route.
Edit the 'stripe_api.routing.yml' file of the 'Stripe API' module and alter the 'requirements' section of the 'stripe_api.webhook' route like this:
stripe_api.webhook:
path: '/stripe/webhook'
methods: [POST]
defaults:
_controller: '\Drupal\stripe_api\Controller\StripeApiWebhook::handleIncomingWebhook'
requirements:
_access: 'TRUE'
_content_type_format: json
2. On the Stripe dashboard add the 'customer.subscription.deleted' webhook.
3. Rebuild the cache.
We do not need to check the webhook signatures because the 'Stripe API' module verifies the event by fetching it from Stripe. See the 'isValidWebhook()' method of the 'StripeApiWebhook' controller.
The export of the Rule for notification of a subscriber via email when a new subscription was created.
langcode: en
status: true
dependencies: { }
id: if_new_stripe_subscription_was_created_then_notify_subscriber
label: 'If a new Stripe subscription was created, then notify a subscriber via email'
events:
-
event_name: 'rules_entity_insert:stripe_subscription'
description: ''
tags: { }
config_version: '3'
expression:
id: rules_rule
uuid: 49c22ebd-6dfb-4998-9552-5330388fa2f6
weight: 0
conditions:
id: rules_and
uuid: db0e4840-8659-47e8-b3b7-85d32bc6f2ee
weight: 0
conditions: { }
actions:
id: rules_action_set
uuid: 178897cd-df5d-4c6e-9c86-31500ed51392
weight: 0
actions:
-
id: rules_action
uuid: 43478176-9883-49cb-88c6-c4d7fd375e52
weight: 0
context_values:
to:
- '{{ stripe_subscription.user_id.entity.mail.value }}'
subject: 'New subscription notification'
message: 'You have subscribed successfully.'
reply: ''
language: ''
context_mapping: { }
context_processors:
to:
rules_tokens: { }
subject:
rules_tokens: { }
message:
rules_tokens: { }
reply:
rules_tokens: { }
language:
rules_tokens: { }
provides_mapping: { }
action_id: rules_send_email
The export of the Rule for notification of a subscriber via email when a subscription was canceled.
langcode: en
status: true
dependencies: { }
id: if_stripe_subscription_was_canceled_then_notify_subscriber
label: 'If a Stripe subscription was canceled, then notify a subscriber via email'
events:
-
event_name: 'rules_entity_update:stripe_subscription'
description: ''
tags: { }
config_version: '3'
expression:
id: rules_rule
uuid: 7b5fc318-e40c-47f6-bd4f-fdece2bd7550
weight: 0
conditions:
id: rules_and
uuid: 08fcffa2-0b59-4f37-90a6-077dbcd6b5d3
weight: 0
conditions: { }
actions:
id: rules_action_set
uuid: efde6986-7d77-41ff-b7a5-e94b0940984a
weight: 0
actions:
-
id: rules_action
uuid: 7fb6b9e6-aad2-4e3c-a57c-26997b0b445e
weight: 0
context_values:
to:
- '{{ stripe_subscription.user_id.entity.mail.value }}'
subject: 'Unsubscribe notification'
message: 'The subscription has been canceled.'
reply: ''
language: ''
context_mapping: { }
context_processors:
to:
rules_tokens: { }
subject:
rules_tokens: { }
message:
rules_tokens: { }
reply:
rules_tokens: { }
language:
rules_tokens: { }
provides_mapping: { }
action_id: rules_send_email
The export of the Rule for the case when administrator deleted a subscription.
If a subscription was canceled before then the notification email will not send (because it was sent after canceling).
langcode: en
status: true
dependencies: { }
id: if_stripe_subscription_was_delated_then_notify_subscriber
label: 'If a Stripe subscription was delated, then notify a subscriber via email'
events:
-
event_name: 'rules_entity_delete:stripe_subscription'
description: ''
tags: { }
config_version: '3'
expression:
id: rules_rule
uuid: 14a4f82f-99f9-40b3-abc8-90404d28579e
weight: 0
conditions:
id: rules_and
uuid: 60dbb3e7-274b-47b0-a513-fc6ddc1d7673
weight: 0
conditions:
-
id: rules_condition
uuid: 30580742-71c3-46e1-934e-bdddfad81195
weight: 0
context_values:
operation: '=='
value: canceled
context_mapping:
data: stripe_subscription.status.value
context_processors:
operation:
rules_tokens: { }
value:
rules_tokens: { }
provides_mapping: { }
condition_id: rules_data_comparison
negate: true
actions:
id: rules_action_set
uuid: 87d0b318-b8d5-4d99-9c6b-e089cc1de9e4
weight: 0
actions:
-
id: rules_action
uuid: 75a62115-b678-460e-85aa-3e93a6c7a980
weight: 0
context_values:
to:
- '{{ stripe_subscription.user_id.entity.mail.value }}'
subject: 'Unsubscribe notification'
message: 'The subscription has been canceled.'
reply: ''
language: ''
context_mapping: { }
context_processors:
to:
rules_tokens: { }
subject:
rules_tokens: { }
message:
rules_tokens: { }
reply:
rules_tokens: { }
language:
rules_tokens: { }
provides_mapping: { }
action_id: rules_send_email
Project information
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Module categories: E-commerce
- Created by wombatbuddy on , updated
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.