mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-01 20:17:35 -04:00 
			
		
		
		
	Fixes for Stripe Connect
This commit is contained in:
		
							parent
							
								
									99dd97443a
								
							
						
					
					
						commit
						b58d3f390e
					
				| @ -21,13 +21,18 @@ class PaymentWebhookController extends Controller | ||||
|     public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id) | ||||
|     { | ||||
| 
 | ||||
|     	MultiDB::findAndSetDbByCompanyKey($company_key); | ||||
|     	// MultiDB::findAndSetDbByCompanyKey($company_key);
 | ||||
| 
 | ||||
|         $payment = $request->getPayment(); | ||||
|          | ||||
|         if(!$payment) | ||||
|         	return response()->json(['message' => 'Payment record not found.'], 400); | ||||
| 
 | ||||
|         $client = is_null($payment) ? $request->getClient() : $payment->client; | ||||
| 
 | ||||
|         // $contact= $client->primary_contact()->first();
 | ||||
|         // Auth::guard('contact')->login($contact, true);
 | ||||
|         if(!$client) | ||||
| 	        return response()->json(['message' => 'Client record not found.'], 400); | ||||
| 
 | ||||
| 
 | ||||
|         return $request->getCompanyGateway() | ||||
|             ->driver($client) | ||||
|  | ||||
| @ -27,7 +27,7 @@ class PaymentWebhookRequest extends Request | ||||
| 
 | ||||
|     public function authorize() | ||||
|     { | ||||
|         MultiDB::findAndSetDbByCompanyKey($this->getCompany()->company_key); | ||||
|         MultiDB::findAndSetDbByCompanyKey($this->company_key); | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| @ -45,7 +45,7 @@ class PaymentWebhookRequest extends Request | ||||
|      * @param mixed $id | ||||
|      * @return null|\App\Models\CompanyGateway | ||||
|      */ | ||||
|     public function getCompanyGateway(): ?CompanyGateway | ||||
|     public function getCompanyGateway() | ||||
|     { | ||||
|         return CompanyGateway::findOrFail($this->decodePrimaryKey($this->company_gateway_id)); | ||||
|     } | ||||
| @ -56,13 +56,13 @@ class PaymentWebhookRequest extends Request | ||||
|      * @param string $hash | ||||
|      * @return null|\App\Models\PaymentHash | ||||
|      */ | ||||
|     public function getPaymentHash(): ?PaymentHash | ||||
|     public function getPaymentHash() | ||||
|     { | ||||
|         if ($this->query('hash')) { | ||||
|             return PaymentHash::where('hash', $this->query('hash'))->firstOrFail(); | ||||
|         } | ||||
| 
 | ||||
|         return null; | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -94,7 +94,7 @@ class PaymentWebhookRequest extends Request | ||||
| 
 | ||||
|         // If none of previously done logics is correct, we'll just display
 | ||||
|         // not found page.
 | ||||
|         abort(404); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -102,11 +102,14 @@ class PaymentWebhookRequest extends Request | ||||
|      * | ||||
|      * @return null|\App\Models\Client | ||||
|      */ | ||||
|     public function getClient(): ?Client | ||||
|     public function getClient() | ||||
|     { | ||||
|         $hash = $this->getPaymentHash(); | ||||
| 
 | ||||
|         return Client::find($hash->data->client_id)->firstOrFail(); | ||||
|         if($hash) | ||||
|             return Client::find($hash->data->client_id)->firstOrFail(); | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user