PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / trunk
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder vtrunk
6.2.15 6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 All 197 releases
← All changes | app/Modules/Payments/PaymentMethods/Stripe/StripeSettings.php +13 -1 6.2.11 → trunk View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace FluentForm\App\Modules\Payments\PaymentMethods\Stripe;
4 4
5 +use FluentForm\App\Models\Subscription;
5 6 use FluentForm\Framework\Helpers\ArrayHelper;
6 7 use FluentForm\App\Modules\Payments\PaymentHelper;
7 8
8 9 if (!defined('ABSPATH')) {
@@ -237,10 +238,13 @@
237 238 $eventType = $event->type;
238 239
239 240 $metaDataEvents = [
240 241 'checkout.session.completed',
242 + 'checkout.session.async_payment_succeeded',
243 + 'checkout.session.async_payment_failed',
241 244 'charge.refunded',
242 - 'charge.succeeded'
245 + 'charge.succeeded',
246 + 'charge.failed',
243 247 ];
244 248
245 249 if (in_array($eventType, $metaDataEvents)) {
246 250 $data = $event->data->object;
@@ -245,8 +249,16 @@
245 249 if (in_array($eventType, $metaDataEvents)) {
246 250 $data = $event->data->object;
247 251 $metaData = (array)$data->metadata;
248 252 return ArrayHelper::get($metaData, 'form_id');
253 + }
254 +
255 + // A delayed subscription's first invoice settles the entry, so it needs the form's own key too. Once the entry is
256 + // linked, renewals keep the global key: a form moved to its own account still bills older subscriptions on it.
257 + $invoice = $event->data->object;
258 + if ('invoice.payment_succeeded' === $eventType && isset($invoice->subscription, $invoice->subscription_details->metadata->form_id)
259 + && !Subscription::byVendorSubscriptionId($invoice->subscription)->first()) {
260 + return $invoice->subscription_details->metadata->form_id;
249 261 }
250 262
251 263 return false;
252 264 }