mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:07:33 -05:00 
			
		
		
		
	WePay ACH auto detect if payment method is authorized
This commit is contained in:
		
							parent
							
								
									f0ec25a606
								
							
						
					
					
						commit
						17434b4caa
					
				@ -214,13 +214,29 @@ class ACH
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function paymentResponse($request)
 | 
					    public function paymentResponse($request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // nlog($request->all());
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        $token = ClientGatewayToken::find($this->decodePrimaryKey($request->input('source')));
 | 
					        $token = ClientGatewayToken::find($this->decodePrimaryKey($request->input('source')));
 | 
				
			||||||
        $token_meta = $token->meta;
 | 
					        $token_meta = $token->meta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!property_exists($token_meta, 'state') || $token_meta->state != "authorized")
 | 
					        if(!property_exists($token_meta, 'state') || $token_meta->state != "authorized"){
 | 
				
			||||||
            return redirect()->route('client.payment_methods.verification', ['payment_method' => $token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]);
 | 
					
 | 
				
			||||||
 | 
					                $response = $this->wepay_payment_driver->wepay->request('/payment_bank', [
 | 
				
			||||||
 | 
					                                'client_id'          => config('ninja.wepay.client_id'),
 | 
				
			||||||
 | 
					                                'client_secret'      => config('ninja.wepay.client_secret'),
 | 
				
			||||||
 | 
					                                'payment_bank_id'    => $token->token,
 | 
				
			||||||
 | 
					                            ]);
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                if($response->state == 'authorized')
 | 
				
			||||||
 | 
					                {     
 | 
				
			||||||
 | 
					                    $meta = $token->meta;
 | 
				
			||||||
 | 
					                    $meta->state = $response->state;
 | 
				
			||||||
 | 
					                    $token->meta = $meta;
 | 
				
			||||||
 | 
					                    $token->save();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    return redirect()->route('client.payment_methods.verification', ['payment_method' => $token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $app_fee = (config('ninja.wepay.fee_ach_multiplier') * $this->wepay_payment_driver->payment_hash->data->amount_with_fee) + config('ninja.wepay.fee_fixed');
 | 
					        $app_fee = (config('ninja.wepay.fee_ach_multiplier') * $this->wepay_payment_driver->payment_hash->data->amount_with_fee) + config('ninja.wepay.fee_fixed');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user