From f4b590228a46990069566abd91aef682d9409cbf Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 18 Apr 2022 08:17:08 +0530 Subject: [PATCH 01/20] Forte gateway added. --- app/Models/Gateway.php | 8 + app/PaymentDrivers/Forte/ACH.php | 231 +++++++++++++++++ app/PaymentDrivers/Forte/CreditCard.php | 233 ++++++++++++++++++ app/PaymentDrivers/FortePaymentDriver.php | 90 +++++++ ...022_04_14_121548_forte_payment_gateway.php | 49 ++++ .../gateways/forte/ach/authorize.blade.php | 108 ++++++++ .../gateways/forte/ach/pay.blade.php | 80 ++++++ .../forte/credit_card/authorize.blade.php | 108 ++++++++ .../gateways/forte/credit_card/pay.blade.php | 80 ++++++ .../forte/includes/credit_card.blade.php | 12 + 10 files changed, 999 insertions(+) create mode 100644 app/PaymentDrivers/Forte/ACH.php create mode 100644 app/PaymentDrivers/Forte/CreditCard.php create mode 100644 app/PaymentDrivers/FortePaymentDriver.php create mode 100644 database/migrations/2022_04_14_121548_forte_payment_gateway.php create mode 100644 resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 5f214de0ce4b..0e61e28b3b7e 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -63,6 +63,8 @@ class Gateway extends StaticModel $link = 'https://applications.sagepay.com/apply/2C02C252-0F8A-1B84-E10D-CF933EFCAA99'; } elseif ($this->id == 20 || $this->id == 56) { $link = 'https://dashboard.stripe.com/account/apikeys'; + } elseif ($this->id == 59) { + $link = 'https://www.forte.net/'; } return $link; @@ -170,6 +172,12 @@ class Gateway extends StaticModel GatewayType::HOSTED_PAGE => ['refund' => false, 'token_billing' => false, 'webhooks' => [' ']] // Razorpay ]; break; + case 59: + return [ + GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], // Forte + GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']], + ]; + break; default: return []; break; diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php new file mode 100644 index 000000000000..96f20e54a859 --- /dev/null +++ b/app/PaymentDrivers/Forte/ACH.php @@ -0,0 +1,231 @@ +forte = $forte; + } + + public function authorizeView(array $data) + { + return render('gateways.forte.ach.authorize', $data); + } + + public function authorizeResponse(Request $request) + { + $customer_token = null; + $request->validate([ + 'account_number'=>'required|numeric', + 'account_holder_name'=>'required|string', + 'routing_number'=>'required|numeric', + ]); + if ($this->forte->client->gateway_tokens->count() == 0) { + try { + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "first_name": "'.$this->forte->client->name.'", + "last_name": "'.$this->forte->client->name.'", + "company_name": "'.$this->forte->client->name.'", + "customer_id": "'.$this->forte->client->number.'" + }', + CURLOPT_HTTPHEADER => array( + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Content-Type: application/json', + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), + 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS; nlbi_621087=eeFJXPvhGXW3XVl0R1efXgAAAAC5hY2Arn4aSDDQA+R2vZZu; incap_ses_713_621087=IuVrdOb1HwK0pTS8ExblCT8B6GAAAAAAWyswWx7wzWve4j23+Nsp4w==' + ), + )); + + $response = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + curl_close($curl); + + $response=json_decode($response); + + if ($httpcode>299) { + $error = Validator::make([], []); + $error->getMessageBag()->add('gateway_error', $response->response->response_desc); + return redirect()->back()->withErrors($error); + } + + $customer_token=$response->customer_token; + } catch (\Throwable $th) { + throw $th; + } + }else{ + $customer_token = $this->forte->client->gateway_tokens[0]->gateway_customer_reference; + } + + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/'.$customer_token.'/paymethods', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "notes":"'.$request->account_holder_name.' echeck", + "echeck": { + "account_holder": "'.$request->account_holder_name.'", + "account_number":"'.$request->account_number.'", + "routing_number":"'.$request->routing_number.'", + "account_type":"checking" + } + }', + CURLOPT_HTTPHEADER => array( + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Content-Type: application/json', + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), + 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS; nlbi_621087=tVVcSY5O+xzIMhyvR1efXgAAAABn4GsrsejFXewG9LEvz7cm; incap_ses_9153_621087=wAileyRCBU3lBWqsNP0Ff80/6GAAAAAASCPsRmBm9ygyrCA0iBX3kg==; incap_ses_9210_621087=OHvJaqfG9Cc+r/0GZX7Qf10a6WAAAAAA1CWMfnTjC/4Y/4bz/HTgBg==; incap_ses_713_621087=Lu/yR4IM2iokOlO8ExblCSWB6WAAAAAANBLUy0jRk/4YatHkXIajvA==' + ), + )); + + $response = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + curl_close($curl); + $response=json_decode($response); + + if ($httpcode>299) { + $error = Validator::make([], []); + $error->getMessageBag()->add('gateway_error', $response->response->response_desc); + return redirect()->back()->withErrors($error); + } + + $payment_meta = new \stdClass; + // $payment_meta->brand = (string)sprintf('%s (%s)', $request->bank_name, ctrans('texts.ach')); + $payment_meta->brand = (string)ctrans('texts.ach'); + $payment_meta->last4 = (string)$response->echeck->last_4_account_number; + $payment_meta->exp_year = '-'; + $payment_meta->type = GatewayType::BANK_TRANSFER; + + $data = [ + 'payment_meta' => $payment_meta, + 'token' => $response->paymethod_token, + 'payment_method_id' => $request->gateway_type_id, + ]; + + $this->forte->storeGatewayToken($data, ['gateway_customer_reference' => $customer_token]); + + return redirect()->route('client.payment_methods.index'); + } + + public function paymentView(array $data) + { + $this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data); + $this->forte->payment_hash->save(); + + $data['gateway'] = $this; + $data['system_amount_with_fee'] = $data['amount_with_fee']; + $data['fee_percent'] = $this->forte->company_gateway->fees_and_limits->{GatewayType::BANK_TRANSFER}->fee_percent; + $data['total']['fee_total'] = $data['total']['invoice_totals'] * $data['fee_percent'] / 100; + $data['total']['amount_with_fee'] = $data['total']['fee_total'] + $data['total']['invoice_totals']; + $data['amount_with_fee'] = $data['total']['amount_with_fee']; + return render('gateways.forte.ach.pay', $data); + } + + public function paymentResponse($request) + { + $data=$request; + + try { + $curl = curl_init(); + curl_setopt_array($curl, array( + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/transactions', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "action":"sale", + "authorization_amount": '.$data->amount_with_fee.', + "paymethod_token": "'.$data->payment_token.'", + "echeck":{ + "sec_code":"PPD", + }, + "billing_address":{ + "first_name": "'.auth()->user()->client->name.'", + "last_name": "'.auth()->user()->client->name.'" + } + }', + CURLOPT_HTTPHEADER => array( + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Content-Type: application/json', + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), + 'Cookie: visid_incap_621087=u18+3REYR/iISgzZxOF5s2ODW2IAAAAAQUIPAAAAAADuGqKgECQLS81FcSDrmhGe; nlbi_621087=YHngadhJ2VU+yr7/R1efXgAAAAD3mQyhqmnLls8PRu4iN58G; incap_ses_1136_621087=CVdrXUdhIlm9WJNDieLDD4QVXGIAAAAAvBwvkUcwhM0+OwvdPm2stg==' + ), + )); + + $response = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + curl_close($curl); + + $response=json_decode($response); + } catch (\Throwable $th) { + throw $th; + } + + if ($httpcode>299) { + $error = Validator::make([], []); + $error->getMessageBag()->add('gateway_error', $response->response->response_desc); + return redirect('client/invoices')->withErrors($error); + } + + $data['gateway_type_id']=GatewayType::CREDIT_CARD; + $data['amount']=$request->system_amount_with_fee; + $data['payment_type']=GatewayType::CREDIT_CARD; + $data['transaction_reference']=$response->transaction_id; + + $payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED); + return redirect('client/invoices')->withSuccess('Invoice paid.'); + } +} diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php new file mode 100644 index 000000000000..aeb68ef7625e --- /dev/null +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -0,0 +1,233 @@ +forte = $forte; + } + + public function authorizeView(array $data) + { + return render('gateways.forte.credit_card.authorize', $data); + } + + public function authorizeResponse($request) + { + $customer_token = null; + $request->validate([ + 'card_number'=>'required', + 'card_holders_name'=>'required|string', + 'expiry_month'=>'required', + 'expiry_year'=>'required', + 'cvc'=>'required', + ]); + if ($this->forte->client->gateway_tokens->count() == 0) { + try { + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "first_name": "'.$this->forte->client->name.'", + "last_name": "'.$this->forte->client->name.'", + "company_name": "'.$this->forte->client->name.'", + "customer_id": "'.$this->forte->client->number.'" + }', + CURLOPT_HTTPHEADER => array( + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Content-Type: application/json', + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), + 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS; nlbi_621087=eeFJXPvhGXW3XVl0R1efXgAAAAC5hY2Arn4aSDDQA+R2vZZu; incap_ses_713_621087=IuVrdOb1HwK0pTS8ExblCT8B6GAAAAAAWyswWx7wzWve4j23+Nsp4w==' + ), + )); + + $response = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + curl_close($curl); + + $response=json_decode($response); + + if ($httpcode>299) { + $error = Validator::make([], []); + $error->getMessageBag()->add('gateway_error', $response->response->response_desc); + return redirect()->back()->withErrors($error); + } + + $customer_token=$response->customer_token; + } catch (\Throwable $th) { + throw $th; + } + }else{ + $customer_token = $this->forte->client->gateway_tokens[0]->gateway_customer_reference; + } + + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/'.$customer_token.'/paymethods', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "notes":"'.$request->card_holders_name.' Card", + "card": { + "name_on_card":"'.$request->card_holders_name.'", + "card_type":"'.$request->card_type.'", + "account_number":"'.str_replace(' ', '', $request->card_number).'", + "expire_month":'.$request->expiry_month.', + "expire_year":20'.$request->expiry_year.', + "card_verification_value": "'.$request->cvc.'" + } + }', + CURLOPT_HTTPHEADER => array( + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Content-Type: application/json', + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), + 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS' + ), + )); + + $response = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + curl_close($curl); + $response=json_decode($response); + + if ($httpcode>299) { + $error = Validator::make([], []); + $error->getMessageBag()->add('gateway_error', $response->response->response_desc); + return redirect()->back()->withErrors($error); + } + + $payment_meta = new \stdClass; + $payment_meta->exp_month = (string) $response->card->expire_month; + $payment_meta->exp_year = (string) $response->card->expire_year; + $payment_meta->brand = (string) $response->card->card_type; + $payment_meta->last4 = (string) $response->card->last_4_account_number; + $payment_meta->type = GatewayType::CREDIT_CARD; + + $data = [ + 'payment_meta' => $payment_meta, + 'token' => $response->paymethod_token, + 'payment_method_id' => $request->payment_method_id, + ]; + + $this->forte->storeGatewayToken($data, ['gateway_customer_reference' => $customer_token]); + + return redirect()->route('client.payment_methods.index'); + } + + public function paymentView(array $data) + { + $this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data); + $this->forte->payment_hash->save(); + + $data['gateway'] = $this; + $data['system_amount_with_fee'] = $data['amount_with_fee']; + $data['fee_percent'] = $this->forte->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->fee_percent; + $data['total']['fee_total'] = $data['total']['invoice_totals'] * $data['fee_percent'] / 100; + $data['total']['amount_with_fee'] = $data['total']['fee_total'] + $data['total']['invoice_totals']; + $data['amount_with_fee'] = $data['total']['amount_with_fee']; + return render('gateways.forte.credit_card.pay', $data); + } + + public function paymentResponse(PaymentResponseRequest $request) + { + $data=$request; + + try { + $curl = curl_init(); + curl_setopt_array($curl, array( + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/transactions', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "action":"sale", + "authorization_amount": '.$data->amount_with_fee.', + "service_fee_amount": '.$data->fee_total.', + "paymethod_token": "'.$data->payment_token.'", + "billing_address":{ + "first_name": "'.auth()->user()->client->name.'", + "last_name": "'.auth()->user()->client->name.'" + } + }', + CURLOPT_HTTPHEADER => array( + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Content-Type: application/json', + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), + 'Cookie: visid_incap_621087=u18+3REYR/iISgzZxOF5s2ODW2IAAAAAQUIPAAAAAADuGqKgECQLS81FcSDrmhGe; nlbi_621087=YHngadhJ2VU+yr7/R1efXgAAAAD3mQyhqmnLls8PRu4iN58G; incap_ses_1136_621087=CVdrXUdhIlm9WJNDieLDD4QVXGIAAAAAvBwvkUcwhM0+OwvdPm2stg==' + ), + )); + + $response = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + curl_close($curl); + + $response=json_decode($response); + } catch (\Throwable $th) { + throw $th; + } + if ($httpcode>299) { + $error = Validator::make([], []); + $error->getMessageBag()->add('gateway_error', $response->response->response_desc); + return redirect('client/invoices')->withErrors($error); + } + + $data['gateway_type_id']=GatewayType::CREDIT_CARD; + $data['amount']=$request->system_amount_with_fee; + $data['payment_type']=GatewayType::CREDIT_CARD; + $data['transaction_reference']=$response->transaction_id; + + $payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED); + return redirect('client/invoices')->withSuccess('Invoice paid.'); + } +} diff --git a/app/PaymentDrivers/FortePaymentDriver.php b/app/PaymentDrivers/FortePaymentDriver.php new file mode 100644 index 000000000000..e79df1dd96dd --- /dev/null +++ b/app/PaymentDrivers/FortePaymentDriver.php @@ -0,0 +1,90 @@ + CreditCard::class, + GatewayType::BANK_TRANSFER => ACH::class, + ]; + + /** + * Returns the gateway types. + */ + public function gatewayTypes(): array + { + $types = []; + + $types[] = GatewayType::CREDIT_CARD; + $types[] = GatewayType::BANK_TRANSFER; + + return $types; + } + + const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model + + public function setPaymentMethod($payment_method_id) + { + $class = self::$methods[$payment_method_id]; + $this->payment_method = new $class($this); + return $this; + } + + public function authorizeView(array $data) + { + return $this->payment_method->authorizeView($data); //this is your custom implementation from here + } + + public function authorizeResponse($request) + { + return $this->payment_method->authorizeResponse($request); //this is your custom implementation from here + } + + public function processPaymentView(array $data) + { + return $this->payment_method->paymentView($data); //this is your custom implementation from here + } + + public function processPaymentResponse($request) + { + return $this->payment_method->paymentResponse($request); //this is your custom implementation from here + } + + // public function refund(Payment $payment, $amount, $return_client_response = false) + // { + // return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here + // } + + // public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) + // { + // return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here + // } +} diff --git a/database/migrations/2022_04_14_121548_forte_payment_gateway.php b/database/migrations/2022_04_14_121548_forte_payment_gateway.php new file mode 100644 index 000000000000..c603180b14b9 --- /dev/null +++ b/database/migrations/2022_04_14_121548_forte_payment_gateway.php @@ -0,0 +1,49 @@ +baseUri = ""; + $fields->apiAccessId = ""; + $fields->secureKey = ""; + $fields->authOrganizationId = ""; + $fields->organizationId = ""; + $fields->locationId = ""; + + $forte = new Gateway; + $forte->id = 59; + $forte->name = 'Forte'; + $forte->key = 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs'; + $forte->provider = 'Forte'; + $forte->is_offsite = true; + $forte->fields = \json_encode($fields); + $forte->visible = 1; + $forte->site_url = 'https://www.forte.net/'; + $forte->default_gateway_type_id = GatewayType::CREDIT_CARD; + $forte->save(); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php new file mode 100644 index 000000000000..950102bdb6f4 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php @@ -0,0 +1,108 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bank Details', 'card_title' => 'Bank Details']) + +@section('gateway_head') + {{-- @if($gateway->company_gateway->getConfigField('account_id')) + + + @else --}} + {{-- --}} + {{-- @endif --}} +@endsection + +@section('gateway_content') + @if(session()->has('ach_error')) +
+

