diff --git a/app/PaymentDrivers/PayTrace/CreditCard.php b/app/PaymentDrivers/PayTrace/CreditCard.php index 4bea3babc8f9..6e97b1baa11f 100644 --- a/app/PaymentDrivers/PayTrace/CreditCard.php +++ b/app/PaymentDrivers/PayTrace/CreditCard.php @@ -23,12 +23,14 @@ use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\PayFastPaymentDriver; use App\PaymentDrivers\PaytracePaymentDriver; +use App\Utils\Traits\MakesHash; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; class CreditCard { + use MakesHash; public $paytrace_driver; @@ -135,7 +137,14 @@ class CreditCard public function paymentView($data) { + $data['client_key'] = $this->paytrace_driver->getAuthToken(); + $data['gateway'] = $this->paytrace_driver; + //do i store the card? + // + //do i use a token? + // + //is it a new card? return render('gateways.paytrace.pay', $data); @@ -146,7 +155,16 @@ class CreditCard { $response_array = $request->all(); + if($request->token) + $this->processTokenPayment($request); + if ($request->has('store_card') && $request->input('store_card') === true) { + + //create customer + + } + + // charge CC // if($response_array['payment_status'] == 'COMPLETE') { @@ -159,12 +177,33 @@ class CreditCard // } } + + public function processTokenPayment($request) + { + + $data = [ + 'customer_id' => $request->token, + 'integrator_id' => '959195xd1CuC', + 'amount' => $request->input('amount_with_fee'), + ]; + + $response = $this->paytrace_driver->gatewayRequest('/v1/transactions/sale/by_customer', $data); + + if($response->success){ + $this->paytrace_driver->logSuccessfulGatewayResponse(['response' => $response, 'data' => $this->paytrace_driver->payment_hash], SystemLog::TYPE_PAYTRACE); + + return $this->processSuccessfulPayment($response); + } + + return $this->processUnsuccessfulPayment($response); + } + private function processSuccessfulPayment($response_array) { - // $payment = $this->paytrace_driver->createPayment($payment_record, Payment::STATUS_COMPLETED); + $payment = $this->paytrace_driver->createPayment($payment_record, Payment::STATUS_COMPLETED); } diff --git a/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php b/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php index e69de29bb2d1..5217115ad0e5 100644 --- a/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php @@ -0,0 +1,208 @@ +@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 + + @include('portal.ninja2020.gateways.includes.save_card') + + +
+ +
+ +
+ @include('portal.ninja2020.gateways.includes.pay_now') + +@endsection + +@section('gateway_footer') + + + + +@endsection