mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:27:29 -05:00 
			
		
		
		
	Throw an renderable exception instead of returning view
This commit is contained in:
		
							parent
							
								
									f73ad4bef7
								
							
						
					
					
						commit
						6e6e73825c
					
				
							
								
								
									
										21
									
								
								app/Exceptions/PaymentFailed.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/Exceptions/PaymentFailed.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\Exceptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PaymentFailed extends Exception
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public function report()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // ..
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function render($request)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return render('gateways.unsuccessful', [
 | 
				
			||||||
 | 
					            'message' => $this->getMessage(),
 | 
				
			||||||
 | 
					            'code' => $this->getCode(),
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -12,6 +12,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\PaymentDrivers\CheckoutCom;
 | 
					namespace App\PaymentDrivers\CheckoutCom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Exceptions\PaymentFailed;
 | 
				
			||||||
use App\Jobs\Mail\PaymentFailureMailer;
 | 
					use App\Jobs\Mail\PaymentFailureMailer;
 | 
				
			||||||
use App\Jobs\Util\SystemLogger;
 | 
					use App\Jobs\Util\SystemLogger;
 | 
				
			||||||
use App\Models\PaymentType;
 | 
					use App\Models\PaymentType;
 | 
				
			||||||
@ -92,10 +93,7 @@ trait Utilities
 | 
				
			|||||||
            $this->checkout->client
 | 
					            $this->checkout->client
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return render('gateways.unsuccessful', [
 | 
					        throw new PaymentFailed($_payment->status, $_payment->http_code);
 | 
				
			||||||
            'code' => $_payment->http_code,
 | 
					 | 
				
			||||||
            'message' => $_payment->status,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function processPendingPayment(\Checkout\Models\Payments\Payment $_payment)
 | 
					    private function processPendingPayment(\Checkout\Models\Payments\Payment $_payment)
 | 
				
			||||||
@ -148,9 +146,6 @@ trait Utilities
 | 
				
			|||||||
            $this->checkout->client,
 | 
					            $this->checkout->client,
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return render('gateways.unsuccessful', [
 | 
					        throw new PaymentFailed($error, $e->getCode());
 | 
				
			||||||
            'error' => $e->getCode(),
 | 
					 | 
				
			||||||
            'message' => $error,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user