mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on payment failure emails
This commit is contained in:
parent
7e7564c085
commit
c14d34350f
@ -69,6 +69,8 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
nlog("payment failure mailer ");
|
||||||
|
|
||||||
/*If we are migrating data we don't want to fire these notification*/
|
/*If we are migrating data we don't want to fire these notification*/
|
||||||
if ($this->company->is_disabled) {
|
if ($this->company->is_disabled) {
|
||||||
return true;
|
return true;
|
||||||
@ -81,11 +83,12 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->setMailDriver();
|
$this->setMailDriver();
|
||||||
|
|
||||||
//iterate through company_users
|
//iterate through company_users
|
||||||
$this->company->company_users->each(function ($company_user) {
|
$this->company->company_users->each(function ($company_user) {
|
||||||
|
|
||||||
//determine if this user has the right permissions
|
//determine if this user has the right permissions
|
||||||
$methods = $this->findCompanyUserNotificationType($company_user, ['payment_failure']);
|
$methods = $this->findCompanyUserNotificationType($company_user, ['payment_failure']);
|
||||||
|
|
||||||
|
|
||||||
//if mail is a method type -fire mail!!
|
//if mail is a method type -fire mail!!
|
||||||
if (($key = array_search('mail', $methods)) !== false) {
|
if (($key = array_search('mail', $methods)) !== false) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
@ -333,13 +333,15 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
|
|
||||||
public function processInternallyFailedPayment($gateway, $e)
|
public function processInternallyFailedPayment($gateway, $e)
|
||||||
{
|
{
|
||||||
if ($e instanceof Exception) {
|
|
||||||
$error = $e->getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($e instanceof CheckoutHttpException) {
|
if ($e instanceof CheckoutHttpException) {
|
||||||
$error = $e->getBody();
|
$error = $e->getBody();
|
||||||
}
|
}
|
||||||
|
else if ($e instanceof Exception) {
|
||||||
|
$error = $e->getMessage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$error = $e->getMessage();
|
||||||
|
|
||||||
$amount = optional($this->payment_hash->data)->value ?? optional($this->payment_hash->data)->amount;
|
$amount = optional($this->payment_hash->data)->value ?? optional($this->payment_hash->data)->amount;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class Charge
|
|||||||
'confirm' => true,
|
'confirm' => true,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
]);
|
]);
|
||||||
|
info("attempting token billing");
|
||||||
SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (CardException $e) {
|
} catch (CardException $e) {
|
||||||
// Since it's a decline, \Stripe\Exception\CardException will be caught
|
// Since it's a decline, \Stripe\Exception\CardException will be caught
|
||||||
@ -89,6 +89,7 @@ class Charge
|
|||||||
'param' => $e->getError()->param,
|
'param' => $e->getError()->param,
|
||||||
'message' => $e->getError()->message,
|
'message' => $e->getError()->message,
|
||||||
];
|
];
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (RateLimitException $e) {
|
} catch (RateLimitException $e) {
|
||||||
@ -101,7 +102,9 @@ class Charge
|
|||||||
'param' => '',
|
'param' => '',
|
||||||
'message' => 'Too many requests made to the API too quickly',
|
'message' => 'Too many requests made to the API too quickly',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (InvalidRequestException $e) {
|
} catch (InvalidRequestException $e) {
|
||||||
// Invalid parameters were supplied to Stripe's API
|
// Invalid parameters were supplied to Stripe's API
|
||||||
@ -114,6 +117,8 @@ class Charge
|
|||||||
'message' => 'Invalid parameters were supplied to Stripe\'s API',
|
'message' => 'Invalid parameters were supplied to Stripe\'s API',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (AuthenticationException $e) {
|
} catch (AuthenticationException $e) {
|
||||||
// Authentication with Stripe's API failed
|
// Authentication with Stripe's API failed
|
||||||
@ -126,6 +131,8 @@ class Charge
|
|||||||
'message' => 'Authentication with Stripe\'s API failed',
|
'message' => 'Authentication with Stripe\'s API failed',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (ApiConnectionException $e) {
|
} catch (ApiConnectionException $e) {
|
||||||
// Network communication with Stripe failed
|
// Network communication with Stripe failed
|
||||||
@ -138,6 +145,8 @@ class Charge
|
|||||||
'message' => 'Network communication with Stripe failed',
|
'message' => 'Network communication with Stripe failed',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (ApiErrorException $e) {
|
} catch (ApiErrorException $e) {
|
||||||
$data = [
|
$data = [
|
||||||
@ -148,6 +157,8 @@ class Charge
|
|||||||
'message' => 'API Error',
|
'message' => 'API Error',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Something else happened, completely unrelated to Stripe
|
// Something else happened, completely unrelated to Stripe
|
||||||
@ -160,6 +171,8 @@ class Charge
|
|||||||
'message' => $e->getMessage(),
|
'message' => $e->getMessage(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
|
||||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ trait UserNotifies
|
|||||||
$notifiable_methods = [];
|
$notifiable_methods = [];
|
||||||
$notifications = $company_user->notifications;
|
$notifications = $company_user->notifications;
|
||||||
|
|
||||||
|
//if a user owns this record or is assigned to it, they are attached the permission for notification.
|
||||||
if ($invitation->{$entity_name}->user_id == $company_user->_user_id || $invitation->{$entity_name}->assigned_user_id == $company_user->user_id) {
|
if ($invitation->{$entity_name}->user_id == $company_user->_user_id || $invitation->{$entity_name}->assigned_user_id == $company_user->user_id) {
|
||||||
array_push($required_permissions, 'all_user_notifications');
|
array_push($required_permissions, 'all_user_notifications');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user