mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-26 00:42:53 -04:00 
			
		
		
		
	Refactor PaymentWebhookController
This commit is contained in:
		
							parent
							
								
									3ca8b88f3f
								
							
						
					
					
						commit
						6740e348a1
					
				| @ -13,26 +13,14 @@ | |||||||
| namespace App\Http\Controllers; | namespace App\Http\Controllers; | ||||||
| 
 | 
 | ||||||
| use App\Http\Requests\Payments\PaymentWebhookRequest; | use App\Http\Requests\Payments\PaymentWebhookRequest; | ||||||
| use App\Libraries\MultiDB; |  | ||||||
| use Auth; |  | ||||||
| 
 | 
 | ||||||
| class PaymentWebhookController extends Controller | class PaymentWebhookController extends Controller | ||||||
| { | { | ||||||
|     public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id) |     public function __invoke(PaymentWebhookRequest $request) | ||||||
|     { |     { | ||||||
| 
 |         return $request | ||||||
|         $payment = $request->getPayment(); |             ->getCompanyGateway() | ||||||
|          |             ->driver() | ||||||
|         if(!$payment) |             ->processWebhookRequest($request); | ||||||
|         	return response()->json(['message' => 'Payment record not found.'], 400); |  | ||||||
| 
 |  | ||||||
|         $client = is_null($payment) ? $request->getClient() : $payment->client; |  | ||||||
| 
 |  | ||||||
|         if(!$client) |  | ||||||
| 	        return response()->json(['message' => 'Client record not found.'], 400); |  | ||||||
| 
 |  | ||||||
|         return $request->getCompanyGateway() |  | ||||||
|             ->driver($client) |  | ||||||
|             ->processWebhookRequest($request, $payment); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -118,7 +118,7 @@ class CompanyGateway extends BaseModel | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* This is the public entry point into the payment superclass */ |     /* This is the public entry point into the payment superclass */ | ||||||
|     public function driver(Client $client) |     public function driver(Client $client = null) | ||||||
|     { |     { | ||||||
|         $class = static::driver_class(); |         $class = static::driver_class(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user