diff --git a/config/language-translations.php b/config/language-translations.php index c66ad9e4..924f8d57 100644 --- a/config/language-translations.php +++ b/config/language-translations.php @@ -267,6 +267,19 @@ return [ 'synchronizing_plans' => 'Synchronizing Plans...', 'plans_are_synchronizing' => 'Your plans are synchronizing with the payment gateways', 'plans_was_synchronized' => 'Plans was successfully synchronized', + 'limit_usage_in_new_accounts_1_subject' => 'Please make first payment for your account to fund your usage', + 'limit_usage_in_new_accounts_1_line' => 'We are happy you are using our service. To continue to using our service, please make first payment for your account balance to fund your usage.', + 'limit_usage_in_new_accounts_2_subject' => '📆 Reminder: Please make first payment for your account to fund your usage', + 'limit_usage_in_new_accounts_2_line' => 'We are happy you are using our service. To continue to using our service, please make first payment for your account balance to fund your usage.', + 'limit_usage_in_new_accounts_3_subject' => '‼️ Uh-oh! Your functionality was restricted. Please make payment to continue using your account', + 'limit_usage_in_new_accounts_3_line' => 'We are sorry for the inconvenience with using our service. To continue to using our service, please make first payment for your account balance to fund your usage and your functionality will be allowed as soon as possible.', + 'usage_bigger_than_balance_1_subject' => "⚠️ You don't have sufficient funds in your account, please increase your account balance", + 'usage_bigger_than_balance_1_line' => 'We are happy you are using our service. To continue to using our service, please increase your funds for your account balance to cover your usage.', + 'usage_bigger_than_balance_2_subject' => "📆 Reminder: You don't have sufficient funds in your account, please increase your account balance", + 'usage_bigger_than_balance_2_line' => 'We are happy you are using our service. To continue to using our service, please increase your funds for your account balance to cover your usage.', + 'usage_bigger_than_balance_3_subject' => '‼️ Uh-oh! Your functionality was restricted. Please increase your funds for your account balance to cover your usage', + 'usage_bigger_than_balance_3_line' => 'We are sorry for the inconvenience with using our service. To continue to using our service, please increase your funds for your account balance to cover your usage and your functionality will be allowed as soon as possible.', + 'dunning_notification_description' => 'Please resolve your billing as soon as possible. Your functions can be restricted.', ], 'regular' => [ 'type' => 'Type', diff --git a/config/subscription.php b/config/subscription.php index ff77b0b3..4189ba96 100644 --- a/config/subscription.php +++ b/config/subscription.php @@ -23,6 +23,7 @@ return [ ], 'notifications' => [ + 'DunningEmailToCoverAccountUsageNotification' => \Domain\Subscriptions\Notifications\DunningEmailToCoverAccountUsageNotification::class, 'ChargeFromCreditCardFailedAgainNotification' => \Domain\Subscriptions\Notifications\ChargeFromCreditCardFailedAgainNotification::class, 'ChargeFromCreditCardFailedNotification' => \Domain\Subscriptions\Notifications\ChargeFromCreditCardFailedNotification::class, 'SubscriptionWasCreatedNotification' => \Domain\Subscriptions\Notifications\SubscriptionWasCreatedNotification::class, @@ -32,8 +33,18 @@ return [ 'BonusCreditAddedNotification' => \Domain\Subscriptions\Notifications\BonusCreditAddedNotification::class, ], - 'metered_billing' => [ + 'metered_billing' => [ 'settlement_period' => 30, + + 'fraud_prevention_mechanism' => [ + 'usage_bigger_than_balance' => [ + 'active' => true, + ], + 'limit_usage_in_new_accounts' => [ + 'active' => true, + 'amount' => 5, + ], + ], ], 'paystack' => [ @@ -48,4 +59,5 @@ return [ ], 'is_demo' => env('APP_DEMO', false), + 'is_local' => env('APP_ENV', 'production') === 'local', ]; diff --git a/resources/js/components/Notifications/Components/Notification.vue b/resources/js/components/Notifications/Components/Notification.vue index b895d03d..caea8110 100644 --- a/resources/js/components/Notifications/Components/Notification.vue +++ b/resources/js/components/Notifications/Components/Notification.vue @@ -19,7 +19,7 @@ class="vue-feather text-theme shrink-0" /> diff --git a/src/Domain/Subscriptions/Notifications/DunningEmailToCoverAccountUsageNotification.php b/src/Domain/Subscriptions/Notifications/DunningEmailToCoverAccountUsageNotification.php new file mode 100644 index 00000000..f80b8b27 --- /dev/null +++ b/src/Domain/Subscriptions/Notifications/DunningEmailToCoverAccountUsageNotification.php @@ -0,0 +1,86 @@ +dunningMessages(); + + return (new MailMessage) + ->subject($message[$this->dunning->type][$this->dunning->sequence]['subject']) + ->greeting(__('Hi there')) + ->line($message[$this->dunning->type][$this->dunning->sequence]['line']) + ->salutation(__('Regards')); + } + + public function toArray(): array + { + $message = $this->dunningMessages(); + + return [ + 'category' => 'payment-alert', + 'title' => $message[$this->dunning->type][$this->dunning->sequence]['subject'], + 'description' => __t('dunning_notification_description'), + 'action' => [ + 'type' => 'route', + 'params' => [ + 'route' => __t('billing'), + 'button' => __t('show_billing'), + ], + ], + ]; + } + + private function dunningMessages(): array + { + return [ + 'limit_usage_in_new_accounts' => [ + [ + 'subject' => __t('limit_usage_in_new_accounts_1_subject'), + 'line' => __t('limit_usage_in_new_accounts_1_line'), + ], + [ + 'subject' => __t('limit_usage_in_new_accounts_2_subject'), + 'line' => __t('limit_usage_in_new_accounts_2_line'), + ], + [ + 'subject' => __t('limit_usage_in_new_accounts_3_subject'), + 'line' => __t('limit_usage_in_new_accounts_3_line'), + ], + ], + 'usage_bigger_than_balance' => [ + [ + 'subject' => __t("usage_bigger_than_balance_1_subject"), + 'line' => __t('usage_bigger_than_balance_1_line'), + ], + [ + 'subject' => __t('usage_bigger_than_balance_2_subject'), + 'line' => __t('usage_bigger_than_balance_2_line'), + ], + [ + 'subject' => __t('usage_bigger_than_balance_3_subject'), + 'line' => __t('usage_bigger_than_balance_3_line'), + ], + ], + ]; + } +}