feat(integrations): resolve payment context from events
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
namespace App\Shared\Integration\Services;
|
||||
|
||||
use App\Domains\Core\Client\Models\Client;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Core\Tenant\Models\AdminWebsiteType;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticketing\Event\Models\Event;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Mail\Factory as MailFactory;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
@@ -39,14 +40,7 @@ class MailService extends BaseIntegrationService
|
||||
public function forTenant(string $tenantCode): self
|
||||
{
|
||||
parent::forTenant($tenantCode);
|
||||
|
||||
if ($this->integrationInstance) {
|
||||
$this->mailer = $this->resolveMailer();
|
||||
$this->usesInstanceMailer = true;
|
||||
} else {
|
||||
$this->mailer = $this->mailFactory->mailer();
|
||||
$this->usesInstanceMailer = false;
|
||||
}
|
||||
$this->configureMailer();
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -55,16 +49,30 @@ class MailService extends BaseIntegrationService
|
||||
{
|
||||
parent::forClient($client);
|
||||
$this->tenant = $this->clientContext?->tenants()->first();
|
||||
$this->configureMailer();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function forEvent(Event $event): self
|
||||
{
|
||||
parent::forEvent($event);
|
||||
$this->configureMailer();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function configureMailer(): void
|
||||
{
|
||||
if ($this->integrationInstance) {
|
||||
$this->mailer = $this->resolveMailer();
|
||||
$this->usesInstanceMailer = true;
|
||||
} else {
|
||||
$this->mailer = $this->mailFactory->mailer();
|
||||
$this->usesInstanceMailer = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $this;
|
||||
$this->mailer = $this->mailFactory->mailer();
|
||||
$this->usesInstanceMailer = false;
|
||||
}
|
||||
|
||||
public function getHeaders(): array
|
||||
@@ -83,7 +91,7 @@ class MailService extends BaseIntegrationService
|
||||
array $attachments = [],
|
||||
): void {
|
||||
if (! $this->mailer || ! $this->tenant) {
|
||||
throw new Exception('MailService no está configurado. Llamá a forTenant() o forClient() primero.');
|
||||
throw new Exception('MailService no está configurado. Llamá a forTenant(), forClient() o forEvent() primero.');
|
||||
}
|
||||
|
||||
$brand ??= $this->tenant;
|
||||
@@ -160,7 +168,7 @@ class MailService extends BaseIntegrationService
|
||||
public function onSetup(): void
|
||||
{
|
||||
if (! $this->mailer || ! $this->clientContext) {
|
||||
throw new Exception('MailService no está configurado. Llamá a forTenant() o forClient() primero.');
|
||||
throw new Exception('MailService no está configurado. Llamá a forTenant(), forClient() o forEvent() primero.');
|
||||
}
|
||||
|
||||
$recipient = $this->getIntegrationSetting('MAIL_FROM_ADDRESS');
|
||||
|
||||
Reference in New Issue
Block a user