feat(integrations): resolve payment context from events
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
|
||||
namespace App\Shared\Notification\Services;
|
||||
|
||||
use App\Domains\Commerce\Purchase\Models\Purchase;
|
||||
use App\Domains\Core\Auth\Models\ResetPasswordAttempt;
|
||||
use App\Domains\Core\Auth\Models\User;
|
||||
use App\Shared\Integration\Services\MailService;
|
||||
use App\Shared\Notification\Events\PasswordResetRequested;
|
||||
use App\Domains\Commerce\Purchase\Models\Purchase;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticketing\Ticket\Models\Ticket;
|
||||
use App\Domains\Ticketing\Ticket\Services\TicketPdfService;
|
||||
use App\Domains\Ticketing\Ticket\Services\TicketPresentationResolver;
|
||||
use App\Domains\Ticketing\Ticket\Services\TicketValidityResolver;
|
||||
use App\Shared\Integration\Services\MailService;
|
||||
use App\Shared\Notification\Events\PasswordResetRequested;
|
||||
use Closure;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -158,7 +158,7 @@ class NotificationMailService
|
||||
$context = ['purchase_id' => $purchaseId];
|
||||
|
||||
$purchase = Purchase::query()
|
||||
->with(['tenant', 'user', 'items'])
|
||||
->with(['event', 'tenant', 'user', 'items'])
|
||||
->find($purchaseId);
|
||||
|
||||
if ($purchase === null) {
|
||||
@@ -197,8 +197,7 @@ class NotificationMailService
|
||||
'mime' => 'application/pdf',
|
||||
]];
|
||||
|
||||
$this->mailService
|
||||
->forTenant($purchase->tenant_codigo)
|
||||
$this->mailForPurchase($purchase)
|
||||
->send(
|
||||
$recipient,
|
||||
"Compra confirmada - Compra #{$purchase->getKey()}",
|
||||
@@ -286,7 +285,6 @@ class NotificationMailService
|
||||
$context,
|
||||
$recipient,
|
||||
function () use (
|
||||
$tenantCode,
|
||||
$purchase,
|
||||
$recipient,
|
||||
$previousDate,
|
||||
@@ -295,8 +293,7 @@ class NotificationMailService
|
||||
): array {
|
||||
$brand = $purchase->tenant;
|
||||
|
||||
$this->mailService
|
||||
->forTenant($tenantCode)
|
||||
$this->mailForPurchase($purchase)
|
||||
->send(
|
||||
$recipient,
|
||||
"Tu evento fue reprogramado - N° de Orden #{$purchase->getKey()}",
|
||||
@@ -387,7 +384,6 @@ class NotificationMailService
|
||||
$context,
|
||||
$recipient,
|
||||
function () use (
|
||||
$tenantCode,
|
||||
$purchase,
|
||||
$recipient,
|
||||
$date,
|
||||
@@ -396,8 +392,7 @@ class NotificationMailService
|
||||
): array {
|
||||
$brand = $purchase->tenant;
|
||||
|
||||
$this->mailService
|
||||
->forTenant($tenantCode)
|
||||
$this->mailForPurchase($purchase)
|
||||
->send(
|
||||
$recipient,
|
||||
"Una fecha de tu evento fue suspendida - N° de Orden #{$purchase->getKey()}",
|
||||
@@ -421,10 +416,17 @@ class NotificationMailService
|
||||
{
|
||||
return Purchase::query()
|
||||
->where('tenant_codigo', $tenantCode)
|
||||
->with(['tenant', 'user'])
|
||||
->with(['event', 'tenant', 'user'])
|
||||
->find($purchaseId);
|
||||
}
|
||||
|
||||
private function mailForPurchase(Purchase $purchase): MailService
|
||||
{
|
||||
return $purchase->event
|
||||
? $this->mailService->forEvent($purchase->event)
|
||||
: $this->mailService->forTenant($purchase->tenant_codigo);
|
||||
}
|
||||
|
||||
private function recipientFor(Purchase $purchase): string
|
||||
{
|
||||
return (string) ($purchase->email ?: $purchase->user?->email);
|
||||
|
||||
Reference in New Issue
Block a user