mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 07:57:33 -05:00 
			
		
		
		
	Fixes for failed mollie payments
This commit is contained in:
		
							parent
							
								
									ce3ea99f22
								
							
						
					
					
						commit
						3695042cc0
					
				@ -16,6 +16,7 @@ use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
 | 
				
			|||||||
use App\Http\Requests\Gateways\Mollie\Mollie3dsRequest;
 | 
					use App\Http\Requests\Gateways\Mollie\Mollie3dsRequest;
 | 
				
			||||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
 | 
					use App\Http\Requests\Payments\PaymentWebhookRequest;
 | 
				
			||||||
use App\Jobs\Util\SystemLogger;
 | 
					use App\Jobs\Util\SystemLogger;
 | 
				
			||||||
 | 
					use App\Models\Client;
 | 
				
			||||||
use App\Models\ClientGatewayToken;
 | 
					use App\Models\ClientGatewayToken;
 | 
				
			||||||
use App\Models\GatewayType;
 | 
					use App\Models\GatewayType;
 | 
				
			||||||
use App\Models\Invoice;
 | 
					use App\Models\Invoice;
 | 
				
			||||||
@ -303,12 +304,39 @@ class MolliePaymentDriver extends BaseDriver
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $payment = $this->gateway->payments->get($request->id);
 | 
					            $payment = $this->gateway->payments->get($request->id);
 | 
				
			||||||
 | 
					            $record = Payment::withTrashed()->where('transaction_reference', $request->id)->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $record = Payment::withTrashed()->where('transaction_reference', $request->id)->firstOrFail();
 | 
					            if($record){
 | 
				
			||||||
 | 
					                $client = $record->client;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else{
 | 
				
			||||||
 | 
					                $input = $request->all();
 | 
				
			||||||
 | 
					                $client = Client::withTrashed()->find($this->decodePrimaryKey($input['metadata']->client_id));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $message = [
 | 
				
			||||||
 | 
					                'server_response' => $payment,
 | 
				
			||||||
 | 
					                'data' => $request->all(),
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $response = SystemLog::EVENT_GATEWAY_FAILURE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if($record){
 | 
				
			||||||
                $record->status_id = $codes[$payment->status];
 | 
					                $record->status_id = $codes[$payment->status];
 | 
				
			||||||
                $record->save();
 | 
					                $record->save();
 | 
				
			||||||
 | 
					                $response = SystemLog::EVENT_GATEWAY_SUCCESS;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            SystemLogger::dispatch(
 | 
				
			||||||
 | 
					                $message,
 | 
				
			||||||
 | 
					                SystemLog::CATEGORY_GATEWAY_RESPONSE,
 | 
				
			||||||
 | 
					                $response,
 | 
				
			||||||
 | 
					                SystemLog::TYPE_MOLLIE,
 | 
				
			||||||
 | 
					                $client
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return response()->json([], 200);
 | 
					            return response()->json([], 200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (ApiException $e) {
 | 
					        } catch (ApiException $e) {
 | 
				
			||||||
            return response()->json(['message' => $e->getMessage(), 'gatewayStatusCode' => $e->getCode()], 500);
 | 
					            return response()->json(['message' => $e->getMessage(), 'gatewayStatusCode' => $e->getCode()], 500);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user