diff --git a/app/Events/Account/StripeConnectFailure.php b/app/Events/Account/StripeConnectFailure.php new file mode 100644 index 0000000000..fd6f5a5d57 --- /dev/null +++ b/app/Events/Account/StripeConnectFailure.php @@ -0,0 +1,36 @@ +db); + + if (Ninja::isHosted() && is_null(Cache::get("stripe_connect_notification:{$event->company->company_key}"))) + { + + $nmo = new NinjaMailerObject(); + $nmo->mailable = new StripeConnectFailed($event->company->owner(), $event->company); + $nmo->company = $event->company; + $nmo->settings = $event->company->settings; + $nmo->to_user = $event->company->owner(); + + NinjaMailerJob::dispatch($nmo, true); + + Cache::put("stripe_connect_notification:{$event->company->company_key}", true, 60 * 60 * 24); + + } + } +} diff --git a/app/Mail/Ninja/StripeConnectFailed.php b/app/Mail/Ninja/StripeConnectFailed.php new file mode 100644 index 0000000000..4c935cdf29 --- /dev/null +++ b/app/Mail/Ninja/StripeConnectFailed.php @@ -0,0 +1,114 @@ +user->email, + ); + } + + /** + * Get the message content definition. + * + * @return \Illuminate\Mail\Mailables\Content + */ + public function content() + { + + return new Content( + view: 'email.admin.stripe_connect_failed', + text: 'email.admin.stripe_connect_failed_text', + with: [ + 'text_body' => $this->textBody(), //@todo this is a bit hacky here. + 'body' => $this->htmlBody(), + 'title' => 'Connect your Stripe account', + 'settings' => $this->company->settings, + 'logo' => $this->company->present()->logo(), + 'signature' => '', + 'company' => $this->company, + 'greeting' => '', + 'links' => [], + 'url' => 'https://www.loom.com/share/a3dc3131cc924e14a34634d5d48065c8?sid=b1971aa2-9deb-4339-8ebd-53f9947ef633', + 'button' => "texts.view" + ] + ); + } + + private function textBody() + { + return " + We note you are yet to connect your Stripe account to Invoice Ninja. Please log in to Invoice Ninja and connect your Stripe account.\n\n + Once logged in you can use the following resource to connect your Stripe account: \n\n + "; + } + + private function htmlBody() + { + return " + We note you are yet to connect your Stripe account to Invoice Ninja. Please log in to Invoice Ninja and connect your Stripe account.

+ + Once logged in you can use the following resource to connect your Stripe account:

+ + "; + } + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments() + { + return []; + } + + /** + * Get the message headers. + * + * @return \Illuminate\Mail\Mailables\Headers + */ + public function headers() + { + return new Headers( + messageId: null, + references: [], + text:['' => ''], + ); + } +} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index d83f5602c8..028eeb4dff 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -94,6 +94,7 @@ use App\Events\Misc\InvitationWasViewed; use App\Events\Payment\PaymentWasVoided; use App\Events\Vendor\VendorWasArchived; use App\Events\Vendor\VendorWasRestored; +use App\Events\Account\StripeConnectFailure; use App\Listeners\Mail\MailSentListener; use App\Observers\ClientContactObserver; use App\Observers\PurchaseOrderObserver; @@ -198,6 +199,8 @@ use App\Listeners\Invoice\InvoiceRestoredActivity; use App\Listeners\Invoice\InvoiceReversedActivity; use App\Listeners\Payment\PaymentRestoredActivity; use App\Listeners\Quote\QuoteApprovedNotification; +use SocialiteProviders\Apple\AppleExtendSocialite; +use SocialiteProviders\Manager\SocialiteWasCalled; use App\Events\Subscription\SubscriptionWasCreated; use App\Events\Subscription\SubscriptionWasDeleted; use App\Events\Subscription\SubscriptionWasUpdated; @@ -221,10 +224,12 @@ use App\Listeners\Invoice\InvoiceEmailFailedActivity; use App\Events\PurchaseOrder\PurchaseOrderWasAccepted; use App\Events\PurchaseOrder\PurchaseOrderWasArchived; use App\Events\PurchaseOrder\PurchaseOrderWasRestored; +use App\Listeners\Payment\PaymentEmailFailureActivity; use App\Listeners\Vendor\UpdateVendorContactLastLogin; use App\Events\RecurringQuote\RecurringQuoteWasCreated; use App\Events\RecurringQuote\RecurringQuoteWasDeleted; use App\Events\RecurringQuote\RecurringQuoteWasUpdated; +use App\Listeners\Account\StripeConnectFailureListener; use App\Listeners\Activity\CreatedSubscriptionActivity; use App\Listeners\Activity\SubscriptionDeletedActivity; use App\Listeners\Activity\SubscriptionUpdatedActivity; @@ -234,6 +239,7 @@ use App\Events\RecurringQuote\RecurringQuoteWasRestored; use App\Listeners\Activity\SubscriptionArchivedActivity; use App\Listeners\Activity\SubscriptionRestoredActivity; use App\Listeners\Invoice\InvoiceFailedEmailNotification; +use SocialiteProviders\Microsoft\MicrosoftExtendSocialite; use App\Events\RecurringExpense\RecurringExpenseWasCreated; use App\Events\RecurringExpense\RecurringExpenseWasDeleted; use App\Events\RecurringExpense\RecurringExpenseWasUpdated; @@ -587,6 +593,9 @@ class EventServiceProvider extends ServiceProvider TaskWasRestored::class => [ TaskRestoredActivity::class, ], + StripeConnectFailure::class => [ + StripeConnectFailureListener::class, + ], SubscriptionWasCreated::class => [ CreatedSubscriptionActivity::class, ], diff --git a/resources/views/email/admin/stripe_connect_failed.blade.php b/resources/views/email/admin/stripe_connect_failed.blade.php new file mode 100644 index 0000000000..aba251b489 --- /dev/null +++ b/resources/views/email/admin/stripe_connect_failed.blade.php @@ -0,0 +1,59 @@ +@component('email.template.admin', ['design' => 'light', 'settings' => $settings, 'logo' => $logo]) +
+ @isset($greeting) +

{{ $greeting }}

+ @endisset + + @isset($title) +

{{ $title }}

+ @endisset + + @isset($h2) +

{{ $title }}

+ @endisset + +
+ @isset($body) + {!! $body !!} + @endisset + + @isset($slot) + {{ $slot }} + @endisset +
+ + @isset($additional_info) +

{{ $additional_info }}

+ @endisset + + @isset($url) + + + + + + + +
+ + {{ ctrans($button) }} + +
+ + + + @endisset + + @isset($signature) +

{!! nl2br($signature) !!}

+ @endisset +
+@endcomponent diff --git a/resources/views/email/admin/stripe_connect_failed_text.blade.php b/resources/views/email/admin/stripe_connect_failed_text.blade.php new file mode 100644 index 0000000000..319daf0679 --- /dev/null +++ b/resources/views/email/admin/stripe_connect_failed_text.blade.php @@ -0,0 +1,5 @@ +{!! $title !!} + +{!! $text_body !!} + +{!! $url !!} \ No newline at end of file