mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:47:32 -05:00 
			
		
		
		
	payment failure emails
This commit is contained in:
		
							parent
							
								
									2ab99e8132
								
							
						
					
					
						commit
						58970fab99
					
				@ -344,8 +344,6 @@ class BaseDriver extends AbstractPaymentDriver
 | 
				
			|||||||
        else 
 | 
					        else 
 | 
				
			||||||
            $error = $e->getMessage();
 | 
					            $error = $e->getMessage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $amount = optional($this->payment_hash->data)->value ?? optional($this->payment_hash->data)->amount;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        AutoBillingFailureMailer::dispatch(
 | 
					        AutoBillingFailureMailer::dispatch(
 | 
				
			||||||
            $gateway->client,
 | 
					            $gateway->client,
 | 
				
			||||||
            $error,
 | 
					            $error,
 | 
				
			||||||
@ -364,6 +362,36 @@ class BaseDriver extends AbstractPaymentDriver
 | 
				
			|||||||
        throw new PaymentFailed($error, $e->getCode());
 | 
					        throw new PaymentFailed($error, $e->getCode());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function tokenBillingFailed($gateway, $e)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->unWindGatewayFees($this->payment_hash);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($e instanceof CheckoutHttpException) {
 | 
				
			||||||
 | 
					            $error = $e->getBody();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if ($e instanceof Exception) {
 | 
				
			||||||
 | 
					            $error = $e->getMessage();
 | 
				
			||||||
 | 
					        }   
 | 
				
			||||||
 | 
					        else 
 | 
				
			||||||
 | 
					            $error = $e->getMessage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        AutoBillingFailureMailer::dispatch(
 | 
				
			||||||
 | 
					            $gateway->client,
 | 
				
			||||||
 | 
					            $error,
 | 
				
			||||||
 | 
					            $gateway->client->company,
 | 
				
			||||||
 | 
					            $this->payment_hash
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        SystemLogger::dispatch(
 | 
				
			||||||
 | 
					            $gateway->payment_hash,
 | 
				
			||||||
 | 
					            SystemLog::CATEGORY_GATEWAY_RESPONSE,
 | 
				
			||||||
 | 
					            SystemLog::EVENT_GATEWAY_ERROR,
 | 
				
			||||||
 | 
					            $gateway::SYSTEM_LOG_TYPE,
 | 
				
			||||||
 | 
					            $gateway->client,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Wrapper method for checking if resource is good.
 | 
					     * Wrapper method for checking if resource is good.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -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,7 +89,7 @@ info("attempting token billing");
 | 
				
			|||||||
            'param' => $e->getError()->param,
 | 
					            'param' => $e->getError()->param,
 | 
				
			||||||
            'message' => $e->getError()->message,
 | 
					            'message' => $e->getError()->message,
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
            $this->stripe->processInternallyFailedPayment($this->stripe, $e);
 | 
					            $this->stripe->tokenBillingFailed($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) {
 | 
				
			||||||
@ -103,7 +103,7 @@ info("attempting token billing");
 | 
				
			|||||||
            '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);
 | 
					            $this->stripe->tokenBillingFailed($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) {
 | 
				
			||||||
@ -117,7 +117,7 @@ info("attempting token billing");
 | 
				
			|||||||
            'message' => 'Invalid parameters were supplied to Stripe\'s API',
 | 
					            'message' => 'Invalid parameters were supplied to Stripe\'s API',
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->stripe->processInternallyFailedPayment($this->stripe, $e);
 | 
					            $this->stripe->tokenBillingFailed($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) {
 | 
				
			||||||
@ -131,7 +131,7 @@ info("attempting token billing");
 | 
				
			|||||||
            'message' => 'Authentication with Stripe\'s API failed',
 | 
					            'message' => 'Authentication with Stripe\'s API failed',
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->stripe->processInternallyFailedPayment($this->stripe, $e);
 | 
					            $this->stripe->tokenBillingFailed($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) {
 | 
				
			||||||
@ -145,7 +145,7 @@ info("attempting token billing");
 | 
				
			|||||||
            'message' => 'Network communication with Stripe failed',
 | 
					            'message' => 'Network communication with Stripe failed',
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->stripe->processInternallyFailedPayment($this->stripe, $e);
 | 
					            $this->stripe->tokenBillingFailed($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) {
 | 
				
			||||||
@ -157,7 +157,7 @@ info("attempting token billing");
 | 
				
			|||||||
            'message' => 'API Error',
 | 
					            'message' => 'API Error',
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->stripe->processInternallyFailedPayment($this->stripe, $e);
 | 
					            $this->stripe->tokenBillingFailed($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) {
 | 
				
			||||||
@ -171,7 +171,7 @@ info("attempting token billing");
 | 
				
			|||||||
            'message' => $e->getMessage(),
 | 
					            'message' => $e->getMessage(),
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->stripe->processInternallyFailedPayment($this->stripe, $e);
 | 
					            $this->stripe->tokenBillingFailed($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);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -66,7 +66,6 @@ trait UserNotifies
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function findCompanyUserNotificationType($company_user, $required_permissions) :array
 | 
					    public function findCompanyUserNotificationType($company_user, $required_permissions) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        nlog("find company user notification type");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($company_user->company->is_disabled) {
 | 
					        if ($company_user->company->is_disabled) {
 | 
				
			||||||
            return [];
 | 
					            return [];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user