|
@@ -2,8 +2,7 @@
|
|
|
|
|
|
namespace App\Http\Services;
|
|
namespace App\Http\Services;
|
|
|
|
|
|
-use App\Models\Invoice;
|
|
|
|
-use App\Models\FinancialTransaction;
|
|
|
|
|
|
+use App\Models\Appointment;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
|
|
@@ -44,132 +43,34 @@ class EmailService
|
|
return json_decode($response, true);
|
|
return json_decode($response, true);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- //Emails
|
|
|
|
-
|
|
|
|
- public function notifyClientOnNewInvoice(Invoice $invoice)
|
|
|
|
- {
|
|
|
|
- $clientEmailAddress = $invoice->customer->client->email_address;
|
|
|
|
- if(!$clientEmailAddress) return;
|
|
|
|
-
|
|
|
|
- $appInternalName = $this->appInternalName;
|
|
|
|
- $stringMappingConfig = $this->stringMappingConfig;
|
|
|
|
- $appUrl = $this->appUrl;
|
|
|
|
- $emailFromName = $this->emailFromName;
|
|
|
|
- $toEmailAddress = $clientEmailAddress;
|
|
|
|
- $html = (string) view('emails.templates.invoice-created-email', compact('toEmailAddress', 'invoice', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
- $plainText = '';
|
|
|
|
-
|
|
|
|
- $params = [
|
|
|
|
- 'subject' => 'New Payment Request Added to Your Account',
|
|
|
|
- 'htmlBody' => $html,
|
|
|
|
- 'plainTextBody' => $plainText,
|
|
|
|
- 'toAddress' => $clientEmailAddress,
|
|
|
|
- 'fromEmail' => $this->fromEmailAddress,
|
|
|
|
- 'fromName' => $this->emailFromName,
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- $response = $this->callJava('/email/send', $params);
|
|
|
|
- return $response;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function notifyClientOnInvoiceDeactivation(Invoice $invoice)
|
|
|
|
- {
|
|
|
|
- $clientEmailAddress = $invoice->customer->client->email_address;
|
|
|
|
- if(!$clientEmailAddress) return;
|
|
|
|
-
|
|
|
|
- $appInternalName = $this->appInternalName;
|
|
|
|
- $stringMappingConfig = $this->stringMappingConfig;
|
|
|
|
- $appUrl = $this->appUrl;
|
|
|
|
- $emailFromName = $this->emailFromName;
|
|
|
|
- $toEmailAddress = $clientEmailAddress;
|
|
|
|
- $html = (string) view('emails.templates.invoice-deactivation-email', compact('toEmailAddress', 'invoice', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
- $plainText = '';
|
|
|
|
-
|
|
|
|
- $params = [
|
|
|
|
- 'subject' => 'Payment Request Cancellation Notice',
|
|
|
|
- 'htmlBody' => $html,
|
|
|
|
- 'plainTextBody' => $plainText,
|
|
|
|
- 'toAddress' => $clientEmailAddress,
|
|
|
|
- 'fromEmail' => $this->fromEmailAddress,
|
|
|
|
- 'fromName' => $this->emailFromName,
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- $response = $this->callJava('/email/send', $params);
|
|
|
|
- return $response;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function notifyClientOnInvoicePayment(Invoice $invoice)
|
|
|
|
- {
|
|
|
|
- $clientEmailAddress = $invoice->customer->client->email_address;
|
|
|
|
- if(!$clientEmailAddress) return;
|
|
|
|
-
|
|
|
|
- $appInternalName = $this->appInternalName;
|
|
|
|
- $stringMappingConfig = $this->stringMappingConfig;
|
|
|
|
- $appUrl = $this->appUrl;
|
|
|
|
- $emailFromName = $this->emailFromName;
|
|
|
|
- $toEmailAddress = $clientEmailAddress;
|
|
|
|
- $html = (string) view('emails.templates.invoice-payment-email', compact('toEmailAddress', 'invoice', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
- $plainText = '';
|
|
|
|
-
|
|
|
|
- $params = [
|
|
|
|
- 'subject' => 'Transaction Notification: Service Payment Confirmation',
|
|
|
|
- 'htmlBody' => $html,
|
|
|
|
- 'plainTextBody' => $plainText,
|
|
|
|
- 'toAddress' => $clientEmailAddress,
|
|
|
|
- 'fromEmail' => $this->fromEmailAddress,
|
|
|
|
- 'fromName' => $this->emailFromName,
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- $response = $this->callJava('/email/send', $params);
|
|
|
|
- return $response;
|
|
|
|
|
|
+ public function getValidToEmailAddress($email){
|
|
|
|
+ if(config('app.env') !== 'production'){
|
|
|
|
+ return config('app.devEmailAddress');
|
|
|
|
+ }
|
|
|
|
+ return $email;
|
|
}
|
|
}
|
|
|
|
|
|
- public function notifyClientOnFailedInvoicePayment(Invoice $invoice)
|
|
|
|
- {
|
|
|
|
- $clientEmailAddress = $invoice->customer->client->email_address;
|
|
|
|
- if(!$clientEmailAddress) return;
|
|
|
|
-
|
|
|
|
- $appInternalName = $this->appInternalName;
|
|
|
|
- $stringMappingConfig = $this->stringMappingConfig;
|
|
|
|
- $appUrl = $this->appUrl;
|
|
|
|
- $emailFromName = $this->emailFromName;
|
|
|
|
- $toEmailAddress = $clientEmailAddress;
|
|
|
|
- $html = (string) view('emails.templates.invoice-failed-payment-email', compact('toEmailAddress', 'invoice', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
- $plainText = '';
|
|
|
|
-
|
|
|
|
- $params = [
|
|
|
|
- 'subject' => 'Payment Declined: Action Required',
|
|
|
|
- 'htmlBody' => $html,
|
|
|
|
- 'plainTextBody' => $plainText,
|
|
|
|
- 'toAddress' => $clientEmailAddress,
|
|
|
|
- 'fromEmail' => $this->fromEmailAddress,
|
|
|
|
- 'fromName' => $this->emailFromName,
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- $response = $this->callJava('/email/send', $params);
|
|
|
|
- return $response;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ //Emails
|
|
|
|
|
|
- public function notifyClientOnRefundTransaction(FinancialTransaction $transaction)
|
|
|
|
|
|
+ public function notifyClientOnNewAppointment(Appointment $appointment)
|
|
{
|
|
{
|
|
- $clientEmailAddress = $transaction->customer->client->email_address;
|
|
|
|
- if(!$clientEmailAddress) return;
|
|
|
|
|
|
+ $toEmailAddress = $this->getValidToEmailAddress($appointment->client->email_address);
|
|
|
|
+ if(!$toEmailAddress) return;
|
|
|
|
|
|
$appInternalName = $this->appInternalName;
|
|
$appInternalName = $this->appInternalName;
|
|
$stringMappingConfig = $this->stringMappingConfig;
|
|
$stringMappingConfig = $this->stringMappingConfig;
|
|
$appUrl = $this->appUrl;
|
|
$appUrl = $this->appUrl;
|
|
$emailFromName = $this->emailFromName;
|
|
$emailFromName = $this->emailFromName;
|
|
- $toEmailAddress = $clientEmailAddress;
|
|
|
|
- $html = (string) view('emails.templates.transaction-refund-email', compact('toEmailAddress', 'transaction', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
|
|
+ $toEmailAddress = $toEmailAddress;
|
|
|
|
+ $html = (string) view('emails.templates.client-new-appointment', compact('toEmailAddress', 'appointment', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
$plainText = '';
|
|
$plainText = '';
|
|
|
|
|
|
$params = [
|
|
$params = [
|
|
- 'subject' => 'Refund Issued for Payment',
|
|
|
|
|
|
+ 'subject' => 'An appointment has been scheduled',
|
|
'htmlBody' => $html,
|
|
'htmlBody' => $html,
|
|
'plainTextBody' => $plainText,
|
|
'plainTextBody' => $plainText,
|
|
- 'toAddress' => $clientEmailAddress,
|
|
|
|
|
|
+ 'toAddress' => $toEmailAddress,
|
|
'fromEmail' => $this->fromEmailAddress,
|
|
'fromEmail' => $this->fromEmailAddress,
|
|
'fromName' => $this->emailFromName,
|
|
'fromName' => $this->emailFromName,
|
|
];
|
|
];
|
|
@@ -178,23 +79,21 @@ class EmailService
|
|
return $response;
|
|
return $response;
|
|
}
|
|
}
|
|
|
|
|
|
- public function notifyEmailOnClientChange($client, $message, $toEmailAddres, $toName)
|
|
|
|
|
|
+ public function notifyProOnNewAppointment(Appointment $appointment)
|
|
{
|
|
{
|
|
- if(config('app.env') !== 'production'){
|
|
|
|
- $toEmailAddress = config('app.devEmailAddress');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ $toEmailAddress = $this->getValidToEmailAddress($appointment->pro->email_address);
|
|
if(!$toEmailAddress) return;
|
|
if(!$toEmailAddress) return;
|
|
-
|
|
|
|
|
|
+
|
|
$appInternalName = $this->appInternalName;
|
|
$appInternalName = $this->appInternalName;
|
|
$stringMappingConfig = $this->stringMappingConfig;
|
|
$stringMappingConfig = $this->stringMappingConfig;
|
|
$appUrl = $this->appUrl;
|
|
$appUrl = $this->appUrl;
|
|
$emailFromName = $this->emailFromName;
|
|
$emailFromName = $this->emailFromName;
|
|
- $html = (string) view('emails.templates.notify-on-company-client-change-email', compact('toEmailAddress', 'message', 'toName', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
|
|
+ $toEmailAddress = $toEmailAddress;
|
|
|
|
+ $html = (string) view('emails.templates.pro-new-appointment', compact('toEmailAddress', 'appointment', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
$plainText = '';
|
|
$plainText = '';
|
|
|
|
|
|
$params = [
|
|
$params = [
|
|
- 'subject' => $client->displayName() . ' Information Update',
|
|
|
|
|
|
+ 'subject' => 'An appointment has been scheduled',
|
|
'htmlBody' => $html,
|
|
'htmlBody' => $html,
|
|
'plainTextBody' => $plainText,
|
|
'plainTextBody' => $plainText,
|
|
'toAddress' => $toEmailAddress,
|
|
'toAddress' => $toEmailAddress,
|
|
@@ -206,23 +105,21 @@ class EmailService
|
|
return $response;
|
|
return $response;
|
|
}
|
|
}
|
|
|
|
|
|
- public function notifyOnCompanyClientChange($companyClient, $message, $toEmailAddres, $toName)
|
|
|
|
|
|
+ public function notifyClientToConfirmAppointment(Appointment $appointment)
|
|
{
|
|
{
|
|
- if(config('app.env') !== 'production'){
|
|
|
|
- $toEmailAddress = config('app.devEmailAddress');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ $toEmailAddress = $this->getValidToEmailAddress($appointment->client->email_address);
|
|
if(!$toEmailAddress) return;
|
|
if(!$toEmailAddress) return;
|
|
-
|
|
|
|
|
|
+
|
|
$appInternalName = $this->appInternalName;
|
|
$appInternalName = $this->appInternalName;
|
|
$stringMappingConfig = $this->stringMappingConfig;
|
|
$stringMappingConfig = $this->stringMappingConfig;
|
|
$appUrl = $this->appUrl;
|
|
$appUrl = $this->appUrl;
|
|
$emailFromName = $this->emailFromName;
|
|
$emailFromName = $this->emailFromName;
|
|
- $html = (string) view('emails.templates.notify-on-company-client-change-email', compact('toEmailAddress', 'companyClient', 'message', 'toName', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
|
|
+ $toEmailAddress = $toEmailAddress;
|
|
|
|
+ $html = (string) view('emails.templates.client-confirm-appointment', compact('toEmailAddress', 'appointment', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
$plainText = '';
|
|
$plainText = '';
|
|
|
|
|
|
$params = [
|
|
$params = [
|
|
- 'subject' => $companyClient->client->displayName() . ' Information Update | ' . $companyClient->company->name,
|
|
|
|
|
|
+ 'subject' => 'Confirm Appointment',
|
|
'htmlBody' => $html,
|
|
'htmlBody' => $html,
|
|
'plainTextBody' => $plainText,
|
|
'plainTextBody' => $plainText,
|
|
'toAddress' => $toEmailAddress,
|
|
'toAddress' => $toEmailAddress,
|
|
@@ -234,34 +131,4 @@ class EmailService
|
|
return $response;
|
|
return $response;
|
|
}
|
|
}
|
|
|
|
|
|
- public function sendServerError($code)
|
|
|
|
- {
|
|
|
|
- $toEmailAddress = config('app.devEmailAddress');
|
|
|
|
- if(!$toEmailAddress) return;
|
|
|
|
-
|
|
|
|
- $emails = explode(',', $toEmailAddress);
|
|
|
|
-
|
|
|
|
- $appInternalName = $this->appInternalName;
|
|
|
|
- $stringMappingConfig = $this->stringMappingConfig;
|
|
|
|
- $appUrl = $this->appUrl;
|
|
|
|
- $emailFromName = $this->emailFromName;
|
|
|
|
- $html = (string) view('emails.templates.error-email', compact('toEmailAddress', 'code', 'appUrl', 'emailFromName', 'appInternalName', 'stringMappingConfig'));
|
|
|
|
- $plainText = '';
|
|
|
|
-
|
|
|
|
- foreach($emails as $email){
|
|
|
|
- $email = preg_replace('/\s+/', '', $email);
|
|
|
|
- $params = [
|
|
|
|
- 'subject' => 'Server Error - ' . $code,
|
|
|
|
- 'htmlBody' => $html,
|
|
|
|
- 'plainTextBody' => $plainText,
|
|
|
|
- 'toAddress' => $email,
|
|
|
|
- 'fromEmail' => $this->fromEmailAddress,
|
|
|
|
- 'fromName' => $this->emailFromName,
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- $response = $this->callJava('/email/send', $params);
|
|
|
|
- }
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|