{{ session('ach_error') }}

+
+ @endif + @if(Session::has('error')) +
{{ Session::get('error') }}
+ @endif + @if ($errors->any()) +
+ +
+ @endif + +
+ @csrf + + {{-- --}} + + + + + + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_holder_type')]) + + + {{ __('texts.individual_account') }} + + + + {{ __('texts.company_account') }} + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_holder_name')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.routing_number')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_number')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element-single') + + + @endcomponent + +
+ + +
+
+ +@endsection + +@section('gateway_footer') + +@endsection diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php new file mode 100644 index 000000000000..783c7ab468b6 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php @@ -0,0 +1,80 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bank Transfer', 'card_title' => 'Bank Transfer']) + +@section('gateway_head') + {{-- + --}} + + + + + +@endsection + +@section('gateway_content') +
+ @csrf + + + + + + + + + + + + +
+ + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + Bank Transfer + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if(count($tokens) > 0) + @foreach($tokens as $token) + + @endforeach + @endisset + + @endcomponent +
+ +
+
+ +@endsection + +@section('gateway_footer') + +@endsection diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php new file mode 100644 index 000000000000..8cd7e92ba659 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php @@ -0,0 +1,108 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')]) + +@section('gateway_head') + {{-- + --}} + + + + + + + + +@endsection + +@section('gateway_content') +
+ @csrf + + {{-- --}} + + + + + + + + + + @if(!Request::isSecure()) +

{{ ctrans('texts.https_required') }}

