diff --git a/app/Jobs/Mail/PaymentFailureMailer.php b/app/Jobs/Mail/PaymentFailureMailer.php index 5d82c83cd7dc..27543a98c1d4 100644 --- a/app/Jobs/Mail/PaymentFailureMailer.php +++ b/app/Jobs/Mail/PaymentFailureMailer.php @@ -69,6 +69,8 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue */ public function handle() { + nlog("payment failure mailer "); + /*If we are migrating data we don't want to fire these notification*/ if ($this->company->is_disabled) { return true; @@ -81,11 +83,12 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue $this->setMailDriver(); //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 $methods = $this->findCompanyUserNotificationType($company_user, ['payment_failure']); + //if mail is a method type -fire mail!! if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 1b83db02500a..f2c48d6760af 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -333,13 +333,15 @@ class BaseDriver extends AbstractPaymentDriver public function processInternallyFailedPayment($gateway, $e) { - if ($e instanceof Exception) { - $error = $e->getMessage(); - } if ($e instanceof CheckoutHttpException) { $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; diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index f68c1a693c98..373773d3eef9 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -77,7 +77,7 @@ class Charge 'confirm' => true, 'description' => $description, ]); - +info("attempting token billing"); SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client); } catch (CardException $e) { // Since it's a decline, \Stripe\Exception\CardException will be caught @@ -89,6 +89,7 @@ class Charge 'param' => $e->getError()->param, '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); } catch (RateLimitException $e) { @@ -101,7 +102,9 @@ class Charge 'param' => '', '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); } catch (InvalidRequestException $e) { // Invalid parameters were supplied to Stripe's API @@ -114,6 +117,8 @@ class Charge '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); } catch (AuthenticationException $e) { // Authentication with Stripe's API failed @@ -126,6 +131,8 @@ class Charge '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); } catch (ApiConnectionException $e) { // Network communication with Stripe failed @@ -138,6 +145,8 @@ class Charge '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); } catch (ApiErrorException $e) { $data = [ @@ -148,6 +157,8 @@ class Charge '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); } catch (Exception $e) { // Something else happened, completely unrelated to Stripe @@ -160,6 +171,8 @@ class Charge '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); } diff --git a/app/Utils/Traits/Notifications/UserNotifies.php b/app/Utils/Traits/Notifications/UserNotifies.php index d5a85cde92f4..96a955fc691d 100644 --- a/app/Utils/Traits/Notifications/UserNotifies.php +++ b/app/Utils/Traits/Notifications/UserNotifies.php @@ -25,6 +25,7 @@ trait UserNotifies $notifiable_methods = []; $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) { array_push($required_permissions, 'all_user_notifications'); }