mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 16:24:30 -04:00
Notify user if auto bill fails
This commit is contained in:
parent
a9832cc8c3
commit
fe3710fe4b
@ -58,12 +58,7 @@ class UserMailer extends Mailer
|
|||||||
$view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}";
|
$view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}";
|
||||||
$account = $user->account;
|
$account = $user->account;
|
||||||
$client = $invoice->client;
|
$client = $invoice->client;
|
||||||
|
$link = $invoice->present()->multiAccountLink;
|
||||||
if ($account->hasMultipleAccounts()) {
|
|
||||||
$link = url(sprintf('/account/%s?redirect_to=%s', $account->account_key, $invoice->present()->path));
|
|
||||||
} else {
|
|
||||||
$link = $invoice->present()->url;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'entityType' => $entityType,
|
'entityType' => $entityType,
|
||||||
@ -116,6 +111,26 @@ class UserMailer extends Mailer
|
|||||||
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
|
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Invitation $invitation
|
||||||
|
*/
|
||||||
|
public function sendMessage($user, $subject, $message, $invoice)
|
||||||
|
{
|
||||||
|
if (! $user->email) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$view = 'user_message';
|
||||||
|
$data = [
|
||||||
|
'userName' => $user->getDisplayName(),
|
||||||
|
'primaryMessage' => $subject,
|
||||||
|
'secondaryMessage' => $message,
|
||||||
|
'invoiceLink' => $invoice->present()->multiAccountLink,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
|
||||||
|
}
|
||||||
|
|
||||||
public function sendSecurityCode($user, $code)
|
public function sendSecurityCode($user, $code)
|
||||||
{
|
{
|
||||||
if (! $user->email) {
|
if (! $user->email) {
|
||||||
|
@ -279,4 +279,18 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
|
|
||||||
return ' - ' . $fee . ' ' . $label;
|
return ' - ' . $fee . ' ' . $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function multiAccountLink()
|
||||||
|
{
|
||||||
|
$invoice = $this->entity;
|
||||||
|
$account = $invoice->account;
|
||||||
|
|
||||||
|
if ($account->hasMultipleAccounts()) {
|
||||||
|
$link = url(sprintf('/account/%s?redirect_to=%s', $account->account_key, $invoice->present()->path));
|
||||||
|
} else {
|
||||||
|
$link = $invoice->present()->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,13 @@ class PaymentService extends BaseService
|
|||||||
try {
|
try {
|
||||||
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
|
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
|
if (! Auth::check()) {
|
||||||
|
$subject = trans('texts.auto_bill_failed', ['invoice_number' => $invoice->invoice_number]);
|
||||||
|
$message = sprintf('%s: %s', ucwords($paymentDriver->providerName()), $exception->getMessage());
|
||||||
|
$mailer = app('App\Ninja\Mailers\UserMailer');
|
||||||
|
$mailer->sendMessage($invoice->user, $subject, $message, $invoice);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2433,6 +2433,7 @@ $LANG = array(
|
|||||||
'reset_counter' => 'Reset Counter',
|
'reset_counter' => 'Reset Counter',
|
||||||
'next_reset' => 'Next Reset',
|
'next_reset' => 'Next Reset',
|
||||||
'reset_counter_help' => 'Automatically reset the invoice and quote counters.',
|
'reset_counter_help' => 'Automatically reset the invoice and quote counters.',
|
||||||
|
'auto_bill_failed' => 'Auto-billing for invoice :invoice_number failed',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user