mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Working on gateway fees to authorize.net
This commit is contained in:
parent
6517d67601
commit
607a47ffd9
@ -1,5 +1,5 @@
|
||||
APP_NAME="Invoice Ninja"
|
||||
APP_ENV=local
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=false
|
||||
|
||||
|
@ -47,6 +47,7 @@ class AuthorizeCreditCard
|
||||
|
||||
public function processPaymentView($data)
|
||||
{
|
||||
|
||||
$tokens = ClientGatewayToken::where('client_id', $this->authorize->client->id)
|
||||
->where('company_gateway_id', $this->authorize->company_gateway->id)
|
||||
->where('gateway_type_id', GatewayType::CREDIT_CARD)
|
||||
@ -63,6 +64,7 @@ class AuthorizeCreditCard
|
||||
|
||||
public function processPaymentResponse($request)
|
||||
{
|
||||
|
||||
if($request->token)
|
||||
return $this->processTokenPayment($request);
|
||||
|
||||
@ -90,15 +92,18 @@ class AuthorizeCreditCard
|
||||
|
||||
private function processTokenPayment($request)
|
||||
{
|
||||
|
||||
$client_gateway_token = ClientGatewayToken::find($this->decodePrimaryKey($request->token));
|
||||
|
||||
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($client_gateway_token->gateway_customer_reference, $client_gateway_token->token, $request->input('amount_with_fee'));
|
||||
|
||||
return $this->handleResponse($data, $request);
|
||||
|
||||
}
|
||||
|
||||
private function tokenBilling($cgt, $amount, $invoice)
|
||||
{
|
||||
|
||||
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($cgt->gateway_customer_reference, $cgt->token, $amounts);
|
||||
|
||||
if($data['response'] != null && $data['response']->getMessages()->getResultCode() == "Ok") {
|
||||
@ -133,16 +138,19 @@ class AuthorizeCreditCard
|
||||
|
||||
private function handleResponse($data, $request)
|
||||
{
|
||||
|
||||
$response = $data['response'];
|
||||
|
||||
if($response != null && $response->getMessages()->getResultCode() == "Ok")
|
||||
return $this->processSuccessfulResponse($data, $request);
|
||||
|
||||
return $this->processFailedResponse($data, $request);
|
||||
|
||||
}
|
||||
|
||||
private function storePayment($payment_hash, $data)
|
||||
{
|
||||
|
||||
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
||||
|
||||
$payment = $this->createPaymentRecord($data, $amount);
|
||||
@ -154,6 +162,7 @@ class AuthorizeCreditCard
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||
|
||||
return $payment;
|
||||
|
||||
}
|
||||
|
||||
private function createPaymentRecord($data, $amount) :?Payment
|
||||
@ -170,16 +179,18 @@ class AuthorizeCreditCard
|
||||
$payment->save();
|
||||
|
||||
return $payment;
|
||||
|
||||
}
|
||||
|
||||
private function processSuccessfulResponse($data, $request)
|
||||
{
|
||||
|
||||
$payment_hash = PaymentHash::whereRaw("BINARY `hash`= ?", [$request->input('payment_hash')])->firstOrFail();
|
||||
$payment = $this->storePayment($payment_hash, $data);
|
||||
|
||||
$vars = [
|
||||
'hashed_ids' => $request->input('hashed_ids'),
|
||||
'amount' => $request->input('amount')
|
||||
'invoices' => $payment_hash->invoice(),
|
||||
'amount' => array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total
|
||||
];
|
||||
|
||||
$logger_message = [
|
||||
@ -201,6 +212,7 @@ class AuthorizeCreditCard
|
||||
|
||||
private function formatGatewayResponse($data, $vars)
|
||||
{
|
||||
|
||||
$response = $data['response'];
|
||||
|
||||
return [
|
||||
@ -209,8 +221,9 @@ class AuthorizeCreditCard
|
||||
'auth_code' => $response->getTransactionResponse()->getAuthCode(),
|
||||
'code' => $response->getTransactionResponse()->getMessages()[0]->getCode(),
|
||||
'description' => $response->getTransactionResponse()->getMessages()[0]->getDescription(),
|
||||
'invoices' => $vars['hashed_ids'],
|
||||
'invoices' => $vars['invoices'],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user