@@ -26,7 +26,7 @@ class WebhookController extends Controller
26
26
public function __construct ()
27
27
{
28
28
if (config ('dodo.webhook_secret ' )) {
29
- $ this ->middleware (DodoPaymentsWebhookSignature::class);
29
+ $ this ->middleware (DodoPaymentsWebhookSignature::class);
30
30
}
31
31
}
32
32
@@ -104,8 +104,31 @@ protected function handleSubscriptionActive(array $payload): void
104
104
}
105
105
$ subscription ->update ([
106
106
'status ' => $ data ['status ' ],
107
+ 'next_billing_at ' => Carbon::parse (Carbon::parse ($ data ['next_billing_date ' ], 'UTC ' ))
107
108
]);
108
109
$ billable = User::whereEmail ($ data ['customer ' ]['email ' ])->first ();
110
+
111
+ SubscriptionActive::dispatch ($ billable , $ subscription , $ payload );
112
+ }
113
+
114
+ /**
115
+ * Handle Subscription Renewed.
116
+ *
117
+ * @param array $payload
118
+ * @return void
119
+ */
120
+ protected function handleSubscriptionRenewed (array $ payload ): void
121
+ {
122
+ $ data = $ payload ['data ' ];
123
+ if (!$ subscription = $ this ->findSubscription ($ data ['subscription_id ' ])) {
124
+ return ;
125
+ }
126
+ $ subscription ->update ([
127
+ 'status ' => $ data ['status ' ],
128
+ 'next_billing_at ' => Carbon::parse (Carbon::parse ($ data ['next_billing_date ' ], 'UTC ' ))
129
+ ]);
130
+ $ billable = User::whereEmail ($ data ['customer ' ]['email ' ])->first ();
131
+
109
132
SubscriptionActive::dispatch ($ billable , $ subscription , $ payload );
110
133
}
111
134
@@ -126,7 +149,7 @@ protected function handleSubscriptionFailed(array $payload): void
126
149
'status ' => $ data ['status ' ],
127
150
]);
128
151
$ billable = User::whereEmail ($ data ['customer ' ]['email ' ])->first ();
129
- SubscriptionFailed::dispatch ($ billable ,$ subscription , $ payload );
152
+ SubscriptionFailed::dispatch ($ billable , $ subscription , $ payload );
130
153
}
131
154
132
155
/**
@@ -145,7 +168,7 @@ protected function handleSubscriptionOnHold(array $payload): void
145
168
'status ' => $ data ['status ' ],
146
169
]);
147
170
$ billable = User::whereEmail ($ data ['customer ' ]['email ' ])->first ();
148
- SubscriptionOnHold::dispatch ($ billable ,$ subscription , $ payload );
171
+ SubscriptionOnHold::dispatch ($ billable , $ subscription , $ payload );
149
172
}
150
173
151
174
/**
@@ -165,7 +188,7 @@ protected function handleSubscriptionPaused(array $payload): void
165
188
'paused_at ' => Carbon::parse ($ data ['created_at ' ], 'UTC ' )
166
189
]);
167
190
$ billable = User::whereEmail ($ data ['customer ' ]['email ' ])->first ();
168
- SubscriptionOnHold::dispatch ($ billable ,$ subscription , $ payload );
191
+ SubscriptionOnHold::dispatch ($ billable , $ subscription , $ payload );
169
192
}
170
193
171
194
/**
0 commit comments