From 2cfdb56c136b9dacb925a913905ce4ac7933c445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 7 Oct 2021 18:04:07 +0200 Subject: [PATCH] Extract scripts into separate file --- resources/js/clients/payments/razorpay-aio.js | 29 +++++++++++++++++++ .../gateways/razorpay/hosted/pay.blade.php | 21 +------------- 2 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 resources/js/clients/payments/razorpay-aio.js diff --git a/resources/js/clients/payments/razorpay-aio.js b/resources/js/clients/payments/razorpay-aio.js new file mode 100644 index 000000000000..2ae159a3e7f6 --- /dev/null +++ b/resources/js/clients/payments/razorpay-aio.js @@ -0,0 +1,29 @@ +/** + * 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 + */ + +let options = JSON.parse( + document.querySelector('meta[name=razorpay-options]')?.content +); + +options.handler = function(response) { + document.getElementById('razorpay_payment_id').value = + response.razorpay_payment_id; + document.getElementById('razorpay_signature').value = + response.razorpay_signature; + document.getElementById('server-response').submit(); +}; + +let razorpay = new Razorpay(options); + +document.getElementById('pay-now').onclick = function(event) { + event.target.parentElement.disabled = true; + + razorpay.open(); +}; diff --git a/resources/views/portal/ninja2020/gateways/razorpay/hosted/pay.blade.php b/resources/views/portal/ninja2020/gateways/razorpay/hosted/pay.blade.php index 2c3e341ecb78..43a76890f809 100644 --- a/resources/views/portal/ninja2020/gateways/razorpay/hosted/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/razorpay/hosted/pay.blade.php @@ -32,24 +32,5 @@ ctrans('texts.aio_checkout')]) @section('gateway_footer') - - + @endsection