mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:47:32 -05:00 
			
		
		
		
	Merge pull request #4765 from turbo124/v5-develop
Fixes for auth.net auto billing
This commit is contained in:
		
						commit
						88bac69e13
					
				@ -1 +1 @@
 | 
				
			|||||||
5.0.53
 | 
					5.0.54
 | 
				
			||||||
@ -87,7 +87,7 @@ class AuthorizeCreditCard
 | 
				
			|||||||
        return $this->handleResponse($data, $request);
 | 
					        return $this->handleResponse($data, $request);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function tokenBilling($cgt, $payment_hash)
 | 
					    public function tokenBilling($cgt, $payment_hash)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
 | 
					        $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -95,10 +95,13 @@ class AuthorizeCreditCard
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        /*Refactor and push to BaseDriver*/
 | 
					        /*Refactor and push to BaseDriver*/
 | 
				
			||||||
        if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') {
 | 
					        if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $response = $data['response'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->storePayment($payment_hash, $data);
 | 
					            $this->storePayment($payment_hash, $data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $vars = [
 | 
					            $vars = [
 | 
				
			||||||
                'hashed_ids' => $invoice->hashed_id,
 | 
					                'invoices' => $payment_hash->invoices(),
 | 
				
			||||||
                'amount' => $amount,
 | 
					                'amount' => $amount,
 | 
				
			||||||
            ];
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -111,6 +114,19 @@ class AuthorizeCreditCard
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $vars = [
 | 
				
			||||||
 | 
					                'invoices' => $payment_hash->invoices(),
 | 
				
			||||||
 | 
					                'amount' => $amount,
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $logger_message = [
 | 
				
			||||||
 | 
					                'server_response' => $response->getTransactionResponse()->getTransId(),
 | 
				
			||||||
 | 
					                'data' => $this->formatGatewayResponse($data, $vars),
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -138,7 +154,7 @@ class AuthorizeCreditCard
 | 
				
			|||||||
        $payment_record = [];
 | 
					        $payment_record = [];
 | 
				
			||||||
        $payment_record['amount'] = $amount;
 | 
					        $payment_record['amount'] = $amount;
 | 
				
			||||||
        $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
 | 
					        $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
 | 
				
			||||||
        ;
 | 
					        
 | 
				
			||||||
        $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
 | 
					        $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $payment = $this->authorize->createPayment($payment_record);
 | 
					        $payment = $this->authorize->createPayment($payment_record);
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\PaymentDrivers\Authorize;
 | 
					namespace App\PaymentDrivers\Authorize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Jobs\Util\SystemLogger;
 | 
				
			||||||
use App\Models\Payment;
 | 
					use App\Models\Payment;
 | 
				
			||||||
 | 
					use App\Models\SystemLog;
 | 
				
			||||||
use App\PaymentDrivers\AuthorizePaymentDriver;
 | 
					use App\PaymentDrivers\AuthorizePaymentDriver;
 | 
				
			||||||
use net\authorize\api\contract\v1\CreateTransactionRequest;
 | 
					use net\authorize\api\contract\v1\CreateTransactionRequest;
 | 
				
			||||||
use net\authorize\api\contract\v1\CustomerProfilePaymentType;
 | 
					use net\authorize\api\contract\v1\CustomerProfilePaymentType;
 | 
				
			||||||
@ -73,61 +75,105 @@ class RefundTransaction
 | 
				
			|||||||
                $tresponse = $response->getTransactionResponse();
 | 
					                $tresponse = $response->getTransactionResponse();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ($tresponse != null && $tresponse->getMessages() != null) {
 | 
					                if ($tresponse != null && $tresponse->getMessages() != null) {
 | 
				
			||||||
                    return [
 | 
					                
 | 
				
			||||||
                    'transaction_reference' => $tresponse->getTransId(),
 | 
					                    $data = [
 | 
				
			||||||
                    'success' => true,
 | 
					                        'transaction_reference' => $tresponse->getTransId(),
 | 
				
			||||||
                    'description' => $tresponse->getMessages()[0]->getDescription(),
 | 
					                        'success' => true,
 | 
				
			||||||
                    'code' => $tresponse->getMessages()[0]->getCode(),
 | 
					                        'description' => $tresponse->getMessages()[0]->getDescription(),
 | 
				
			||||||
                    'transaction_response' => $tresponse->getResponseCode(),
 | 
					                        'code' => $tresponse->getMessages()[0]->getCode(),
 | 
				
			||||||
                ];
 | 
					                        'transaction_response' => $tresponse->getResponseCode(),
 | 
				
			||||||
 | 
					                        'payment_id' => $payment->id,
 | 
				
			||||||
 | 
					                        'amount' => $amount,
 | 
				
			||||||
 | 
					                    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return $data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ($tresponse->getErrors() != null) {
 | 
					                    if ($tresponse->getErrors() != null) {
 | 
				
			||||||
                        return [
 | 
					
 | 
				
			||||||
                    'transaction_reference' => '',
 | 
					                        $data = [
 | 
				
			||||||
                    'transaction_response' => '',
 | 
					                            'transaction_reference' => '',
 | 
				
			||||||
                    'success' => false,
 | 
					                            'transaction_response' => '',
 | 
				
			||||||
                    'description' => $tresponse->getErrors()[0]->getErrorText(),
 | 
					                            'success' => false,
 | 
				
			||||||
                    'code' => $tresponse->getErrors()[0]->getErrorCode(),
 | 
					                            'description' => $tresponse->getErrors()[0]->getErrorText(),
 | 
				
			||||||
                ];
 | 
					                            'code' => $tresponse->getErrors()[0]->getErrorCode(),
 | 
				
			||||||
 | 
					                            'payment_id' => $payment->id,
 | 
				
			||||||
 | 
					                            'amount' => $amount,
 | 
				
			||||||
 | 
					                        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        return $data;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                echo "Transaction Failed \n";
 | 
					                echo "Transaction Failed \n";
 | 
				
			||||||
                $tresponse = $response->getTransactionResponse();
 | 
					                $tresponse = $response->getTransactionResponse();
 | 
				
			||||||
                if ($tresponse != null && $tresponse->getErrors() != null) {
 | 
					                if ($tresponse != null && $tresponse->getErrors() != null) {
 | 
				
			||||||
                    return [
 | 
					
 | 
				
			||||||
                    'transaction_reference' => '',
 | 
					                    $data = [
 | 
				
			||||||
                    'transaction_response' => '',
 | 
					                        'transaction_reference' => '',
 | 
				
			||||||
                    'success' => false,
 | 
					                        'transaction_response' => '',
 | 
				
			||||||
                    'description' => $tresponse->getErrors()[0]->getErrorText(),
 | 
					                        'success' => false,
 | 
				
			||||||
                    'code' => $tresponse->getErrors()[0]->getErrorCode(),
 | 
					                        'description' => $tresponse->getErrors()[0]->getErrorText(),
 | 
				
			||||||
                ];
 | 
					                        'code' => $tresponse->getErrors()[0]->getErrorCode(),
 | 
				
			||||||
 | 
					                        'payment_id' => $payment->id,
 | 
				
			||||||
 | 
					                        'amount' => $amount,
 | 
				
			||||||
 | 
					                    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    return $data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    return [
 | 
					
 | 
				
			||||||
                    'transaction_reference' => '',
 | 
					                    $data = [
 | 
				
			||||||
                    'transaction_response' => '',
 | 
					                        'transaction_reference' => '',
 | 
				
			||||||
                    'success' => false,
 | 
					                        'transaction_response' => '',
 | 
				
			||||||
                    'description' => $response->getMessages()->getMessage()[0]->getText(),
 | 
					                        'success' => false,
 | 
				
			||||||
                    'code' => $response->getMessages()->getMessage()[0]->getCode(),
 | 
					                        'description' => $response->getMessages()->getMessage()[0]->getText(),
 | 
				
			||||||
                ];
 | 
					                        'code' => $response->getMessages()->getMessage()[0]->getCode(),
 | 
				
			||||||
 | 
					                        'payment_id' => $payment->id,
 | 
				
			||||||
 | 
					                        'amount' => $amount,
 | 
				
			||||||
 | 
					                    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    return $data;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return [
 | 
					
 | 
				
			||||||
 | 
					                $data = [
 | 
				
			||||||
                    'transaction_reference' => '',
 | 
					                    'transaction_reference' => '',
 | 
				
			||||||
                    'transaction_response' => '',
 | 
					                    'transaction_response' => '',
 | 
				
			||||||
                    'success' => false,
 | 
					                    'success' => false,
 | 
				
			||||||
                    'description' => 'No response returned',
 | 
					                    'description' => 'No response returned',
 | 
				
			||||||
                    'code' => 'No response returned',
 | 
					                    'code' => 'No response returned',
 | 
				
			||||||
 | 
					                    'payment_id' => $payment->id,
 | 
				
			||||||
 | 
					                    'amount' => $amount,
 | 
				
			||||||
                ];
 | 
					                ];
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return $data;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return [
 | 
					        $data = [
 | 
				
			||||||
                    'transaction_reference' => '',
 | 
					            'transaction_reference' => '',
 | 
				
			||||||
                    'transaction_response' => '',
 | 
					            'transaction_response' => '',
 | 
				
			||||||
                    'success' => false,
 | 
					            'success' => false,
 | 
				
			||||||
                    'description' => 'No response returned',
 | 
					            'description' => 'No response returned',
 | 
				
			||||||
                    'code' => 'No response returned',
 | 
					            'code' => 'No response returned',
 | 
				
			||||||
                ];
 | 
					            'payment_id' => $payment->id,
 | 
				
			||||||
 | 
					            'amount' => $amount,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -104,6 +104,8 @@ class AuthorizePaymentDriver extends BaseDriver
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
 | 
					    public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $this->setPaymentHash($payment_hash);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        $this->setPaymentMethod($cgt->gateway_type_id);
 | 
					        $this->setPaymentMethod($cgt->gateway_type_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->payment_method->tokenBilling($cgt, $payment_hash);
 | 
					        return $this->payment_method->tokenBilling($cgt, $payment_hash);
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ return [
 | 
				
			|||||||
    'require_https' => env('REQUIRE_HTTPS', true),
 | 
					    'require_https' => env('REQUIRE_HTTPS', true),
 | 
				
			||||||
    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
					    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
				
			||||||
    'app_domain' => env('APP_DOMAIN', ''),
 | 
					    'app_domain' => env('APP_DOMAIN', ''),
 | 
				
			||||||
    'app_version' => '5.0.53',
 | 
					    'app_version' => '5.0.54',
 | 
				
			||||||
    'minimum_client_version' => '5.0.16',
 | 
					    'minimum_client_version' => '5.0.16',
 | 
				
			||||||
    'terms_version' => '1.0.1',
 | 
					    'terms_version' => '1.0.1',
 | 
				
			||||||
    'api_secret' => env('API_SECRET', false),
 | 
					    'api_secret' => env('API_SECRET', false),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user