← All changes
|
app/Services/FormBuilder/Notifications/EmailNotificationActions.php
+15
-5
6.2.5
→
6.2.14
View file →
| @@ -84,16 +84,26 @@ | ||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function notify($feed, $formData, $entry, $form) |
| 87 | 87 | { |
| 88 | - // If this is a payment form and the feed is configured to run on payment_success, | |
| 89 | - // then do not send while the submission's payment status is still pending. | |
| 88 | + // Defer a payment_success email only for a KNOWN unsettled status. An empty | |
| 89 | + // status is a genuine $0 order (an all-optional form or a 100% coupon, no payment | |
| 90 | + // attempted) and still confirms; any status NOT in the deny-list still sends, so a | |
| 91 | + // custom/settled status a gateway registers via fluentform/available_payment_statuses | |
| 92 | + // is never silently dropped. Custom unsettled statuses extend the deny-list via | |
| 93 | + // fluentform/unsettled_payment_statuses. A non-success gateway return never reaches | |
| 94 | + // here as empty -- it is gated in the processor and left as its pending status. | |
| 90 | 95 | if (isset($form->has_payment) && $form->has_payment) { |
| 91 | 96 | if (FormFieldsParser::hasElement($form, 'payment_method')) { |
| 92 | 97 | $isTriggerOnPaymentSuccess = ArrayHelper::get($feed, 'processedValues.feed_trigger_event') === 'payment_success'; |
| 93 | - $isPaymentPending = isset($entry->payment_status) && $entry->payment_status === 'pending'; | |
| 94 | - if ($isTriggerOnPaymentSuccess && $isPaymentPending) { | |
| 95 | - return; | |
| 98 | + if ($isTriggerOnPaymentSuccess) { | |
| 99 | + $paymentStatus = is_null($entry->payment_status ?? null) ? '' : (string) $entry->payment_status; | |
| 100 | + $unsettledStatuses = apply_filters('fluentform/unsettled_payment_statuses', [ | |
| 101 | + 'pending', 'failed', 'requires_review', 'cancelled', 'refunded', 'partially-refunded', | |
| 102 | + ]); | |
| 103 | + if (in_array($paymentStatus, $unsettledStatuses, true)) { | |
| 104 | + return; | |
| 105 | + } | |
| 96 | 106 | } |
| 97 | 107 | } |
| 98 | 108 | } |
| 99 | 109 | |