From 04a16fca905ca79047a011eca4d888391107b964 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Aug 2021 11:11:08 +1000 Subject: [PATCH 1/2] Square - pay --- app/PaymentDrivers/Square/CreditCard.php | 4 +- app/PaymentDrivers/SquarePaymentDriver.php | 45 ++++ .../square/credit_card/authorize.blade.php | 234 +++++++++--------- .../gateways/square/credit_card/pay.blade.php | 171 +++++++++++++ 4 files changed, 336 insertions(+), 118 deletions(-) create mode 100644 resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index b2f2a72391..75848bec07 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -130,9 +130,9 @@ class CreditCard { $data['gateway'] = $this->square_driver; - $data['client_token'] = $this->braintree->gateway->clientToken()->generate(); - return render('gateways.braintree.credit_card.pay', $data); + + return render('gateways.square.credit_card.pay', $data); } diff --git a/app/PaymentDrivers/SquarePaymentDriver.php b/app/PaymentDrivers/SquarePaymentDriver.php index d3c5ab2471..818c1e501a 100644 --- a/app/PaymentDrivers/SquarePaymentDriver.php +++ b/app/PaymentDrivers/SquarePaymentDriver.php @@ -102,4 +102,49 @@ class SquarePaymentDriver extends BaseDriver public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) { } + + + public function getClientRequiredFields(): array + { + $fields = []; + + $fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required']; + + if ($this->company_gateway->require_client_name) { + $fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_contact_name) { + $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_contact_email) { + $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; + } + + if ($this->company_gateway->require_client_phone) { + $fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required']; + } + + if ($this->company_gateway->require_billing_address) { + $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; +// $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable']; + $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_shipping_address) { + $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; +// $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes']; + $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; + } + + + return $fields; + } } \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php index 7bd9f85d4f..5b761b6761 100644 --- a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php @@ -27,141 +27,143 @@ @section('gateway_footer') - - + @else + + @endif + + + }); + @endsection \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php new file mode 100644 index 0000000000..e29ed33863 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php @@ -0,0 +1,171 @@ +@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-single') +
+ +
+ + + @endcomponent + + @component('portal.ninja2020.gateways.includes.pay_now') + {{ ctrans('texts.pay_now') }} + @endcomponent +@endsection + +@section('gateway_footer') + + @if($gateway->company_gateway->getConfigField('testMode')) + + @else + + @endif + + + +@endsection \ No newline at end of file From 613b649baac371b0575654a955d1e000402fe16d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Aug 2021 11:54:34 +1000 Subject: [PATCH 2/2] Square Test Mode --- .../gateways/square/credit_card/authorize.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php index 5b761b6761..0c5eaf2a28 100644 --- a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php @@ -10,14 +10,14 @@ @csrf - + @component('portal.ninja2020.components.general.card-element-single') -
+
-
+
- + @endcomponent @component('portal.ninja2020.gateways.includes.pay_now') @@ -32,7 +32,7 @@ @else @endif - +