From 9420f23081876557c1f75b009594db1303ee0247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 20 Oct 2020 15:19:21 +0200 Subject: [PATCH] stripe: pay with credit card token & credit --- .../js/clients/payments/stripe-credit-card.js | 8 ++++---- resources/lang/en/texts.php | 2 ++ .../gateways/includes/pay_now.blade.php | 16 ++++++++++------ .../gateways/stripe/credit_card.blade.php | 17 ++++++++++++++--- .../stripe/includes/pay_with_credit.blade.php | 6 +++--- .../stripe/includes/pay_with_token.blade.php | 14 ++++++++++---- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/resources/js/clients/payments/stripe-credit-card.js b/resources/js/clients/payments/stripe-credit-card.js index f5b2c32629bd..84d96d94ea61 100644 --- a/resources/js/clients/payments/stripe-credit-card.js +++ b/resources/js/clients/payments/stripe-credit-card.js @@ -44,8 +44,8 @@ class StripeCreditCard { this.payNowButton.querySelector('span').classList.add('hidden'); this.stripe - .handleCardPayment(payNowButton.dataset.secret, { - payment_method: payNowButton.dataset.token, + .handleCardPayment(this.secret, { + payment_method: this.token, }) .then((result) => { if (result.error) { @@ -114,7 +114,7 @@ class StripeCreditCard { handle() { this.setupStripe(); - if (this.usingToken) { + if (this.token) { document .getElementById('pay-now-with-token') .addEventListener('click', () => { @@ -122,7 +122,7 @@ class StripeCreditCard { }); } - if (!this.usingToken) { + if (!this.token) { this.createElement().mountCardElement(); document.getElementById('pay-now').addEventListener('click', () => { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 5e9ddc8dea0f..735ea7f7c5cd 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3287,4 +3287,6 @@ return [ 'credit_message' => 'To view your credit for :amount, click the link below.', 'store_for_future_use' => 'Store for future use', + + 'pay_with_credit' => 'Pay with credit', ]; diff --git a/resources/views/portal/ninja2020/gateways/includes/pay_now.blade.php b/resources/views/portal/ninja2020/gateways/includes/pay_now.blade.php index d3bdcc8c83e7..bb43731892d5 100644 --- a/resources/views/portal/ninja2020/gateways/includes/pay_now.blade.php +++ b/resources/views/portal/ninja2020/gateways/includes/pay_now.blade.php @@ -1,9 +1,13 @@
-
diff --git a/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php b/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php index 7beefe76861f..41866f4d7e86 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php @@ -2,7 +2,7 @@ @section('gateway_head') - + @endsection @@ -17,12 +17,23 @@ + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) {{ ctrans('texts.credit_card') }} (Stripe) @endcomponent - @include('portal.ninja2020.gateways.stripe.includes.card_widget') - @include('portal.ninja2020.gateways.includes.pay_now') + @include('portal.ninja2020.gateways.includes.payment_details') + + @if((int)$total['amount_with_fee'] == 0) + @include('portal.ninja2020.gateways.stripe.includes.pay_with_credit') + @elseif($token) + @include('portal.ninja2020.gateways.stripe.includes.pay_with_token') + @include('portal.ninja2020.gateways.includes.pay_now', ['id' => 'pay-now-with-token']) + @else + @include('portal.ninja2020.gateways.stripe.includes.card_widget') + @include('portal.ninja2020.gateways.includes.pay_now') + @endif @endsection @section('gateway_footer') diff --git a/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_credit.blade.php b/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_credit.blade.php index b8ad2f749cd9..48d19935f80d 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_credit.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_credit.blade.php @@ -3,6 +3,6 @@ -
- -
+@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'pay-with-credit', 'form' => 'credit-payment']) + {{ ctrans('texts.pay_with_credit') }} +@endcomponent diff --git a/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_token.blade.php b/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_token.blade.php index ec1fff9a750a..1a2a1847cc44 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_token.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/includes/pay_with_token.blade.php @@ -1,12 +1,18 @@ -
+{{--
{{ ctrans('texts.credit_card') }}
{{ strtoupper($token->meta->brand) }} - **** {{ $token->meta->last4 }}
-
-
+
--}} + +@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.credit_card')]) + {{ strtoupper($token->meta->brand) }} - **** {{ $token->meta->last4 }} +@endcomponent + + +{{--
-
+
--}}