From 7ec745c52c3b5d7a16c98a1535f2861e693254a9 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Wed, 19 Jul 2023 10:34:04 +0000 Subject: [PATCH] =?UTF-8?q?!159=20Stripe=20=E5=8D=87=E7=BA=A7=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20*=20wip=20*=20fixed=20stripe=20charge=20*=20wip=20*?= =?UTF-8?q?=20wip=20*=20code=20format=20*=20wip=20*=20wip=20*=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20stripe=20*=20Background=20tab=20is=20automatically?= =?UTF-8?q?=20activated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Stripe/Services/StripePaymentService.php | 15 +- .../Stripe/Views/checkout/payment.blade.php | 212 +++++++++++------- resources/beike/admin/js/app.js | 17 +- .../beike/admin/views/pages/setting.blade.php | 6 +- 4 files changed, 156 insertions(+), 94 deletions(-) diff --git a/plugins/Stripe/Services/StripePaymentService.php b/plugins/Stripe/Services/StripePaymentService.php index b20c9cc7..5648ae92 100644 --- a/plugins/Stripe/Services/StripePaymentService.php +++ b/plugins/Stripe/Services/StripePaymentService.php @@ -26,21 +26,16 @@ class StripePaymentService extends PaymentService /** * @throws ApiErrorException + * @throws \Exception */ public function capture($creditCardData): bool { $apiKey = plugin_setting('stripe.secret_key'); Stripe::setApiKey($apiKey); - $token = Token::create([ - 'card' => [ - 'number' => $creditCardData['cardnum'], - 'exp_year' => $creditCardData['year'], - 'exp_month' => $creditCardData['month'], - 'cvc' => $creditCardData['cvv'], - ], - ]); - - $tokenId = $token['id']; + $tokenId = $creditCardData['token'] ?? ''; + if (empty($tokenId)) { + throw new \Exception('Invalid token'); + } $currency = $this->order->currency_code; if (! in_array($currency, self::ZERO_DECIMAL)) { diff --git a/plugins/Stripe/Views/checkout/payment.blade.php b/plugins/Stripe/Views/checkout/payment.blade.php index 446ca0c9..9a405686 100644 --- a/plugins/Stripe/Views/checkout/payment.blade.php +++ b/plugins/Stripe/Views/checkout/payment.blade.php @@ -1,114 +1,170 @@ - - + - -
+

{{ __('Stripe::common.title_info') }}
-
+
- - - - - -
- - - - - - - - +
+
+
Cardholder Name
+
+
- - - - - - {{ __('Stripe::common.remenber') }} - - - - - +
+
@{{ errors.cardholderName }}
+ +
+
Credit Card Number
+
+
+
+
@{{ errors.cardNumber }}
+ +
+
Expiration Date
+
+
+
+
@{{ errors.cardExpiry }}
+
+
CVV
+
+
+
@{{ errors.cardCvc }}
+
+
+
+
- + \ No newline at end of file diff --git a/resources/beike/admin/js/app.js b/resources/beike/admin/js/app.js index eed417d1..6732452c 100644 --- a/resources/beike/admin/js/app.js +++ b/resources/beike/admin/js/app.js @@ -3,7 +3,7 @@ * @link https://beikeshop.com * @Author pu shuo * @Date 2022-08-26 18:18:22 - * @LastEditTime 2023-06-14 14:30:05 + * @LastEditTime 2023-07-14 18:15:09 */ import http from "../../../js/http"; @@ -64,6 +64,7 @@ $(document).ready(function ($) { }, }); + autoActiveTab() tinymceInit() }); @@ -114,3 +115,17 @@ const tinymceInit = () => { }); } +const autoActiveTab = () => { + const tab = bk.getQueryString('tab'); + + if (tab) { + if ($(`a[href="#${tab}"]`).length) { + $(`a[href="#${tab}"]`)[0].click() + return; + } + + if ($(`button[data-bs-target="#${tab}"]`).length) { + $(`button[data-bs-target="#${tab}"]`)[0].click() + } + } +} diff --git a/resources/beike/admin/views/pages/setting.blade.php b/resources/beike/admin/views/pages/setting.blade.php index d938b3e6..0022e29a 100644 --- a/resources/beike/admin/views/pages/setting.blade.php +++ b/resources/beike/admin/views/pages/setting.blade.php @@ -255,17 +255,13 @@ } $(function() { - const [tab, line] = [bk.getQueryString('tab'), bk.getQueryString('line')]; + const line = bk.getQueryString('line'); getZones(country_id); $('select[name="country_id"]').on('change', function () { getZones($(this).val()); }); - if (tab) { - $(`a[href="#${tab}"]`)[0].click() - } - if (line) { $(`textarea[name="${line}"], select[name="${line}"], input[name="${line}"]`).parents('.row').addClass('active-line');