Skip to content

Commit e878199

Browse files
committed
feat: add billing_reason example
1 parent 8fd4fd9 commit e878199

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Billing/Commands/themes/subscriptions/stripe/app/controllers/Billing/WebhooksController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ public function handle()
2727
* $event->activateSubscription() - to activate the new subscription in webhook (if available)
2828
*/
2929

30+
if ($event->is('invoice.payment_succeeded')) {
31+
// Payment was successful
32+
33+
if ($event->data()['object']['billing_reason'] === 'subscription_cycle') {
34+
// Subscription renewed/charged after trial/cycle
35+
// ✅ Give access to your service
36+
}
37+
38+
// Other payment succeeded events
39+
// ✅ Give access to your service
40+
41+
return;
42+
}
43+
3044
if ($event->is('customer.subscription.updated')) {
3145
if ($event->activateSubscription()) {
3246
response()->json([
@@ -74,10 +88,11 @@ public function handle()
7488
if ($event->is('customer.subscription.resumed')) {
7589
// Subscription was resumed
7690
// ✅ Give access to your service
77-
// $event->user() will give you the user who made the payment (if available)
7891
return;
7992
}
8093

8194
// ... handle all other necessary events
8295
}
8396
}
97+
// You can also use the event data to perform other actions, such as sending emails, updating your database, etc.
98+
// You can also use the event data to perform other actions, such as sending emails, updating your database, etc.

0 commit comments

Comments
 (0)