+ @endif + + + @if(Session::has('error')) +
{{ Session::get('error') }}
+ @endif + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')]) + {{ ctrans('texts.credit_card') }} + @endcomponent + + @include('portal.ninja2020.gateways.forte.includes.credit_card') + +
+ + +
+ +
+ + {{-- @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'card_button']) + {{ ctrans('texts.add_payment_method') }} + @endcomponent --}} +@endsection + +@section('gateway_footer') + {{-- @if($gateway->company_gateway->getConfigField('testMode')) + + @else + + @endif + + --}} + +@endsection \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php new file mode 100644 index 000000000000..4c39a1eacd9f --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php @@ -0,0 +1,80 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.payment_type_credit_card'), 'card_title' => ctrans('texts.payment_type_credit_card')]) + +@section('gateway_head') + {{-- + --}} + + + + + +@endsection + +@section('gateway_content') +
+ @csrf + + + + + + + + + + + + +
+ + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.credit_card') }} + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if(count($tokens) > 0) + @foreach($tokens as $token) + + @endforeach + @endisset + + @endcomponent +
+ +
+
+ +@endsection + +@section('gateway_footer') + +@endsection diff --git a/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php b/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php new file mode 100644 index 000000000000..98ba257752bc --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php @@ -0,0 +1,12 @@ +
+
+ + + + + +
+ +
+
From b935b82a8be899e3193677f23f1352d8120432f2 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 18 Apr 2022 17:53:45 +0530 Subject: [PATCH 02/20] Global configuration added to Forte gateway. --- app/PaymentDrivers/Forte/ACH.php | 13 ++++++++++--- app/PaymentDrivers/Forte/CreditCard.php | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 96f20e54a859..6bd649545482 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -35,6 +35,13 @@ class ACH public function __construct(FortePaymentDriver $forte) { $this->forte = $forte; + + $this->forte_base_uri = $this->forte->company_gateway->getConfigField('baseUri'); + $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); + $this->forte_secure_key = $this->forte->company_gateway->getConfigField('secureKey'); + $this->forte_auth_organization_id = $this->forte->company_gateway->getConfigField('authOrganizationId'); + $this->forte_organization_id = $this->forte->company_gateway->getConfigField('organizationId'); + $this->forte_location_id = $this->forte->company_gateway->getConfigField('locationId'); } public function authorizeView(array $data) @@ -64,9 +71,9 @@ class ACH CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ - "first_name": "'.$this->forte->client->name.'", - "last_name": "'.$this->forte->client->name.'", - "company_name": "'.$this->forte->client->name.'", + "first_name": "'.$this->forte->client->present()->name().'", + "last_name": "'.$this->forte->client->present()->name().'", + "company_name": "'.$this->forte->client->present()->name().'", "customer_id": "'.$this->forte->client->number.'" }', CURLOPT_HTTPHEADER => array( diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index aeb68ef7625e..e1073456dc0a 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -36,6 +36,13 @@ class CreditCard public function __construct(FortePaymentDriver $forte) { $this->forte = $forte; + + $this->forte_base_uri = $this->forte->company_gateway->getConfigField('baseUri'); + $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); + $this->forte_secure_key = $this->forte->company_gateway->getConfigField('secureKey'); + $this->forte_auth_organization_id = $this->forte->company_gateway->getConfigField('authOrganizationId'); + $this->forte_organization_id = $this->forte->company_gateway->getConfigField('organizationId'); + $this->forte_location_id = $this->forte->company_gateway->getConfigField('locationId'); } public function authorizeView(array $data) @@ -67,9 +74,9 @@ class CreditCard CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ - "first_name": "'.$this->forte->client->name.'", - "last_name": "'.$this->forte->client->name.'", - "company_name": "'.$this->forte->client->name.'", + "first_name": "'.$this->forte->client->present()->name().'", + "last_name": "'.$this->forte->client->present()->name().'", + "company_name": "'.$this->forte->client->present()->name().'", "customer_id": "'.$this->forte->client->number.'" }', CURLOPT_HTTPHEADER => array( From 7be910ea69d58b181cb446bd66d13aa55b822ce4 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Tue, 19 Apr 2022 11:27:40 +0530 Subject: [PATCH 03/20] Bug fixed. --- app/PaymentDrivers/Forte/ACH.php | 5 +++-- app/PaymentDrivers/Forte/CreditCard.php | 3 ++- .../ninja2020/gateways/forte/credit_card/pay.blade.php | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 6bd649545482..32db4db4cf2d 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -12,12 +12,13 @@ namespace App\PaymentDrivers\Forte; +use App\Models\Payment; use App\Models\GatewayType; +use App\Models\PaymentType; use App\Http\Requests\Request; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Validator; use App\PaymentDrivers\FortePaymentDriver; -use App\Models\Payment; class ACH { @@ -229,7 +230,7 @@ class ACH $data['gateway_type_id']=GatewayType::CREDIT_CARD; $data['amount']=$request->system_amount_with_fee; - $data['payment_type']=GatewayType::CREDIT_CARD; + $data['payment_type']=PaymentType::ACH; $data['transaction_reference']=$response->transaction_id; $payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED); diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index e1073456dc0a..7346754991b9 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -14,6 +14,7 @@ namespace App\PaymentDrivers\Forte; use App\Models\Payment; use App\Models\GatewayType; +use App\Models\PaymentType; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Validator; @@ -231,7 +232,7 @@ class CreditCard $data['gateway_type_id']=GatewayType::CREDIT_CARD; $data['amount']=$request->system_amount_with_fee; - $data['payment_type']=GatewayType::CREDIT_CARD; + $data['payment_type']=PaymentType::parseCardType(strtolower($request->card_brand)) ?: PaymentType::CREDIT_CARD_OTHER; $data['transaction_reference']=$response->transaction_id; $payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED); diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php index 4c39a1eacd9f..068e27a94295 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php @@ -37,6 +37,7 @@ @if(count($tokens) > 0) @foreach($tokens as $token) @endforeach - @endisset + @else +
+ @if($client->getBankTransferGateway()) + + {{ ctrans('texts.bank_account') }} + + @endif +
+ @endif @endcomponent
diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php index 068e27a94295..059b8da6d456 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php @@ -21,9 +21,6 @@ - - -
@@ -48,7 +45,16 @@ **** {{ optional($token->meta)->last4 }} @endforeach - @endisset + @else +
+ + @if($client->getCreditCardGateway()) + + {{ ctrans('texts.credit_card') }} + + @endif +
+ @endif @endcomponent
From ec1f5c8f6d8d23c2233ccf52b81b6bb4edc8547a Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Tue, 19 Apr 2022 18:21:50 +0530 Subject: [PATCH 05/20] payment_type updated for ACH. --- app/PaymentDrivers/Forte/ACH.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index cfe38d36166c..1579b26e05a6 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -226,10 +226,10 @@ class ACH $data = [ 'payment_method' => $request->payment_method_id, - 'payment_type' => PaymentType::parseCardType(strtolower($request->card_brand)) ?: PaymentType::CREDIT_CARD_OTHER, + 'payment_type' => PaymentType::ACH, 'amount' => $payment_hash->data->amount_with_fee, 'transaction_reference' => $response->transaction_id, - 'gateway_type_id' => GatewayType::CREDIT_CARD, + 'gateway_type_id' => GatewayType::BANK_TRANSFER, ]; $payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED); From 55affa93a3cf0dac32c1e7a7bc84485ab0c39b11 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Thu, 21 Apr 2022 11:15:08 +0530 Subject: [PATCH 06/20] Forte added in PaymentLibrariesSeeder. --- database/seeders/PaymentLibrariesSeeder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index e602fab0f08f..a375580c4746 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -82,6 +82,7 @@ class PaymentLibrariesSeeder extends Seeder ['id' => 55, 'name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 21, 'key' => '54faab2ab6e3223dbe848b1686490baa', 'fields' => '{"name":"","text":""}'], ['id' => 57, 'name' => 'Square', 'provider' => 'Square', 'is_offsite' => false, 'sort_order' => 21, 'key' => '65faab2ab6e3223dbe848b1686490baz', 'fields' => '{"accessToken":"","applicationId":"","locationId":"","testMode":false}'], ['id' => 58, 'name' => 'Razorpay', 'provider' => 'Razorpay', 'is_offsite' => false, 'sort_order' => 21, 'key' => 'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9', 'fields' => '{"apiKey":"","apiSecret":""}'], + ['id' => 59, 'name' => 'Forte', 'provider' => 'Forte', 'is_offsite' => true, 'sort_order' => 21, 'key' => 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs', 'fields' => '{"baseUri":"","apiAccessId":"","secureKey":"","authOrganizationId":"","organizationId":"","locationId":""}'], ]; foreach ($gateways as $gateway) { @@ -98,7 +99,7 @@ class PaymentLibrariesSeeder extends Seeder Gateway::query()->update(['visible' => 0]); - Gateway::whereIn('id', [1,3,7,11,15,20,39,46,55,50,57,52,58])->update(['visible' => 1]); + Gateway::whereIn('id', [1,3,7,11,15,20,39,46,55,50,57,52,58,59])->update(['visible' => 1]); if (Ninja::isHosted()) { Gateway::whereIn('id', [20])->update(['visible' => 0]); From ccc44430015e0c21c541c8d002de52466d516bf1 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Thu, 21 Apr 2022 11:53:12 +0530 Subject: [PATCH 07/20] Forte gateway create line removed from PaymentLibrariesSeeder and baseUri now static. --- app/PaymentDrivers/Forte/ACH.php | 5 ++++- app/PaymentDrivers/Forte/CreditCard.php | 5 ++++- .../migrations/2022_04_14_121548_forte_payment_gateway.php | 2 +- database/seeders/PaymentLibrariesSeeder.php | 1 - 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 1579b26e05a6..367d79ac667b 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -38,7 +38,10 @@ class ACH { $this->forte = $forte; - $this->forte_base_uri = $this->forte->company_gateway->getConfigField('baseUri'); + $this->forte_base_uri = "https://sandbox.forte.net/api/v3"; + if($this->forte->company_gateway->getConfigField('testMode') == true){ + $this->forte_base_uri = "https://api.forte.net/v3"; + } $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); $this->forte_secure_key = $this->forte->company_gateway->getConfigField('secureKey'); $this->forte_auth_organization_id = $this->forte->company_gateway->getConfigField('authOrganizationId'); diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index 96ceba12da11..a0723a7f9849 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -39,7 +39,10 @@ class CreditCard { $this->forte = $forte; - $this->forte_base_uri = $this->forte->company_gateway->getConfigField('baseUri'); + $this->forte_base_uri = "https://sandbox.forte.net/api/v3"; + if($this->forte->company_gateway->getConfigField('testMode') == true){ + $this->forte_base_uri = "https://api.forte.net/v3"; + } $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); $this->forte_secure_key = $this->forte->company_gateway->getConfigField('secureKey'); $this->forte_auth_organization_id = $this->forte->company_gateway->getConfigField('authOrganizationId'); diff --git a/database/migrations/2022_04_14_121548_forte_payment_gateway.php b/database/migrations/2022_04_14_121548_forte_payment_gateway.php index c603180b14b9..f330d5d19fac 100644 --- a/database/migrations/2022_04_14_121548_forte_payment_gateway.php +++ b/database/migrations/2022_04_14_121548_forte_payment_gateway.php @@ -17,7 +17,7 @@ class FortePaymentGateway extends Migration public function up() { $fields = new \stdClass; - $fields->baseUri = ""; + $fields->testMode = true; $fields->apiAccessId = ""; $fields->secureKey = ""; $fields->authOrganizationId = ""; diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index a375580c4746..91a1276027c9 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -82,7 +82,6 @@ class PaymentLibrariesSeeder extends Seeder ['id' => 55, 'name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 21, 'key' => '54faab2ab6e3223dbe848b1686490baa', 'fields' => '{"name":"","text":""}'], ['id' => 57, 'name' => 'Square', 'provider' => 'Square', 'is_offsite' => false, 'sort_order' => 21, 'key' => '65faab2ab6e3223dbe848b1686490baz', 'fields' => '{"accessToken":"","applicationId":"","locationId":"","testMode":false}'], ['id' => 58, 'name' => 'Razorpay', 'provider' => 'Razorpay', 'is_offsite' => false, 'sort_order' => 21, 'key' => 'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9', 'fields' => '{"apiKey":"","apiSecret":""}'], - ['id' => 59, 'name' => 'Forte', 'provider' => 'Forte', 'is_offsite' => true, 'sort_order' => 21, 'key' => 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs', 'fields' => '{"baseUri":"","apiAccessId":"","secureKey":"","authOrganizationId":"","organizationId":"","locationId":""}'], ]; foreach ($gateways as $gateway) { From 87df26a6fdcb523b0504f901fc97b477a127b335 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Thu, 21 Apr 2022 12:02:01 +0530 Subject: [PATCH 08/20] forte_base_uri error solved. --- app/PaymentDrivers/Forte/ACH.php | 4 ++-- app/PaymentDrivers/Forte/CreditCard.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 367d79ac667b..aa8569965cce 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -38,9 +38,9 @@ class ACH { $this->forte = $forte; - $this->forte_base_uri = "https://sandbox.forte.net/api/v3"; + $this->forte_base_uri = "https://sandbox.forte.net/api/v3/"; if($this->forte->company_gateway->getConfigField('testMode') == true){ - $this->forte_base_uri = "https://api.forte.net/v3"; + $this->forte_base_uri = "https://api.forte.net/v3/"; } $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); $this->forte_secure_key = $this->forte->company_gateway->getConfigField('secureKey'); diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index a0723a7f9849..1f7d27e32963 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -39,9 +39,9 @@ class CreditCard { $this->forte = $forte; - $this->forte_base_uri = "https://sandbox.forte.net/api/v3"; + $this->forte_base_uri = "https://sandbox.forte.net/api/v3/"; if($this->forte->company_gateway->getConfigField('testMode') == true){ - $this->forte_base_uri = "https://api.forte.net/v3"; + $this->forte_base_uri = "https://api.forte.net/v3/"; } $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); $this->forte_secure_key = $this->forte->company_gateway->getConfigField('secureKey'); From 69a09a5dccb52efa90a369b48aeaab536403eadc Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Thu, 21 Apr 2022 12:06:00 +0530 Subject: [PATCH 09/20] testMode error solved. --- app/PaymentDrivers/Forte/ACH.php | 2 +- app/PaymentDrivers/Forte/CreditCard.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index aa8569965cce..1e48649b15aa 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -39,7 +39,7 @@ class ACH $this->forte = $forte; $this->forte_base_uri = "https://sandbox.forte.net/api/v3/"; - if($this->forte->company_gateway->getConfigField('testMode') == true){ + if($this->forte->company_gateway->getConfigField('testMode') == false){ $this->forte_base_uri = "https://api.forte.net/v3/"; } $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index 1f7d27e32963..090ced1a65fe 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -40,7 +40,7 @@ class CreditCard $this->forte = $forte; $this->forte_base_uri = "https://sandbox.forte.net/api/v3/"; - if($this->forte->company_gateway->getConfigField('testMode') == true){ + if($this->forte->company_gateway->getConfigField('testMode') == false){ $this->forte_base_uri = "https://api.forte.net/v3/"; } $this->forte_api_access_id = $this->forte->company_gateway->getConfigField('apiAccessId'); From b8527698b47e0d8e089eb352ded5b95504cb5db7 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Thu, 21 Apr 2022 13:05:47 +0530 Subject: [PATCH 10/20] $fields->testMode is set to false. --- database/migrations/2022_04_14_121548_forte_payment_gateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2022_04_14_121548_forte_payment_gateway.php b/database/migrations/2022_04_14_121548_forte_payment_gateway.php index f330d5d19fac..b45b6d109cc2 100644 --- a/database/migrations/2022_04_14_121548_forte_payment_gateway.php +++ b/database/migrations/2022_04_14_121548_forte_payment_gateway.php @@ -17,7 +17,7 @@ class FortePaymentGateway extends Migration public function up() { $fields = new \stdClass; - $fields->testMode = true; + $fields->testMode = false; $fields->apiAccessId = ""; $fields->secureKey = ""; $fields->authOrganizationId = ""; From 77513a6bcc80ce4423e42ce68390980af826e6d5 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 25 Apr 2022 11:25:10 +0530 Subject: [PATCH 11/20] PCI compliance issue solved. --- app/PaymentDrivers/Forte/ACH.php | 103 +-- app/PaymentDrivers/Forte/CreditCard.php | 161 +---- .../js/clients/payments/forte-card-js.min.js | 669 ++++++++++++++++++ .../gateways/forte/ach/authorize.blade.php | 44 +- .../forte/credit_card/authorize.blade.php | 64 +- .../forte/includes/credit_card.blade.php | 2 +- 6 files changed, 783 insertions(+), 260 deletions(-) create mode 100644 public/js/clients/payments/forte-card-js.min.js diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 1e48649b15aa..59600ea68454 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -56,113 +56,20 @@ class ACH public function authorizeResponse(Request $request) { - $customer_token = null; - $request->validate([ - 'account_number'=>'required|numeric', - 'account_holder_name'=>'required|string', - 'routing_number'=>'required|numeric', - ]); - if ($this->forte->client->gateway_tokens->count() == 0) { - try { - $curl = curl_init(); - - curl_setopt_array($curl, array( - CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS =>'{ - "first_name": "'.$this->forte->client->present()->name().'", - "last_name": "'.$this->forte->client->present()->name().'", - "company_name": "'.$this->forte->client->present()->name().'", - "customer_id": "'.$this->forte->client->number.'" - }', - CURLOPT_HTTPHEADER => array( - 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, - 'Content-Type: application/json', - 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), - 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS; nlbi_621087=eeFJXPvhGXW3XVl0R1efXgAAAAC5hY2Arn4aSDDQA+R2vZZu; incap_ses_713_621087=IuVrdOb1HwK0pTS8ExblCT8B6GAAAAAAWyswWx7wzWve4j23+Nsp4w==' - ), - )); - $response = curl_exec($curl); - $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - - curl_close($curl); - - $response=json_decode($response); - - if ($httpcode>299) { - $error = Validator::make([], []); - $error->getMessageBag()->add('gateway_error', $response->response->response_desc); - return redirect()->back()->withErrors($error); - } - - $customer_token=$response->customer_token; - } catch (\Throwable $th) { - throw $th; - } - }else{ - $customer_token = $this->forte->client->gateway_tokens[0]->gateway_customer_reference; - } - - $curl = curl_init(); - - curl_setopt_array($curl, array( - CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/'.$customer_token.'/paymethods', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS =>'{ - "notes":"'.$request->account_holder_name.' echeck", - "echeck": { - "account_holder": "'.$request->account_holder_name.'", - "account_number":"'.$request->account_number.'", - "routing_number":"'.$request->routing_number.'", - "account_type":"checking" - } - }', - CURLOPT_HTTPHEADER => array( - 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, - 'Content-Type: application/json', - 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), - 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS; nlbi_621087=tVVcSY5O+xzIMhyvR1efXgAAAABn4GsrsejFXewG9LEvz7cm; incap_ses_9153_621087=wAileyRCBU3lBWqsNP0Ff80/6GAAAAAASCPsRmBm9ygyrCA0iBX3kg==; incap_ses_9210_621087=OHvJaqfG9Cc+r/0GZX7Qf10a6WAAAAAA1CWMfnTjC/4Y/4bz/HTgBg==; incap_ses_713_621087=Lu/yR4IM2iokOlO8ExblCSWB6WAAAAAANBLUy0jRk/4YatHkXIajvA==' - ), - )); - - $response = curl_exec($curl); - $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - curl_close($curl); - $response=json_decode($response); - - if ($httpcode>299) { - $error = Validator::make([], []); - $error->getMessageBag()->add('gateway_error', $response->response->response_desc); - return redirect()->back()->withErrors($error); - } - $payment_meta = new \stdClass; - // $payment_meta->brand = (string)sprintf('%s (%s)', $request->bank_name, ctrans('texts.ach')); $payment_meta->brand = (string)ctrans('texts.ach'); - $payment_meta->last4 = (string)$response->echeck->last_4_account_number; + $payment_meta->last4 = (string) $request->last_4; $payment_meta->exp_year = '-'; $payment_meta->type = GatewayType::BANK_TRANSFER; $data = [ 'payment_meta' => $payment_meta, - 'token' => $response->paymethod_token, + 'token' => $request->one_time_token, 'payment_method_id' => $request->gateway_type_id, ]; - $this->forte->storeGatewayToken($data, ['gateway_customer_reference' => $customer_token]); + $this->forte->storeGatewayToken($data); return redirect()->route('client.payment_methods.index')->withSuccess('Payment Method added.'); } @@ -194,13 +101,15 @@ class ACH CURLOPT_POSTFIELDS =>'{ "action":"sale", "authorization_amount": '.$payment_hash->data->total->amount_with_fee.', - "paymethod_token": "'.$request->payment_token.'", "echeck":{ "sec_code":"PPD", }, "billing_address":{ "first_name": "'.auth()->user()->client->name.'", "last_name": "'.auth()->user()->client->name.'" + }, + "echeck":{ + "one_time_token":"'.$request->payment_token.'" } }', CURLOPT_HTTPHEADER => array( diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index 090ced1a65fe..f5d96f78b5c9 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -57,117 +57,20 @@ class CreditCard public function authorizeResponse($request) { - $customer_token = null; - $request->validate([ - 'card_number'=>'required', - 'card_holders_name'=>'required|string', - 'expiry_month'=>'required', - 'expiry_year'=>'required', - 'cvc'=>'required', - ]); - if ($this->forte->client->gateway_tokens->count() == 0) { - try { - $curl = curl_init(); - - curl_setopt_array($curl, array( - CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS =>'{ - "first_name": "'.$this->forte->client->present()->name().'", - "last_name": "'.$this->forte->client->present()->name().'", - "company_name": "'.$this->forte->client->present()->name().'", - "customer_id": "'.$this->forte->client->number.'" - }', - CURLOPT_HTTPHEADER => array( - 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, - 'Content-Type: application/json', - 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), - 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS; nlbi_621087=eeFJXPvhGXW3XVl0R1efXgAAAAC5hY2Arn4aSDDQA+R2vZZu; incap_ses_713_621087=IuVrdOb1HwK0pTS8ExblCT8B6GAAAAAAWyswWx7wzWve4j23+Nsp4w==' - ), - )); - - $response = curl_exec($curl); - $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - - curl_close($curl); - - $response=json_decode($response); - - if ($httpcode>299) { - $error = Validator::make([], []); - $error->getMessageBag()->add('gateway_error', $response->response->response_desc); - return redirect()->back()->withErrors($error); - } - - $customer_token=$response->customer_token; - } catch (\Throwable $th) { - throw $th; - } - }else{ - $customer_token = $this->forte->client->gateway_tokens[0]->gateway_customer_reference; - } - - $curl = curl_init(); - - curl_setopt_array($curl, array( - CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/customers/'.$customer_token.'/paymethods', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS =>'{ - "notes":"'.$request->card_holders_name.' Card", - "card": { - "name_on_card":"'.$request->card_holders_name.'", - "card_type":"'.$request->card_type.'", - "account_number":"'.str_replace(' ', '', $request->card_number).'", - "expire_month":'.$request->expiry_month.', - "expire_year":20'.$request->expiry_year.', - "card_verification_value": "'.$request->cvc.'" - } - }', - CURLOPT_HTTPHEADER => array( - 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, - 'Content-Type: application/json', - 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), - 'Cookie: visid_incap_621087=QJCccwHeTHinK5DnAeQIuXPk5mAAAAAAQUIPAAAAAAATABmm7IZkHhUi85sN+UaS' - ), - )); - - $response = curl_exec($curl); - $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - curl_close($curl); - $response=json_decode($response); - - if ($httpcode>299) { - $error = Validator::make([], []); - $error->getMessageBag()->add('gateway_error', $response->response->response_desc); - return redirect()->back()->withErrors($error); - } - $payment_meta = new \stdClass; - $payment_meta->exp_month = (string) $response->card->expire_month; - $payment_meta->exp_year = (string) $response->card->expire_year; - $payment_meta->brand = (string) $response->card->card_type; - $payment_meta->last4 = (string) $response->card->last_4_account_number; + $payment_meta->exp_month = (string) $request->expire_month; + $payment_meta->exp_year = (string) $request->expire_year; + $payment_meta->brand = (string) $request->card_type; + $payment_meta->last4 = (string) $request->last_4; $payment_meta->type = GatewayType::CREDIT_CARD; $data = [ 'payment_meta' => $payment_meta, - 'token' => $response->paymethod_token, + 'token' => $request->one_time_token, 'payment_method_id' => $request->payment_method_id, ]; - $this->forte->storeGatewayToken($data, ['gateway_customer_reference' => $customer_token]); + $this->forte->storeGatewayToken($data); return redirect()->route('client.payment_methods.index')->withSuccess('Payment Method added.'); } @@ -187,32 +90,34 @@ class CreditCard try { $curl = curl_init(); + curl_setopt_array($curl, array( - CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/transactions', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS =>'{ - "action":"sale", - "authorization_amount": '.$payment_hash->data->total->amount_with_fee.', - "service_fee_amount": '.$payment_hash->data->total->fee_total.', - "paymethod_token": "'.$request->payment_token.'", - "billing_address":{ - "first_name": "'.auth()->user()->client->name.'", - "last_name": "'.auth()->user()->client->name.'" - } - }', - CURLOPT_HTTPHEADER => array( - 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, - 'Content-Type: application/json', - 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key), - 'Cookie: visid_incap_621087=u18+3REYR/iISgzZxOF5s2ODW2IAAAAAQUIPAAAAAADuGqKgECQLS81FcSDrmhGe; nlbi_621087=YHngadhJ2VU+yr7/R1efXgAAAAD3mQyhqmnLls8PRu4iN58G; incap_ses_1136_621087=CVdrXUdhIlm9WJNDieLDD4QVXGIAAAAAvBwvkUcwhM0+OwvdPm2stg==' - ), - )); + CURLOPT_URL => $this->forte_base_uri.'organizations/'.$this->forte_organization_id.'/locations/'.$this->forte_location_id.'/transactions', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "action":"sale", + "authorization_amount":'.$payment_hash->data->total->amount_with_fee.', + "service_fee_amount":'.$payment_hash->data->total->fee_total.', + "billing_address":{ + "first_name":"'.auth()->user()->client->name.'", + "last_name":"'.auth()->user()->client->name.'" + }, + "card":{ + "one_time_token":"'.$request->payment_token.'" + } + }', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'X-Forte-Auth-Organization-Id: '.$this->forte_organization_id, + 'Authorization: Basic '.base64_encode($this->forte_api_access_id.':'.$this->forte_secure_key) + ), + )); $response = curl_exec($curl); $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); diff --git a/public/js/clients/payments/forte-card-js.min.js b/public/js/clients/payments/forte-card-js.min.js new file mode 100644 index 000000000000..833dd5ee4bed --- /dev/null +++ b/public/js/clients/payments/forte-card-js.min.js @@ -0,0 +1,669 @@ +(() => { + function t(t) { + (this.elem = jQuery(t)), + (this.captureName = + !!this.elem.data('capture-name') && + this.elem.data('capture-name')), + (this.iconColour = + !!this.elem.data('icon-colour') && + this.elem.data('icon-colour')), + (this.stripe = + !!this.elem.data('stripe') && this.elem.data('stripe')), + this.stripe && (this.captureName = !1), + this.initCardNumberInput(), + this.initNameInput(), + this.initExpiryMonthInput(), + this.initExpiryYearInput(), + this.initCvcInput(), + this.elem.empty(), + this.setupCardNumberInput(), + this.setupNameInput(), + this.setupExpiryInput(), + this.setupCvcInput(), + this.iconColour && this.setIconColour(this.iconColour), + this.refreshCreditCardTypeIcon(); + } + !(function (e) { + var r = { + init: function () { + return this.data('cardjs', new t(this)), this; + }, + cardNumber: function () { + return this.data('cardjs').getCardNumber(); + }, + cardType: function () { + return this.data('cardjs').getCardType(); + }, + name: function () { + return this.data('cardjs').getName(); + }, + expiryMonth: function () { + return this.data('cardjs').getExpiryMonth(); + }, + expiryYear: function () { + return this.data('cardjs').getExpiryYear(); + }, + cvc: function () { + return this.data('cardjs').getCvc(); + }, + }; + e.fn.CardJs = function (t) { + return r[t] + ? r[t].apply(this, Array.prototype.slice.call(arguments, 1)) + : 'object' != typeof t && t + ? void e.error( + 'Method ' + t + ' does not exist on jQuery.CardJs' + ) + : r.init.apply(this, arguments); + }; + })(jQuery), + $(function () { + $('.card-js').each(function (t, e) { + $(e).CardJs(); + }); + }), + (t.prototype.constructor = t), + (t.KEYS = { + 0: 48, + 9: 57, + NUMPAD_0: 96, + NUMPAD_9: 105, + DELETE: 46, + BACKSPACE: 8, + ARROW_LEFT: 37, + ARROW_RIGHT: 39, + ARROW_UP: 38, + ARROW_DOWN: 40, + HOME: 36, + END: 35, + TAB: 9, + A: 65, + X: 88, + C: 67, + V: 86, + }), + (t.CREDIT_CARD_NUMBER_DEFAULT_MASK = 'XXXX XXXX XXXX XXXX'), + (t.CREDIT_CARD_NUMBER_VISA_MASK = 'XXXX XXXX XXXX XXXX'), + (t.CREDIT_CARD_NUMBER_MASTERCARD_MASK = 'XXXX XXXX XXXX XXXX'), + (t.CREDIT_CARD_NUMBER_DISCOVER_MASK = 'XXXX XXXX XXXX XXXX'), + (t.CREDIT_CARD_NUMBER_JCB_MASK = 'XXXX XXXX XXXX XXXX'), + (t.CREDIT_CARD_NUMBER_AMEX_MASK = 'XXXX XXXXXX XXXXX'), + (t.CREDIT_CARD_NUMBER_DINERS_MASK = 'XXXX XXXX XXXX XX'), + (t.prototype.creditCardNumberMask = t.CREDIT_CARD_NUMBER_DEFAULT_MASK), + (t.CREDIT_CARD_NUMBER_PLACEHOLDER = 'Card number'), + (t.NAME_PLACEHOLDER = 'Name on card'), + (t.EXPIRY_MASK = 'XX / XXXX'), + (t.EXPIRY_PLACEHOLDER = 'MM / YYYY'), + (t.EXPIRY_USE_DROPDOWNS = !1), + (t.EXPIRY_NUMBER_OF_YEARS = 10), + (t.CVC_MASK_3 = 'XXX'), + (t.CVC_MASK_4 = 'XXXX'), + (t.CVC_PLACEHOLDER = 'CVC'), + (t.CREDIT_CARD_SVG = + ''), + (t.LOCK_SVG = + ''), + (t.CALENDAR_SVG = + ''), + (t.USER_SVG = + ''), + (t.MAIL_SVG = + ''), + (t.INFORMATION_SVG = + ''), + (t.keyCodeFromEvent = function (t) { + return t.which || t.keyCode; + }), + (t.keyIsCommandFromEvent = function (t) { + return t.ctrlKey || t.metaKey; + }), + (t.keyIsNumber = function (e) { + return t.keyIsTopNumber(e) || t.keyIsKeypadNumber(e); + }), + (t.keyIsTopNumber = function (e) { + var r = t.keyCodeFromEvent(e); + return r >= t.KEYS[0] && r <= t.KEYS[9]; + }), + (t.keyIsKeypadNumber = function (e) { + var r = t.keyCodeFromEvent(e); + return r >= t.KEYS.NUMPAD_0 && r <= t.KEYS.NUMPAD_9; + }), + (t.keyIsDelete = function (e) { + return t.keyCodeFromEvent(e) == t.KEYS.DELETE; + }), + (t.keyIsBackspace = function (e) { + return t.keyCodeFromEvent(e) == t.KEYS.BACKSPACE; + }), + (t.keyIsDeletion = function (e) { + return t.keyIsDelete(e) || t.keyIsBackspace(e); + }), + (t.keyIsArrow = function (e) { + var r = t.keyCodeFromEvent(e); + return r >= t.KEYS.ARROW_LEFT && r <= t.KEYS.ARROW_DOWN; + }), + (t.keyIsNavigation = function (e) { + var r = t.keyCodeFromEvent(e); + return r == t.KEYS.HOME || r == t.KEYS.END; + }), + (t.keyIsKeyboardCommand = function (e) { + var r = t.keyCodeFromEvent(e); + return ( + t.keyIsCommandFromEvent(e) && + (r == t.KEYS.A || + r == t.KEYS.X || + r == t.KEYS.C || + r == t.KEYS.V) + ); + }), + (t.keyIsTab = function (e) { + return t.keyCodeFromEvent(e) == t.KEYS.TAB; + }), + (t.copyAllElementAttributes = function (t, e) { + $.each(t[0].attributes, function (t, r) { + e.attr(r.nodeName, r.nodeValue); + }); + }), + (t.numbersOnlyString = function (t) { + for (var e = '', r = 0; r < t.length; r++) { + var n = t.charAt(r); + !isNaN(parseInt(n)) && (e += n); + } + return e; + }), + (t.applyFormatMask = function (t, e) { + for (var r = '', n = 0, i = 0; i < e.length; i++) { + var a = e[i]; + if ('X' == a) { + if (!t.charAt(n)) break; + (r += t.charAt(n)), n++; + } else r += a; + } + return r; + }), + (t.cardTypeFromNumber = function (t) { + if (((e = new RegExp('^30[0-5]')), null != t.match(e))) + return 'Diners - Carte Blanche'; + if (((e = new RegExp('^(30[6-9]|36|38)')), null != t.match(e))) + return 'Diners'; + if (((e = new RegExp('^35(2[89]|[3-8][0-9])')), null != t.match(e))) + return 'JCB'; + if (((e = new RegExp('^3[47]')), null != t.match(e))) return 'AMEX'; + if ( + ((e = new RegExp('^(4026|417500|4508|4844|491(3|7))')), + null != t.match(e)) + ) + return 'Visa Electron'; + var e = new RegExp('^4'); + return null != t.match(e) + ? 'Visa' + : ((e = new RegExp('^5[1-5]')), + null != t.match(e) + ? 'Mastercard' + : ((e = new RegExp( + '^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)' + )), + null != t.match(e) ? 'Discover' : '')); + }), + (t.caretStartPosition = function (t) { + return 'number' == typeof t.selectionStart && t.selectionStart; + }), + (t.caretEndPosition = function (t) { + return 'number' == typeof t.selectionEnd && t.selectionEnd; + }), + (t.setCaretPosition = function (t, e) { + if (null != t) + if (t.createTextRange) { + var r = t.createTextRange(); + r.move('character', e), r.select(); + } else + t.selectionStart + ? (t.focus(), t.setSelectionRange(e, e)) + : t.focus(); + }), + (t.normaliseCaretPosition = function (t, e) { + var r = 0; + if (0 > e || e > t.length) return 0; + for (var n = 0; n < t.length; n++) { + if (n == e) return r; + 'X' == t[n] && r++; + } + return r; + }), + (t.denormaliseCaretPosition = function (t, e) { + var r = 0; + if (0 > e || e > t.length) return 0; + for (var n = 0; n < t.length; n++) { + if (r == e) return n; + 'X' == t[n] && r++; + } + return t.length; + }), + (t.filterNumberOnlyKey = function (e) { + var r = t.keyIsNumber(e), + n = t.keyIsDeletion(e), + i = t.keyIsArrow(e), + a = t.keyIsNavigation(e), + s = t.keyIsKeyboardCommand(e), + p = t.keyIsTab(e); + r || n || i || a || s || p || e.preventDefault(); + }), + (t.digitFromKeyCode = function (e) { + return e >= t.KEYS[0] && e <= t.KEYS[9] + ? e - t.KEYS[0] + : e >= t.KEYS.NUMPAD_0 && e <= t.KEYS.NUMPAD_9 + ? e - t.KEYS.NUMPAD_0 + : null; + }), + (t.handleMaskedNumberInputKey = function (e, r) { + t.filterNumberOnlyKey(e); + var n = e.which || e.keyCode, + i = e.target, + a = t.caretStartPosition(i), + s = t.caretEndPosition(i), + p = t.normaliseCaretPosition(r, a), + c = t.normaliseCaretPosition(r, s), + o = a, + u = t.keyIsNumber(e), + h = t.keyIsDelete(e), + d = t.keyIsBackspace(e); + if (u || h || d) { + e.preventDefault(); + var l = $(i).val(), + y = t.numbersOnlyString(l), + m = t.digitFromKeyCode(n), + C = c > p; + C && (y = y.slice(0, p) + y.slice(c)), + a != r.length && + (u && + l.length <= r.length && + ((y = y.slice(0, p) + m + y.slice(p)), + (o = Math.max( + t.denormaliseCaretPosition(r, p + 1), + t.denormaliseCaretPosition(r, p + 2) - 1 + ))), + h && (y = y.slice(0, p) + y.slice(p + 1))), + 0 != a && + d && + !C && + ((y = y.slice(0, p - 1) + y.slice(p)), + (o = t.denormaliseCaretPosition(r, p - 1))), + $(i).val(t.applyFormatMask(y, r)), + t.setCaretPosition(i, o); + } + }), + (t.handleCreditCardNumberKey = function (e, r) { + t.handleMaskedNumberInputKey(e, r); + }), + (t.handleCreditCardNumberChange = function (t) {}), + (t.handleExpiryKey = function (e) { + t.handleMaskedNumberInputKey(e, t.EXPIRY_MASK); + }), + (t.prototype.getCardNumber = function () { + return this.cardNumberInput.val(); + }), + (t.prototype.getCardType = function () { + return t.cardTypeFromNumber(this.getCardNumber()); + }), + (t.prototype.getName = function () { + return this.nameInput.val(); + }), + (t.prototype.getExpiryMonth = function () { + return this.expiryMonthInput.val(); + }), + (t.prototype.getExpiryYear = function () { + return this.expiryYearInput.val(); + }), + (t.prototype.getCvc = function () { + return this.cvcInput.val(); + }), + (t.prototype.setIconColour = function (t) { + this.elem.find('.icon .svg').css({ fill: t }); + }), + (t.prototype.setIconColour = function (t) { + this.elem.find('.icon .svg').css({ fill: t }); + }), + (t.prototype.refreshCreditCardTypeIcon = function () { + this.setCardTypeIconFromNumber( + t.numbersOnlyString(this.cardNumberInput.val()) + ); + }), + (t.prototype.clearCardTypeIcon = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .removeClass('show'); + }), + (t.prototype.setCardTypeIconAsVisa = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .attr('class', 'card-type-icon show visa'); + }), + (t.prototype.setCardTypeIconAsMasterCard = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .attr('class', 'card-type-icon show master-card'); + }), + (t.prototype.setCardTypeIconAsAmericanExpress = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .attr('class', 'card-type-icon show american-express'); + }), + (t.prototype.setCardTypeIconAsDiscover = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .attr('class', 'card-type-icon show discover'); + }), + (t.prototype.setCardTypeIconAsDiners = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .attr('class', 'card-type-icon show diners'); + }), + (t.prototype.setCardTypeIconAsJcb = function () { + this.elem + .find('.card-number-wrapper .card-type-icon') + .attr('class', 'card-type-icon show jcb'); + }), + (t.prototype.setCardTypeIconFromNumber = function (e) { + switch (t.cardTypeFromNumber(e)) { + case 'Visa Electron': + case 'Visa': + this.setCardTypeAsVisa(); + break; + case 'Mastercard': + this.setCardTypeAsMasterCard(); + break; + case 'AMEX': + this.setCardTypeAsAmericanExpress(); + break; + case 'Discover': + this.setCardTypeAsDiscover(); + break; + case 'Diners - Carte Blanche': + case 'Diners': + this.setCardTypeAsDiners(); + break; + case 'JCB': + this.setCardTypeAsJcb(); + break; + default: + this.clearCardType(); + } + }), + (t.prototype.setCardMask = function (t) { + (this.creditCardNumberMask = t), + this.cardNumberInput.attr('maxlength', t.length); + }), + (t.prototype.setCvc3 = function () { + this.cvcInput.attr('maxlength', t.CVC_MASK_3.length); + }), + (t.prototype.setCvc4 = function () { + this.cvcInput.attr('maxlength', t.CVC_MASK_4.length); + }), + (t.prototype.clearCardType = function () { + this.clearCardTypeIcon(), + this.setCardMask(t.CREDIT_CARD_NUMBER_DEFAULT_MASK), + this.setCvc3(); + }), + (t.prototype.setCardTypeAsVisa = function () { + this.setCardTypeIconAsVisa(), + this.setCardMask(t.CREDIT_CARD_NUMBER_VISA_MASK), + this.setCvc3(); + }), + (t.prototype.setCardTypeAsMasterCard = function () { + this.setCardTypeIconAsMasterCard(), + this.setCardMask(t.CREDIT_CARD_NUMBER_MASTERCARD_MASK), + this.setCvc3(); + }), + (t.prototype.setCardTypeAsAmericanExpress = function () { + this.setCardTypeIconAsAmericanExpress(), + this.setCardMask(t.CREDIT_CARD_NUMBER_AMEX_MASK), + this.setCvc4(); + }), + (t.prototype.setCardTypeAsDiscover = function () { + this.setCardTypeIconAsDiscover(), + this.setCardMask(t.CREDIT_CARD_NUMBER_DISCOVER_MASK), + this.setCvc3(); + }), + (t.prototype.setCardTypeAsDiners = function () { + this.setCardTypeIconAsDiners(), + this.setCardMask(t.CREDIT_CARD_NUMBER_DINERS_MASK), + this.setCvc3(); + }), + (t.prototype.setCardTypeAsJcb = function () { + this.setCardTypeIconAsJcb(), + this.setCardMask(t.CREDIT_CARD_NUMBER_JCB_MASK), + this.setCvc3(); + }), + (t.prototype.initCardNumberInput = function () { + var e = this; + (this.cardNumberInput = this.elem.find('.card-number')), + this.cardNumberInput[0] + ? this.cardNumberInput.detach() + : (this.cardNumberInput = $( + "" + )), + this.cardNumberInput.attr('type', 'tel'), + this.cardNumberInput.attr('placeholder') || + this.cardNumberInput.attr( + 'placeholder', + t.CREDIT_CARD_NUMBER_PLACEHOLDER + ), + this.cardNumberInput.attr( + 'maxlength', + this.creditCardNumberMask.length + ), + this.cardNumberInput.attr('x-autocompletetype', 'cc-number'), + this.cardNumberInput.attr('autocompletetype', 'cc-number'), + this.cardNumberInput.attr('autocorrect', 'off'), + this.cardNumberInput.attr('spellcheck', 'off'), + this.cardNumberInput.attr('autocapitalize', 'off'), + this.cardNumberInput.keydown(function (r) { + t.handleCreditCardNumberKey(r, e.creditCardNumberMask); + }), + this.cardNumberInput.keyup(function (t) { + e.refreshCreditCardTypeIcon(); + }), + this.cardNumberInput.change(t.handleCreditCardNumberChange); + }), + (t.prototype.initNameInput = function () { + (this.nameInput = this.elem.find('.name')), + this.nameInput[0] + ? ((this.captureName = !0), this.nameInput.detach()) + : (this.nameInput = $("")), + this.nameInput.attr('placeholder') || + this.nameInput.attr('placeholder', t.NAME_PLACEHOLDER); + }), + (t.prototype.initExpiryMonthInput = function () { + (this.expiryMonthInput = this.elem.find('.expiry-month')), + this.expiryMonthInput[0] + ? this.expiryMonthInput.detach() + : (this.expiryMonthInput = $( + "" + )); + }), + (t.prototype.initExpiryYearInput = function () { + (this.expiryYearInput = this.elem.find('.expiry-year')), + this.expiryYearInput[0] + ? this.expiryYearInput.detach() + : (this.expiryYearInput = $( + "" + )); + }), + (t.prototype.initCvcInput = function () { + (this.cvcInput = this.elem.find('.cvc')), + this.cvcInput[0] + ? this.cvcInput.detach() + : (this.cvcInput = $("")), + this.cvcInput.attr('type', 'tel'), + this.cvcInput.attr('placeholder') || + this.cvcInput.attr('placeholder', t.CVC_PLACEHOLDER), + this.cvcInput.attr('maxlength', t.CVC_MASK_3.length), + this.cvcInput.attr('x-autocompletetype', 'cc-csc'), + this.cvcInput.attr('autocompletetype', 'cc-csc'), + this.cvcInput.attr('autocorrect', 'off'), + this.cvcInput.attr('spellcheck', 'off'), + this.cvcInput.attr('autocapitalize', 'off'), + this.cvcInput.keydown(t.filterNumberOnlyKey); + }), + (t.prototype.setupCardNumberInput = function () { + this.stripe && this.cardNumberInput.attr('data-stripe', 'number'), + this.elem.append("
"); + var e = this.elem.find('.card-number-wrapper'); + e.append(this.cardNumberInput), + e.append("
"), + e.append("
"), + e.find('.icon').append(t.CREDIT_CARD_SVG); + }), + (t.prototype.setupNameInput = function () { + if (this.captureName) { + this.elem.append("
"); + var e = this.elem.find('.name-wrapper'); + e.append(this.nameInput), + e.append("
"), + e.find('.icon').append(t.USER_SVG); + } + }), + (t.prototype.setupExpiryInput = function () { + this.elem.append( + "
" + ); + var e, + r = this.elem.find('.expiry-wrapper'); + if (this.EXPIRY_USE_DROPDOWNS) { + e = $('
'); + var n = $( + "" + ), + i = this.expiryMonthInput; + t.copyAllElementAttributes(i, n), + this.expiryMonthInput.remove(), + (this.expiryMonthInput = n); + for ( + var a = $( + "" + ), + s = parseInt( + new Date().getFullYear().toString().substring(2, 4) + ), + p = 0; + p < t.EXPIRY_NUMBER_OF_YEARS; + p++ + ) + a.append("'), + (s = (s + 1) % 100); + var c = this.expiryYearInput; + t.copyAllElementAttributes(c, a), + this.expiryYearInput.remove(), + (this.expiryYearInput = a), + e.append(this.expiryMonthInput), + e.append(this.expiryYearInput); + } else { + (e = $('
')), + (this.expiryMonthInput = $( + "" + )), + (this.expiryYearInput = $( + "" + )), + this.stripe && + (this.expiryMonthInput.attr('data-stripe', 'exp-month'), + this.expiryYearInput.attr('data-stripe', 'exp-year')), + (this.expiryMonthYearInput = $("")), + this.expiryMonthYearInput.attr('type', 'tel'), + this.expiryMonthYearInput.attr('placeholder') || + this.expiryMonthYearInput.attr( + 'placeholder', + t.EXPIRY_PLACEHOLDER + ), + this.expiryMonthYearInput.attr( + 'maxlength', + t.EXPIRY_MASK.length + ), + this.expiryMonthYearInput.attr( + 'x-autocompletetype', + 'cc-exp' + ), + this.expiryMonthYearInput.attr( + 'autocompletetype', + 'cc-exp' + ), + this.expiryMonthYearInput.attr('autocorrect', 'off'), + this.expiryMonthYearInput.attr('spellcheck', 'off'), + this.expiryMonthYearInput.attr('autocapitalize', 'off'); + var o = this; + this.expiryMonthYearInput.keydown(function (e) { + t.handleExpiryKey(e); + var r = o.expiryMonthYearInput.val(); + 1 == r.length && + parseInt(r) > 1 && + t.keyIsNumber(e) && + o.expiryMonthYearInput.val( + t.applyFormatMask('0' + r, t.EXPIRY_MASK) + ), + o.EXPIRY_USE_DROPDOWNS || + null == o.expiryMonthYearInput || + (o.expiryMonthInput.val(o.expiryMonth()), + o.expiryYearInput.val( + 9 == r.length ? r.substr(5, 4) : null + )); + }), + this.expiryMonthYearInput.blur(function (t) { + o.refreshExpiryMonthValidation(); + }), + e.append(this.expiryMonthYearInput), + e.append(this.expiryMonthInput), + e.append(this.expiryYearInput); + } + r.append(e), + r.append("
"), + r.find('.icon').append(t.CALENDAR_SVG); + }), + (t.prototype.setupCvcInput = function () { + this.stripe && this.cvcInput.attr('data-stripe', 'cvc'), + this.elem.append( + "
" + ); + var e = this.elem.find('.cvc-wrapper'); + e.append(this.cvcInput), + e.append("
"), + e.find('.icon').append(t.LOCK_SVG); + }), + (t.prototype.expiryMonth = function () { + if ( + !this.EXPIRY_USE_DROPDOWNS && + null != this.expiryMonthYearInput + ) { + var t = this.expiryMonthYearInput.val(); + return t.length >= 2 ? parseInt(t.substr(0, 2)) : null; + } + return null; + }), + (t.isValidMonth = function (t) { + return t >= 1 && 12 >= t; + }), + (t.isExpiryValid = function (e, r) { + var n = new Date(), + i = n.getMonth() + 1, + a = '' + n.getFullYear(); + return ( + 2 == ('' + r).length && (r = a.substring(0, 2) + '' + r), + (i = parseInt(i)), + (a = parseInt(a)), + (e = parseInt(e)), + (r = parseInt(r)), + t.isValidMonth(e) && (r > a || (r == a && e >= i)) + ); + }), + (t.prototype.refreshExpiryMonthValidation = function () { + t.isExpiryValid(this.getExpiryMonth(), this.getExpiryYear()) + ? this.setExpiryMonthAsValid() + : this.setExpiryMonthAsInvalid(); + }), + (t.prototype.setExpiryMonthAsValid = function () { + this.EXPIRY_USE_DROPDOWNS || + this.expiryMonthYearInput.parent().removeClass('has-error'); + }), + (t.prototype.setExpiryMonthAsInvalid = function () { + this.EXPIRY_USE_DROPDOWNS || + this.expiryMonthYearInput.parent().addClass('has-error'); + }); +})(); diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php index 950102bdb6f4..2506d1086c9a 100644 --- a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php @@ -1,12 +1,11 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bank Details', 'card_title' => 'Bank Details']) @section('gateway_head') - {{-- @if($gateway->company_gateway->getConfigField('account_id')) - - - @else --}} - {{-- --}} - {{-- @endif --}} + @if($gateway->getConfigField('testMode')) + + @else + + @endif @endsection @section('gateway_content') @@ -18,6 +17,7 @@ @if(Session::has('error'))
{{ Session::get('error') }}
@endif +
@if ($errors->any())
    @@ -31,10 +31,11 @@
    @csrf - {{-- --}} + + @@ -70,11 +71,11 @@ @endcomponent @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.routing_number')]) - + @endcomponent @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_number')]) - + @endcomponent @component('portal.ninja2020.components.general.card-element-single') @@ -100,9 +101,32 @@ @section('gateway_footer') @endsection diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php index 8cd7e92ba659..67bad76fc8ae 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php @@ -1,16 +1,19 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')]) @section('gateway_head') - {{-- - --}} - + + @if($gateway->getConfigField('testMode')) + + @else + + @endif @endsection @section('gateway_content') @@ -20,13 +23,11 @@ {{-- --}} - - - - - - + + + + @if(!Request::isSecure())

    {{ ctrans('texts.https_required') }}

    @@ -36,6 +37,7 @@ @if(Session::has('error'))
    {{ Session::get('error') }}
    @endif +
    @if ($errors->any())
      @@ -66,21 +68,21 @@
    - - {{-- @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'card_button']) - {{ ctrans('texts.add_payment_method') }} - @endcomponent --}} @endsection @section('gateway_footer') - {{-- @if($gateway->company_gateway->getConfigField('testMode')) - - @else - - @endif - - --}} @endsection \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php b/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php index 98ba257752bc..5183e72986ed 100644 --- a/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/includes/credit_card.blade.php @@ -2,7 +2,7 @@ style="display: flex!important; justify-content: center!important;" id="authorize--credit-card-container">
    - + From aa12278d7cf8073c5f311d2e7ae7ad7e3eadf08f Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 25 Apr 2022 13:49:17 +0530 Subject: [PATCH 12/20] apiLoginId added. --- database/migrations/2022_04_14_121548_forte_payment_gateway.php | 1 + .../portal/ninja2020/gateways/forte/ach/authorize.blade.php | 2 +- .../ninja2020/gateways/forte/credit_card/authorize.blade.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/database/migrations/2022_04_14_121548_forte_payment_gateway.php b/database/migrations/2022_04_14_121548_forte_payment_gateway.php index b45b6d109cc2..93268ed7ad38 100644 --- a/database/migrations/2022_04_14_121548_forte_payment_gateway.php +++ b/database/migrations/2022_04_14_121548_forte_payment_gateway.php @@ -18,6 +18,7 @@ class FortePaymentGateway extends Migration { $fields = new \stdClass; $fields->testMode = false; + $fields->apiLoginId = ""; $fields->apiAccessId = ""; $fields->secureKey = ""; $fields->authOrganizationId = ""; diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php index 2506d1086c9a..586e5f374071 100644 --- a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php @@ -117,7 +117,7 @@ var routing_number=document.getElementById('routing-number').value; var data = { - api_login_id: 'D4A18FE6DC', + api_login_id: '{{$gateway->getConfigField("apiAccessId")}}', account_number: account_number, routing_number: routing_number, account_type: "checking", diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php index 67bad76fc8ae..540067e6eb6e 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php @@ -108,7 +108,7 @@ document.getElementById('expire_month').value=month; var data = { - api_login_id: 'D4A18FE6DC', + api_login_id: '{{$gateway->getConfigField("apiLoginId")}}', card_number: cc, expire_year: year, expire_month: month, From c9938c94341b5aa27bd77d21210ffa153ea13b8a Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 25 Apr 2022 14:09:10 +0530 Subject: [PATCH 13/20] apiLoginId issue fixed. --- .../portal/ninja2020/gateways/forte/ach/authorize.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php index 586e5f374071..fbc4dc8aebbe 100644 --- a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php @@ -117,7 +117,7 @@ var routing_number=document.getElementById('routing-number').value; var data = { - api_login_id: '{{$gateway->getConfigField("apiAccessId")}}', + api_login_id: '{{$gateway->getConfigField("apiLoginId")}}', account_number: account_number, routing_number: routing_number, account_type: "checking", From dc2ebc8d4f1fdd0b686287764375108ad83e1e83 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Tue, 26 Apr 2022 10:48:24 +0530 Subject: [PATCH 14/20] payment details added on payment page. --- .../gateways/forte/ach/authorize.blade.php | 1 - .../gateways/forte/ach/pay.blade.php | 79 ++++++++++--------- .../forte/credit_card/authorize.blade.php | 2 - .../gateways/forte/credit_card/pay.blade.php | 73 +++++++++-------- 4 files changed, 80 insertions(+), 75 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php index fbc4dc8aebbe..6929c8b3ea8b 100644 --- a/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/ach/authorize.blade.php @@ -102,7 +102,6 @@ @section('gateway_footer') - - - + @if($gateway->forte->company_gateway->getConfigField('testMode')) + + @else + + @endif @endsection @section('gateway_content') @@ -22,7 +20,7 @@ -
    +
    @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) Bank Transfer @@ -31,29 +29,19 @@ @include('portal.ninja2020.gateways.includes.payment_details') @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) - @if(count($tokens) > 0) - @foreach($tokens as $token) - - @endforeach - @else -
    - @if($client->getBankTransferGateway()) - - {{ ctrans('texts.bank_account') }} - - @endif -
    - @endif - + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.routing_number')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_number')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element-single') + + + @endcomponent @endcomponent
    + @endsection @section('gateway_footer') @endsection diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php index 540067e6eb6e..70d356f8e2f2 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/authorize.blade.php @@ -21,7 +21,6 @@ method="post" id="server_response"> @csrf - {{-- --}} @@ -73,7 +72,6 @@ @section('gateway_footer') - + + + @if($gateway->forte->company_gateway->getConfigField('testMode')) + + @else + + @endif @endsection @section('gateway_content') @@ -22,7 +25,7 @@ -
    +
    @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) {{ ctrans('texts.credit_card') }} @@ -31,30 +34,9 @@ @include('portal.ninja2020.gateways.includes.payment_details') @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) - @if(count($tokens) > 0) - @foreach($tokens as $token) - - @endforeach - @else -
    - - @if($client->getCreditCardGateway()) - - {{ ctrans('texts.credit_card') }} - - @endif -
    - @endif + + + @include('portal.ninja2020.gateways.forte.includes.credit_card') @endcomponent
    @@ -66,22 +48,43 @@ {{ $slot ?? ctrans('texts.pay_now') }} -
    + @endsection @section('gateway_footer') @endsection From f3f590097f26caec5baee00928f7b78f47734240 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Fri, 29 Apr 2022 09:47:26 +0530 Subject: [PATCH 15/20] ACH div error solved. --- .../gateways/forte/ach/pay.blade.php | 22 ++++++++----------- .../gateways/forte/credit_card/pay.blade.php | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php index c927b32877e4..1634ba966555 100644 --- a/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php @@ -28,20 +28,16 @@ @include('portal.ninja2020.gateways.includes.payment_details') - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @component('portal.ninja2020.components.general.card-element', ['title' => 'Pay with Bank Transfer']) - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.routing_number')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_number')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element-single') - - - @endcomponent +
    + +
    +
    + +
    @endcomponent
    -
    +
    + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + Bank Transfer + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => 'Pay with Bank Transfer']) + +
    + +
    +
    + +
    + @endcomponent +
    + +
    + @endsection @section('gateway_footer') diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php index 3d6df3deca32..ac47cda057cf 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php @@ -16,6 +16,8 @@ @section('gateway_content')
    @csrf + + @@ -24,35 +26,33 @@ - -
    - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) - {{ ctrans('texts.credit_card') }} - @endcomponent - - @include('portal.ninja2020.gateways.includes.payment_details') - - @component('portal.ninja2020.components.general.card-element', ['title' => 'Pay with Credit Card']) - - - @include('portal.ninja2020.gateways.forte.includes.credit_card') - - @endcomponent -
    - -
    +
    + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.credit_card') }} + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => 'Pay with Credit Card']) + @include('portal.ninja2020.gateways.forte.includes.credit_card') + @endcomponent + +
    + +
    + @endsection @section('gateway_footer') From e7331c9e2187c4b5e55eeb6c75b9e1af8d0c80a1 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 20 Jun 2022 09:41:03 +0530 Subject: [PATCH 17/20] some modification implemented for removing double submission. --- .../js/clients/payments/forte-ach-payment.js | 81 ++++++++++++++++++ .../payments/forte-credit-card-payment.js | 83 +++++++++++++++++++ .../gateways/forte/ach/pay.blade.php | 53 +++--------- .../gateways/forte/credit_card/pay.blade.php | 57 ++----------- webpack.mix.js | 8 ++ 5 files changed, 191 insertions(+), 91 deletions(-) create mode 100644 resources/js/clients/payments/forte-ach-payment.js create mode 100644 resources/js/clients/payments/forte-credit-card-payment.js diff --git a/resources/js/clients/payments/forte-ach-payment.js b/resources/js/clients/payments/forte-ach-payment.js new file mode 100644 index 000000000000..90bf9f675377 --- /dev/null +++ b/resources/js/clients/payments/forte-ach-payment.js @@ -0,0 +1,81 @@ +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://opensource.org/licenses/AAL + */ + +class ForteAuthorizeACH { + constructor(apiLoginId) { + this.apiLoginId = apiLoginId; + } + + handleAuthorization = () => { + var account_number = document.getElementById('account-number').value; + var routing_number = document.getElementById('routing-number').value; + + var data = { + api_login_id: this.apiLoginId, + account_number: account_number, + routing_number: routing_number, + account_type: 'checking', + }; + + let payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + document.getElementById('pay-now').disabled = true; + document.querySelector('#pay-now > svg').classList.remove('hidden'); + document.querySelector('#pay-now > span').classList.add('hidden'); + } + // console.log(data); + forte + .createToken(data) + .success(this.successResponseHandler) + .error(this.failedResponseHandler); + return false; + }; + + successResponseHandler = (response) => { + document.getElementById('payment_token').value = response.onetime_token; + + document.getElementById('server_response').submit(); + + return false; + }; + + failedResponseHandler = (response) => { + var errors = + '
    • ' + + response.response_description + + '
    '; + document.getElementById('forte_errors').innerHTML = errors; + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + + return false; + }; + + handle = () => { + let payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + payNowButton.addEventListener('click', (e) => { + this.handleAuthorization(); + }); + } + + return this; + }; +} + +const apiLoginId = document.querySelector( + 'meta[name="forte-api-login-id"]' +).content; + +/** @handle */ +new ForteAuthorizeACH(apiLoginId).handle(); diff --git a/resources/js/clients/payments/forte-credit-card-payment.js b/resources/js/clients/payments/forte-credit-card-payment.js new file mode 100644 index 000000000000..0139356a4daa --- /dev/null +++ b/resources/js/clients/payments/forte-credit-card-payment.js @@ -0,0 +1,83 @@ +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://opensource.org/licenses/AAL + */ + +class ForteAuthorizeCard { + constructor(apiLoginId) { + this.apiLoginId = apiLoginId; + this.cardHolderName = document.getElementById('cardholder_name'); + } + + handleAuthorization = () => { + var myCard = $('#my-card'); + + var data = { + api_login_id: this.apiLoginId, + card_number: myCard.CardJs('cardNumber').replace(/[^\d]/g, ''), + expire_year: myCard.CardJs('expiryYear').replace(/[^\d]/g, ''), + expire_month: myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''), + cvv: document.getElementById('cvv').value.replace(/[^\d]/g, ''), + }; + + let payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + document.getElementById('pay-now').disabled = true; + document.querySelector('#pay-now > svg').classList.remove('hidden'); + document.querySelector('#pay-now > span').classList.add('hidden'); + } + + forte + .createToken(data) + .success(this.successResponseHandler) + .error(this.failedResponseHandler); + return false; + }; + + successResponseHandler = (response) => { + document.getElementById('payment_token').value = response.onetime_token; + document.getElementById('card_brand').value = response.card_type; + + document.getElementById('server_response').submit(); + + return false; + }; + + failedResponseHandler = (response) => { + var errors = + '
    • ' + + response.response_description + + '
    '; + document.getElementById('forte_errors').innerHTML = errors; + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + + return false; + }; + + handle = () => { + let payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + payNowButton.addEventListener('click', (e) => { + this.handleAuthorization(); + }); + } + + return this; + }; +} + +const apiLoginId = document.querySelector( + 'meta[name="forte-api-login-id"]' +).content; + +/** @handle */ +new ForteAuthorizeCard(apiLoginId).handle(); diff --git a/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php index 524bdb7e41ff..5dbb93fbd246 100644 --- a/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/ach/pay.blade.php @@ -1,11 +1,7 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bank Transfer', 'card_title' => 'Bank Transfer']) @section('gateway_head') - @if($gateway->forte->company_gateway->getConfigField('testMode')) - - @else - - @endif + @endsection @section('gateway_content') @@ -41,46 +37,17 @@
    @endcomponent -
    - -
    + + @include('portal.ninja2020.gateways.includes.pay_now') @endsection @section('gateway_footer') - + @if($gateway->forte->company_gateway->getConfigField('testMode')) + + @else + + @endif + + @endsection diff --git a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php index ac47cda057cf..1cceb137f39c 100644 --- a/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/forte/credit_card/pay.blade.php @@ -1,16 +1,11 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.payment_type_credit_card'), 'card_title' => ctrans('texts.payment_type_credit_card')]) @section('gateway_head') + - - @if($gateway->forte->company_gateway->getConfigField('testMode')) - - @else - - @endif @endsection @section('gateway_content') @@ -41,50 +36,16 @@ @include('portal.ninja2020.gateways.forte.includes.credit_card') @endcomponent -
    - -
    + @include('portal.ninja2020.gateways.includes.pay_now') @endsection @section('gateway_footer') - + @if($gateway->forte->company_gateway->getConfigField('testMode')) + + @else + + @endif + + @endsection diff --git a/webpack.mix.js b/webpack.mix.js index 9f0c809188b5..0ad6a2425d05 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -10,6 +10,14 @@ mix.js("resources/js/app.js", "public/js") "resources/js/clients/payments/authorize-credit-card-payment.js", "public/js/clients/payments/authorize-credit-card-payment.js" ) + .js( + "resources/js/clients/payments/forte-credit-card-payment.js", + "public/js/clients/payments/forte-credit-card-payment.js" + ) + .js( + "resources/js/clients/payments/forte-ach-payment.js", + "public/js/clients/payments/forte-ach-payment.js" + ) .js( "resources/js/clients/payments/stripe-ach.js", "public/js/clients/payments/stripe-ach.js" From a503518ff8cec77a5800151a17a7db7da01522d3 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 20 Jun 2022 12:03:28 +0530 Subject: [PATCH 18/20] compiled js file added to public folder. --- .../js/clients/payments/forte-ach-payment.js | 81 ++++++++++++++++++ .../payments/forte-credit-card-payment.js | 82 +++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 public/js/clients/payments/forte-ach-payment.js create mode 100644 public/js/clients/payments/forte-credit-card-payment.js diff --git a/public/js/clients/payments/forte-ach-payment.js b/public/js/clients/payments/forte-ach-payment.js new file mode 100644 index 000000000000..837aeac0b641 --- /dev/null +++ b/public/js/clients/payments/forte-ach-payment.js @@ -0,0 +1,81 @@ +/******/ (() => { // webpackBootstrap +var __webpack_exports__ = {}; +/*!************************************************************!*\ + !*** ./resources/js/clients/payments/forte-ach-payment.js ***! + \************************************************************/ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://opensource.org/licenses/AAL + */ +var ForteAuthorizeACH = function ForteAuthorizeACH(apiLoginId) { + var _this = this; + + _classCallCheck(this, ForteAuthorizeACH); + + _defineProperty(this, "handleAuthorization", function () { + var account_number = document.getElementById('account-number').value; + var routing_number = document.getElementById('routing-number').value; + var data = { + api_login_id: _this.apiLoginId, + account_number: account_number, + routing_number: routing_number, + account_type: 'checking' + }; + var payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + document.getElementById('pay-now').disabled = true; + document.querySelector('#pay-now > svg').classList.remove('hidden'); + document.querySelector('#pay-now > span').classList.add('hidden'); + } // console.log(data); + + + forte.createToken(data).success(_this.successResponseHandler).error(_this.failedResponseHandler); + return false; + }); + + _defineProperty(this, "successResponseHandler", function (response) { + document.getElementById('payment_token').value = response.onetime_token; + document.getElementById('server_response').submit(); + return false; + }); + + _defineProperty(this, "failedResponseHandler", function (response) { + var errors = '
    • ' + response.response_description + '
    '; + document.getElementById('forte_errors').innerHTML = errors; + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + return false; + }); + + _defineProperty(this, "handle", function () { + var payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + payNowButton.addEventListener('click', function (e) { + _this.handleAuthorization(); + }); + } + + return _this; + }); + + this.apiLoginId = apiLoginId; +}; + +var apiLoginId = document.querySelector('meta[name="forte-api-login-id"]').content; +/** @handle */ + +new ForteAuthorizeACH(apiLoginId).handle(); +/******/ })() +; \ No newline at end of file diff --git a/public/js/clients/payments/forte-credit-card-payment.js b/public/js/clients/payments/forte-credit-card-payment.js new file mode 100644 index 000000000000..2c181f59171d --- /dev/null +++ b/public/js/clients/payments/forte-credit-card-payment.js @@ -0,0 +1,82 @@ +/******/ (() => { // webpackBootstrap +var __webpack_exports__ = {}; +/*!********************************************************************!*\ + !*** ./resources/js/clients/payments/forte-credit-card-payment.js ***! + \********************************************************************/ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://opensource.org/licenses/AAL + */ +var ForteAuthorizeCard = function ForteAuthorizeCard(apiLoginId) { + var _this = this; + + _classCallCheck(this, ForteAuthorizeCard); + + _defineProperty(this, "handleAuthorization", function () { + var myCard = $('#my-card'); + var data = { + api_login_id: _this.apiLoginId, + card_number: myCard.CardJs('cardNumber').replace(/[^\d]/g, ''), + expire_year: myCard.CardJs('expiryYear').replace(/[^\d]/g, ''), + expire_month: myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''), + cvv: document.getElementById('cvv').value.replace(/[^\d]/g, '') + }; + var payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + document.getElementById('pay-now').disabled = true; + document.querySelector('#pay-now > svg').classList.remove('hidden'); + document.querySelector('#pay-now > span').classList.add('hidden'); + } + + forte.createToken(data).success(_this.successResponseHandler).error(_this.failedResponseHandler); + return false; + }); + + _defineProperty(this, "successResponseHandler", function (response) { + document.getElementById('payment_token').value = response.onetime_token; + document.getElementById('card_brand').value = response.card_type; + document.getElementById('server_response').submit(); + return false; + }); + + _defineProperty(this, "failedResponseHandler", function (response) { + var errors = '
    • ' + response.response_description + '
    '; + document.getElementById('forte_errors').innerHTML = errors; + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + return false; + }); + + _defineProperty(this, "handle", function () { + var payNowButton = document.getElementById('pay-now'); + + if (payNowButton) { + payNowButton.addEventListener('click', function (e) { + _this.handleAuthorization(); + }); + } + + return _this; + }); + + this.apiLoginId = apiLoginId; + this.cardHolderName = document.getElementById('cardholder_name'); +}; + +var apiLoginId = document.querySelector('meta[name="forte-api-login-id"]').content; +/** @handle */ + +new ForteAuthorizeCard(apiLoginId).handle(); +/******/ })() +; \ No newline at end of file From 203f6184bfd80639d6cfb8e313b20498be28a915 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Mon, 20 Jun 2022 16:29:19 +0530 Subject: [PATCH 19/20] service fee related issue solved. --- app/PaymentDrivers/Forte/CreditCard.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index 4448fa8028c7..8e632357e993 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -87,7 +87,10 @@ class CreditCard public function paymentResponse(PaymentResponseRequest $request) { $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail(); - + $amount_with_fee = $payment_hash->data->total->amount_with_fee; + $fee_total = ( 3 * $amount_with_fee) / 100; + $amount_with_fee = $amount_with_fee + $fee_total; + try { $curl = curl_init(); @@ -102,8 +105,8 @@ class CreditCard CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "action":"sale", - "authorization_amount":'.$payment_hash->data->total->amount_with_fee.', - "service_fee_amount":'.$payment_hash->data->total->fee_total.', + "authorization_amount":'.$amount_with_fee.', + "service_fee_amount":'.$fee_total.', "billing_address":{ "first_name":"'.$this->forte->client->name.'", "last_name":"'.$this->forte->client->name.'" From c30616fc4622add99d4f2956494cf8e5db15b929 Mon Sep 17 00:00:00 2001 From: Kishan Patel Date: Thu, 23 Jun 2022 12:03:57 +0530 Subject: [PATCH 20/20] calculation updated for credit card. --- app/PaymentDrivers/Forte/CreditCard.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index 8e632357e993..b9882b3a4349 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -88,8 +88,18 @@ class CreditCard { $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail(); $amount_with_fee = $payment_hash->data->total->amount_with_fee; - $fee_total = ( 3 * $amount_with_fee) / 100; - $amount_with_fee = $amount_with_fee + $fee_total; + $invoice_totals = $payment_hash->data->total->invoice_totals; + $fee_total = 0; + print_r($payment_hash->data->total); + for ($i = ($invoice_totals * 100) ; $i < ($amount_with_fee * 100); $i++) { + $calculated_fee = ( 3 * $i) / 100; + $calculated_amount_with_fee = round(($i + $calculated_fee) / 100,2); + if ($calculated_amount_with_fee == $amount_with_fee) { + $fee_total = round($calculated_fee / 100,2); + $amount_with_fee = $calculated_amount_with_fee; + break; + } + } try { $curl = curl_init();