From 0de492d96fac6f0eca5aa1bb56a4321cd9c431d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 16 Jul 2024 10:43:55 +0200 Subject: [PATCH] Stripe: New payment flow (#67) * stripe: ach * stripe: klarna * stripe: bank transfer * assets build * stripe: bacs * stripe: bancontact * stripe: becs * stripe: eps * stripe: fpx * stripe: giropay * stripe: ideal * stripe: przelewy24 * stripe: sepa * stripe: sofort * assets build * assets build * pass context payload into livewirePaymentView * update checkout.com * update livewire method interface * stripe: acss * align methods with interface (array $data) --- app/Livewire/Flow2/ProcessPayment.php | 13 +- app/PaymentDrivers/CheckoutCom/CreditCard.php | 2 +- .../CheckoutComPaymentDriver.php | 4 +- .../Common/LivewireMethodInterface.php | 2 +- app/PaymentDrivers/Stripe/ACH.php | 97 +++++----- app/PaymentDrivers/Stripe/ACSS.php | 121 +++++++------ app/PaymentDrivers/Stripe/BACS.php | 21 ++- app/PaymentDrivers/Stripe/BECS.php | 69 ++++--- app/PaymentDrivers/Stripe/Bancontact.php | 67 ++++--- app/PaymentDrivers/Stripe/BankTransfer.php | 77 ++++---- app/PaymentDrivers/Stripe/BrowserPay.php | 6 +- app/PaymentDrivers/Stripe/CreditCard.php | 2 +- app/PaymentDrivers/Stripe/EPS.php | 65 ++++--- app/PaymentDrivers/Stripe/FPX.php | 65 ++++--- app/PaymentDrivers/Stripe/GIROPAY.php | 65 ++++--- app/PaymentDrivers/Stripe/Klarna.php | 69 ++++--- app/PaymentDrivers/Stripe/PRZELEWY24.php | 65 ++++--- app/PaymentDrivers/Stripe/SEPA.php | 69 ++++--- app/PaymentDrivers/Stripe/SOFORT.php | 65 ++++--- app/PaymentDrivers/Stripe/iDeal.php | 65 ++++--- app/PaymentDrivers/StripePaymentDriver.php | 4 +- .../assets/authorize-stripe-acss-f6bd46c1.js | 9 + ...24.js => checkout-credit-card-eba516f2.js} | 2 +- .../build/assets/stripe-ach-pay-22d14901.js | 9 + ...ss-946fe54a.js => stripe-acss-1184fda8.js} | 4 +- ...cs-38c8b975.js => stripe-bacs-e1cfee99.js} | 4 +- .../assets/stripe-bancontact-743204e1.js | 9 + .../assets/stripe-bancontact-cb004d43.js | 9 - .../assets/stripe-bank-transfer-801a4de6.js | 9 + ...cs-4d1494ed.js => stripe-becs-ce05fb09.js} | 4 +- ...8fb26.js => stripe-browserpay-813e625e.js} | 4 +- ...996a.js => stripe-credit-card-f3658509.js} | 2 +- public/build/assets/stripe-eps-6ebc87cd.js | 9 - public/build/assets/stripe-eps-735c10bd.js | 9 + ...fpx-240a05e2.js => stripe-fpx-d93f7d79.js} | 4 +- .../build/assets/stripe-giropay-9d3bfbab.js | 9 - .../build/assets/stripe-giropay-bff9b7b5.js | 9 + public/build/assets/stripe-ideal-22b9f5cf.js | 9 + public/build/assets/stripe-ideal-efa175e9.js | 9 - ...-e45c946d.js => stripe-klarna-9ee067e7.js} | 4 +- ...54acf.js => stripe-przelewy24-7f03b69e.js} | 4 +- ...pa-6dd487fc.js => stripe-sepa-554f6dfd.js} | 4 +- ...-18aeca06.js => stripe-sofort-6e4e7148.js} | 4 +- public/build/assets/wait-8f4ae121.js | 9 + public/build/assets/wait-d71d9fed.js | 9 - public/build/manifest.json | 101 +++++++++-- .../payment_methods/authorize-stripe-acss.js | 80 +++++++++ .../js/clients/payments/stripe-ach-pay.js | 168 ++++++++++++++++++ resources/js/clients/payments/stripe-acss.js | 19 +- resources/js/clients/payments/stripe-bacs.js | 24 +-- .../js/clients/payments/stripe-bancontact.js | 19 +- .../clients/payments/stripe-bank-transfer.js | 76 ++++++++ resources/js/clients/payments/stripe-becs.js | 20 ++- resources/js/clients/payments/stripe-eps.js | 20 ++- resources/js/clients/payments/stripe-fpx.js | 22 +-- .../js/clients/payments/stripe-giropay.js | 20 ++- resources/js/clients/payments/stripe-ideal.js | 20 ++- .../js/clients/payments/stripe-klarna.js | 20 ++- .../js/clients/payments/stripe-przelewy24.js | 20 ++- resources/js/clients/payments/stripe-sepa.js | 14 +- .../js/clients/payments/stripe-sofort.js | 20 ++- resources/js/clients/wait.js | 14 ++ .../stripe/ach/pay_livewire.blade.php | 92 ++++++++++ .../stripe/acss/authorize_livewire.blade.php | 70 ++++++++ .../gateways/stripe/acss/pay.blade.php | 3 +- .../stripe/acss/pay_livewire.blade.php | 56 ++++++ .../stripe/bacs/pay_livewire.blade.php | 47 +++++ .../stripe/bancontact/pay_livewire.blade.php | 33 ++++ .../bank_transfer/pay_livewire.blade.php | 43 +++++ .../stripe/becs/pay_livewire.blade.php | 36 ++++ .../stripe/eps/pay_livewire.blade.php | 33 ++++ .../stripe/fpx/pay_livewire.blade.php | 31 ++++ .../stripe/giropay/pay_livewire.blade.php | 32 ++++ .../stripe/ideal/pay_livewire.blade.php | 32 ++++ .../stripe/klarna/pay_livewire.blade.php | 37 ++++ .../stripe/przelewy24/pay_livewire.blade.php | 35 ++++ .../stripe/sepa/pay_livewire.blade.php | 89 ++++++++++ .../stripe/sofort/pay_livewire.blade.php | 30 ++++ vite.config.ts | 3 + 79 files changed, 1947 insertions(+), 602 deletions(-) create mode 100644 public/build/assets/authorize-stripe-acss-f6bd46c1.js rename public/build/assets/{checkout-credit-card-ba005c24.js => checkout-credit-card-eba516f2.js} (98%) create mode 100644 public/build/assets/stripe-ach-pay-22d14901.js rename public/build/assets/{stripe-acss-946fe54a.js => stripe-acss-1184fda8.js} (72%) rename public/build/assets/{stripe-bacs-38c8b975.js => stripe-bacs-e1cfee99.js} (76%) create mode 100644 public/build/assets/stripe-bancontact-743204e1.js delete mode 100644 public/build/assets/stripe-bancontact-cb004d43.js create mode 100644 public/build/assets/stripe-bank-transfer-801a4de6.js rename public/build/assets/{stripe-becs-4d1494ed.js => stripe-becs-ce05fb09.js} (83%) rename public/build/assets/{stripe-browserpay-ac78fb26.js => stripe-browserpay-813e625e.js} (92%) rename public/build/assets/{stripe-credit-card-ce33996a.js => stripe-credit-card-f3658509.js} (99%) delete mode 100644 public/build/assets/stripe-eps-6ebc87cd.js create mode 100644 public/build/assets/stripe-eps-735c10bd.js rename public/build/assets/{stripe-fpx-240a05e2.js => stripe-fpx-d93f7d79.js} (67%) delete mode 100644 public/build/assets/stripe-giropay-9d3bfbab.js create mode 100644 public/build/assets/stripe-giropay-bff9b7b5.js create mode 100644 public/build/assets/stripe-ideal-22b9f5cf.js delete mode 100644 public/build/assets/stripe-ideal-efa175e9.js rename public/build/assets/{stripe-klarna-e45c946d.js => stripe-klarna-9ee067e7.js} (64%) rename public/build/assets/{stripe-przelewy24-f9154acf.js => stripe-przelewy24-7f03b69e.js} (81%) rename public/build/assets/{stripe-sepa-6dd487fc.js => stripe-sepa-554f6dfd.js} (91%) rename public/build/assets/{stripe-sofort-18aeca06.js => stripe-sofort-6e4e7148.js} (71%) create mode 100644 public/build/assets/wait-8f4ae121.js delete mode 100644 public/build/assets/wait-d71d9fed.js create mode 100644 resources/js/clients/payment_methods/authorize-stripe-acss.js create mode 100644 resources/js/clients/payments/stripe-ach-pay.js create mode 100644 resources/js/clients/payments/stripe-bank-transfer.js create mode 100644 resources/views/portal/ninja2020/gateways/stripe/ach/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/acss/authorize_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/acss/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/bacs/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/bancontact/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/bank_transfer/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/becs/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/eps/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/fpx/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/giropay/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/ideal/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/klarna/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/przelewy24/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/sepa/pay_livewire.blade.php create mode 100644 resources/views/portal/ninja2020/gateways/stripe/sofort/pay_livewire.blade.php diff --git a/app/Livewire/Flow2/ProcessPayment.php b/app/Livewire/Flow2/ProcessPayment.php index 8e012b713fb5..8598357520aa 100644 --- a/app/Livewire/Flow2/ProcessPayment.php +++ b/app/Livewire/Flow2/ProcessPayment.php @@ -54,17 +54,20 @@ class ProcessPayment extends Component $company_gateway = CompanyGateway::find($this->getContext()['company_gateway_id']); - if(!$responder_data['success']) { + if (!$responder_data['success']) { throw new PaymentFailed($responder_data['error'], 400); } $driver = $company_gateway - ->driver($invitation->contact->client) - ->setPaymentMethod($data['payment_method_id']) - ->setPaymentHash($responder_data['payload']['ph']); + ->driver($invitation->contact->client) + ->setPaymentMethod($data['payment_method_id']) + ->setPaymentHash($responder_data['payload']['ph']); - $this->payment_view = $driver->livewirePaymentView(); $this->payment_data_payload = $driver->processPaymentViewData($responder_data['payload']); + + $this->payment_view = $driver->livewirePaymentView( + $this->payment_data_payload, + ); $this->isLoading = false; diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index fb75e0c3f35f..516b19cfda2d 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -165,7 +165,7 @@ class CreditCard implements MethodInterface, LivewireMethodInterface return render('gateways.checkout.credit_card.pay', $data); } - public function livewirePaymentView(): string + public function livewirePaymentView(array $data): string { return 'gateways.checkout.credit_card.livewire_pay'; } diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 156d7a7cb0e8..7bbf315a2f49 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -630,8 +630,8 @@ class CheckoutComPaymentDriver extends BaseDriver implements LivewireMethodInter }); } - public function livewirePaymentView(): string + public function livewirePaymentView(array $data): string { - return $this->payment_method->livewirePaymentView(); + return $this->payment_method->livewirePaymentView($data); } } diff --git a/app/PaymentDrivers/Common/LivewireMethodInterface.php b/app/PaymentDrivers/Common/LivewireMethodInterface.php index ef8fa395bf6d..e60f35de1723 100644 --- a/app/PaymentDrivers/Common/LivewireMethodInterface.php +++ b/app/PaymentDrivers/Common/LivewireMethodInterface.php @@ -18,5 +18,5 @@ interface LivewireMethodInterface * * @param array $data */ - public function livewirePaymentView(): string; + public function livewirePaymentView(array $data): string; } diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 2802835bc69e..c759766a5697 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -24,6 +24,7 @@ use App\Models\Payment; use App\Models\PaymentHash; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; use App\Utils\Traits\MakesHash; use Exception; @@ -35,7 +36,7 @@ use Stripe\Exception\InvalidRequestException; use Stripe\Exception\RateLimitException; use Stripe\PaymentIntent; -class ACH +class ACH implements LivewireMethodInterface { use MakesHash; @@ -199,47 +200,7 @@ class ACH */ public function paymentView(array $data) { - $data['gateway'] = $this->stripe; - $data['currency'] = $this->stripe->client->getCurrencyCode(); - $data['payment_method_id'] = GatewayType::BANK_TRANSFER; - $data['customer'] = $this->stripe->findOrCreateCustomer(); - $data['amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - - $description = $this->stripe->getDescription(false); - - $intent = false; - - if (count($data['tokens']) == 1) { - - $token = $data['tokens'][0]; - - $meta = $token->meta; - - if(isset($meta->state) && $meta->state == 'unauthorized') { - return redirect()->route('client.payment_methods.show', $token->hashed_id); - } - } - - if (count($data['tokens']) == 0) { - $intent = - $this->stripe->createPaymentIntent( - [ - 'amount' => $data['amount'], - 'currency' => $data['currency'], - 'setup_future_usage' => 'off_session', - 'customer' => $data['customer']->id, - 'payment_method_types' => ['us_bank_account'], - 'description' => $description, - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::BANK_TRANSFER, - ], - 'statement_descriptor' => $this->stripe->getStatementDescriptor(), - ] - ); - } - - $data['client_secret'] = $intent ? $intent->client_secret : false; + $this->paymentData($data); return render('gateways.stripe.ach.pay', $data); } @@ -628,4 +589,56 @@ class ACH return $this->stripe->processInternallyFailedPayment($this->stripe, $e); } } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.ach.pay_livewire'; + } + + public function paymentData(array $data): array + { + $data['gateway'] = $this->stripe; + $data['currency'] = $this->stripe->client->getCurrencyCode(); + $data['payment_method_id'] = GatewayType::BANK_TRANSFER; + $data['customer'] = $this->stripe->findOrCreateCustomer(); + $data['amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + + $description = $this->stripe->getDescription(false); + + $intent = false; + + if (count($data['tokens']) == 1) { + + $token = $data['tokens'][0]; + + $meta = $token->meta; + + if(isset($meta->state) && $meta->state == 'unauthorized') { + return redirect()->route('client.payment_methods.show', $token->hashed_id); + } + } + + if (count($data['tokens']) == 0) { + $intent = + $this->stripe->createPaymentIntent( + [ + 'amount' => $data['amount'], + 'currency' => $data['currency'], + 'setup_future_usage' => 'off_session', + 'customer' => $data['customer']->id, + 'payment_method_types' => ['us_bank_account'], + 'description' => $description, + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::BANK_TRANSFER, + ], + 'statement_descriptor' => $this->stripe->getStatementDescriptor(), + ] + ); + } + + $data['client_secret'] = $intent ? $intent->client_secret : false; + + return $data; + } } diff --git a/app/PaymentDrivers/Stripe/ACSS.php b/app/PaymentDrivers/Stripe/ACSS.php index 38e3a8162c9e..67d8dda09d6e 100644 --- a/app/PaymentDrivers/Stripe/ACSS.php +++ b/app/PaymentDrivers/Stripe/ACSS.php @@ -17,6 +17,7 @@ use App\Models\SystemLog; use App\Models\GatewayType; use App\Models\PaymentHash; use App\Models\PaymentType; +use App\PaymentDrivers\Common\LivewireMethodInterface; use Illuminate\Support\Str; use App\Http\Requests\Request; use App\Jobs\Util\SystemLogger; @@ -29,7 +30,7 @@ use App\PaymentDrivers\StripePaymentDriver; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use Stripe\PaymentIntent; -class ACSS +class ACSS implements LivewireMethodInterface { use MakesHash; @@ -127,7 +128,7 @@ class ACSS $this->stripe->setClient($hash->fee_invoice->client); $this->stripe->setPaymentMethod(GatewayType::ACSS); - return $this->continuePayment($data); + return $this->paymentView($data); } return redirect()->route('client.payment_methods.show', $client_gateway_token->hashed_id); @@ -161,73 +162,43 @@ class ACSS return $intent; } - /** - * Payment view for ACSS - * - * Determines if any payment tokens are available and if not, generates a mandate - * - * @param array $data - - */ - public function paymentView(array $data) + public function paymentData(array $data) { - if(count($data['tokens']) == 0) { $hash = Str::random(32); + Cache::put($hash, $data, 3600); + $data['post_auth_response'] = $hash; + $data['needs_mandate_generate'] = true; - return $this->generateMandate($data); + $data['gateway'] = $this->stripe; + $data['company_gateway'] = $this->stripe->company_gateway; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\SetupIntent::create([ + 'usage' => 'off_session', + 'payment_method_types' => ['acss_debit'], + 'customer' => $data['customer'], + 'payment_method_options' => [ + 'acss_debit' => [ + 'currency' => 'cad', + 'mandate_options' => [ + 'payment_schedule' => 'combined', + 'interval_description' => 'On any invoice due date', + 'transaction_type' => 'personal', + ], + 'verification_method' => 'instant', + ], + ], + ], $this->stripe->stripe_connect_auth); + + $data['pi_client_secret'] = $intent->client_secret; + + return $data; } - return $this->continuePayment($data); - } - - /** - * Generate a payment Mandate for ACSS - * - * @param array $data - - */ - private function generateMandate(array $data) - { - - $data['gateway'] = $this->stripe; - $data['company_gateway'] = $this->stripe->company_gateway; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\SetupIntent::create([ - 'usage' => 'off_session', - 'payment_method_types' => ['acss_debit'], - 'customer' => $data['customer'], - 'payment_method_options' => [ - 'acss_debit' => [ - 'currency' => 'cad', - 'mandate_options' => [ - 'payment_schedule' => 'combined', - 'interval_description' => 'On any invoice due date', - 'transaction_type' => 'personal', - ], - 'verification_method' => 'instant', - ], - ], - ], $this->stripe->stripe_connect_auth); - - $data['pi_client_secret'] = $intent->client_secret; - - return render('gateways.stripe.acss.authorize', array_merge($data)); - - } - - /** - * Continues the payment flow after a Mandate has been successfully generated - * - * @param array $data - */ - private function continuePayment(array $data) - { - $this->stripe->init(); $data['gateway'] = $this->stripe; @@ -240,6 +211,25 @@ class ACSS $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); $this->stripe->payment_hash->save(); + return $data; + } + + /** + * Payment view for ACSS + * + * Determines if any payment tokens are available and if not, generates a mandate + * + * @param array $data + + */ + public function paymentView(array $data) + { + $data = $this->paymentData($data); + + if (array_key_exists('needs_mandate_generate', $data)) { + return render('gateways.stripe.acss.authorize', array_merge($data)); + } + return render('gateways.stripe.acss.pay', $data); } @@ -399,4 +389,13 @@ class ACSS return $this->stripe->processInternallyFailedPayment($this->stripe, $e); } } + + public function livewirePaymentView(array $data): string + { + if (array_key_exists('needs_mandate_generate', $data)) { + return 'gateways.stripe.acss.authorize_livewire'; + } + + return 'gateways.stripe.acss.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/BACS.php b/app/PaymentDrivers/Stripe/BACS.php index 84ce704a8990..a028a311a4af 100644 --- a/app/PaymentDrivers/Stripe/BACS.php +++ b/app/PaymentDrivers/Stripe/BACS.php @@ -20,12 +20,13 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\Stripe\Jobs\UpdateCustomer; use App\PaymentDrivers\StripePaymentDriver; use App\Utils\Number; use Stripe\Checkout\Session; -class BACS +class BACS implements LivewireMethodInterface { public $stripe; @@ -69,9 +70,7 @@ class BACS } public function paymentView(array $data) { - $data['gateway'] = $this->stripe; - $data['amount'] = $data['total']['amount_with_fee']; - $data['payment_hash'] = $this->stripe->payment_hash->hash; + $data = $this->paymentData($data); return render('gateways.stripe.bacs.pay', $data); } @@ -187,4 +186,18 @@ class BACS return $this->stripe->processInternallyFailedPayment($this->stripe, $e); } } + + public function paymentData(array $data): array + { + $data['gateway'] = $this->stripe; + $data['amount'] = $data['total']['amount_with_fee']; + $data['payment_hash'] = $this->stripe->payment_hash->hash; + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.bacs.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/BECS.php b/app/PaymentDrivers/Stripe/BECS.php index 271e6170f481..020d9493d506 100644 --- a/app/PaymentDrivers/Stripe/BECS.php +++ b/app/PaymentDrivers/Stripe/BECS.php @@ -19,9 +19,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class BECS +class BECS implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -39,33 +40,7 @@ class BECS public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['payment_method_id'] = GatewayType::BECS; - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - $data['payment_hash'] = $this->stripe->payment_hash->hash; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => $this->stripe->client->currency()->code, - 'payment_method_types' => ['au_becs_debit'], - 'setup_future_usage' => 'off_session', - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::BECS, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.becs.pay', $data); } @@ -161,4 +136,42 @@ class BECS return $this->stripe->processInternallyFailedPayment($this->stripe, $e); } } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['payment_method_id'] = GatewayType::BECS; + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + $data['payment_hash'] = $this->stripe->payment_hash->hash; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => $this->stripe->client->currency()->code, + 'payment_method_types' => ['au_becs_debit'], + 'setup_future_usage' => 'off_session', + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::BECS, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.becs.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/Bancontact.php b/app/PaymentDrivers/Stripe/Bancontact.php index a4b0d61fd095..352db6bc1cbc 100644 --- a/app/PaymentDrivers/Stripe/Bancontact.php +++ b/app/PaymentDrivers/Stripe/Bancontact.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class Bancontact +class Bancontact implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,32 +38,7 @@ class Bancontact public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['bancontact'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::BANCONTACT, - ], - - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.bancontact.pay', $data); } @@ -143,4 +119,41 @@ class Bancontact throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['bancontact'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::BANCONTACT, + ], + + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.bancontact.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/BankTransfer.php b/app/PaymentDrivers/Stripe/BankTransfer.php index 4f7a1bac4392..51a6e8e59c3f 100644 --- a/app/PaymentDrivers/Stripe/BankTransfer.php +++ b/app/PaymentDrivers/Stripe/BankTransfer.php @@ -19,12 +19,13 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; use App\Utils\Number; use App\Utils\Traits\MakesHash; use Stripe\PaymentIntent; -class BankTransfer +class BankTransfer implements LivewireMethodInterface { use MakesHash; @@ -38,37 +39,7 @@ class BankTransfer public function paymentView(array $data) { - $this->stripe->init(); - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - 'currency' => $this->stripe->client->currency()->code, - 'customer' => $this->stripe->findOrCreateCustomer()->id, - 'description' => $this->stripe->getDescription(false), - 'payment_method_types' => ['customer_balance'], - 'payment_method_data' => [ - 'type' => 'customer_balance', - ], - 'payment_method_options' => [ - 'customer_balance' => [ - 'funding_type' => 'bank_transfer', - 'bank_transfer' => $this->resolveBankType() - ], - ], - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::DIRECT_DEBIT, - ], - ], $this->stripe->stripe_connect_auth); - - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency())]); - $this->stripe->payment_hash->save(); - - $data = []; - $data['return_url'] = $this->buildReturnUrl(); - $data['gateway'] = $this->stripe; - $data['client_secret'] = $intent ? $intent->client_secret : false; + $data = $this->paymentData($data); return render('gateways.stripe.bank_transfer.pay', $data); } @@ -317,4 +288,46 @@ class BankTransfer throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), + 'currency' => $this->stripe->client->currency()->code, + 'customer' => $this->stripe->findOrCreateCustomer()->id, + 'description' => $this->stripe->getDescription(false), + 'payment_method_types' => ['customer_balance'], + 'payment_method_data' => [ + 'type' => 'customer_balance', + ], + 'payment_method_options' => [ + 'customer_balance' => [ + 'funding_type' => 'bank_transfer', + 'bank_transfer' => $this->resolveBankType() + ], + ], + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::DIRECT_DEBIT, + ], + ], $this->stripe->stripe_connect_auth); + + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency())]); + $this->stripe->payment_hash->save(); + + $data = []; + $data['return_url'] = $this->buildReturnUrl(); + $data['gateway'] = $this->stripe; + $data['client_secret'] = $intent ? $intent->client_secret : false; + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.bank_transfer.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 4358f4614a2a..e26c88ad04be 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -240,10 +240,8 @@ class BrowserPay implements MethodInterface, LivewireMethodInterface return str_replace(['https://', '/public'], '', $domain); } - /** - * @inheritDoc - */ - public function livewirePaymentView(): string + + public function livewirePaymentView(array $data): string { return 'gateways.stripe.browser_pay.pay_livewire'; } diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index b40ddc1051ab..2c9154ae81ba 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -88,7 +88,7 @@ class CreditCard implements LivewireMethodInterface return render('gateways.stripe.credit_card.pay', $data); } - public function livewirePaymentView(): string + public function livewirePaymentView(array $data): string { return 'gateways.stripe.credit_card.pay_livewire'; } diff --git a/app/PaymentDrivers/Stripe/EPS.php b/app/PaymentDrivers/Stripe/EPS.php index 8f1456fcebb0..98b23fdc2b9f 100644 --- a/app/PaymentDrivers/Stripe/EPS.php +++ b/app/PaymentDrivers/Stripe/EPS.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class EPS +class EPS implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,31 +38,7 @@ class EPS public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['eps'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::EPS, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.eps.pay', $data); } @@ -142,4 +119,40 @@ class EPS throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['eps'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::EPS, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.eps.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/FPX.php b/app/PaymentDrivers/Stripe/FPX.php index e97b25562c13..a7cfe5d52158 100644 --- a/app/PaymentDrivers/Stripe/FPX.php +++ b/app/PaymentDrivers/Stripe/FPX.php @@ -19,9 +19,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class FPX +class FPX implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -38,31 +39,7 @@ class FPX public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => $this->stripe->client->getCurrencyCode(), - 'payment_method_types' => ['fpx'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::FPX, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.fpx.pay', $data); } @@ -143,4 +120,40 @@ class FPX throw new PaymentFailed('Failed to process the payment.', 400); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => $this->stripe->client->getCurrencyCode(), + 'payment_method_types' => ['fpx'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::FPX, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.fpx.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/GIROPAY.php b/app/PaymentDrivers/Stripe/GIROPAY.php index cd8828bfb4ea..2a90cd0e7eb4 100644 --- a/app/PaymentDrivers/Stripe/GIROPAY.php +++ b/app/PaymentDrivers/Stripe/GIROPAY.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class GIROPAY +class GIROPAY implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,31 +38,7 @@ class GIROPAY public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['giropay'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::GIROPAY, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.giropay.pay', $data); } @@ -142,4 +119,40 @@ class GIROPAY throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['giropay'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::GIROPAY, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.giropay.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/Klarna.php b/app/PaymentDrivers/Stripe/Klarna.php index 09169e4f16a1..47544d21e20d 100644 --- a/app/PaymentDrivers/Stripe/Klarna.php +++ b/app/PaymentDrivers/Stripe/Klarna.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class Klarna +class Klarna implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,33 +38,7 @@ class Klarna public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $description = $this->stripe->getDescription(false); - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => $this->stripe->client->getCurrencyCode(), - 'payment_method_types' => ['klarna'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $description, - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::KLARNA, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.klarna.pay', $data); } @@ -142,4 +117,42 @@ class Klarna throw new PaymentFailed(ctrans('texts.gateway_error'), 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $description = $this->stripe->getDescription(false); + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => $this->stripe->client->getCurrencyCode(), + 'payment_method_types' => ['klarna'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $description, + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::KLARNA, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.klarna.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/PRZELEWY24.php b/app/PaymentDrivers/Stripe/PRZELEWY24.php index ce9bb79405ed..d0422bc167ca 100644 --- a/app/PaymentDrivers/Stripe/PRZELEWY24.php +++ b/app/PaymentDrivers/Stripe/PRZELEWY24.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class PRZELEWY24 +class PRZELEWY24 implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,31 +38,7 @@ class PRZELEWY24 public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['p24'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::PRZELEWY24, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.przelewy24.pay', $data); } @@ -142,4 +119,40 @@ class PRZELEWY24 throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['p24'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::PRZELEWY24, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.przelewy24.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index 79f98e9f6239..e633a06403e4 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -19,9 +19,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class SEPA +class SEPA implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -47,33 +48,7 @@ class SEPA public function paymentView(array $data) { - $data['gateway'] = $this->stripe; - $data['payment_method_id'] = GatewayType::SEPA; - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - $data['payment_hash'] = $this->stripe->payment_hash->hash; - - $intent_data = [ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['sepa_debit'], - 'setup_future_usage' => 'off_session', - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::SEPA, - ], - ]; - - $intent = \Stripe\PaymentIntent::create($intent_data, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.sepa.pay', $data); } @@ -176,4 +151,42 @@ class SEPA return $this->stripe->processInternallyFailedPayment($this->stripe, $e); } } + + public function paymentData(array $data): array + { + $data['gateway'] = $this->stripe; + $data['payment_method_id'] = GatewayType::SEPA; + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + $data['payment_hash'] = $this->stripe->payment_hash->hash; + + $intent_data = [ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['sepa_debit'], + 'setup_future_usage' => 'off_session', + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::SEPA, + ], + ]; + + $intent = \Stripe\PaymentIntent::create($intent_data, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.sepa.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/SOFORT.php b/app/PaymentDrivers/Stripe/SOFORT.php index 4a7faef870c0..1aa7d95ed89b 100644 --- a/app/PaymentDrivers/Stripe/SOFORT.php +++ b/app/PaymentDrivers/Stripe/SOFORT.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class SOFORT +class SOFORT implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,31 +38,7 @@ class SOFORT public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['sofort'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::SOFORT, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.sofort.pay', $data); } @@ -137,4 +114,40 @@ class SOFORT throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['sofort'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::SOFORT, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.sofort.pay_livewire'; + } } diff --git a/app/PaymentDrivers/Stripe/iDeal.php b/app/PaymentDrivers/Stripe/iDeal.php index 01b346b7801d..00d738c020d6 100644 --- a/app/PaymentDrivers/Stripe/iDeal.php +++ b/app/PaymentDrivers/Stripe/iDeal.php @@ -18,9 +18,10 @@ use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\StripePaymentDriver; -class iDeal +class iDeal implements LivewireMethodInterface { /** @var StripePaymentDriver */ public StripePaymentDriver $stripe; @@ -37,31 +38,7 @@ class iDeal public function paymentView(array $data) { - $this->stripe->init(); - - $data['gateway'] = $this->stripe; - $data['return_url'] = $this->buildReturnUrl(); - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['ideal'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::IDEAL, - ], - ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); + $data = $this->paymentData($data); return render('gateways.stripe.ideal.pay', $data); } @@ -142,4 +119,40 @@ class iDeal throw new PaymentFailed('Failed to process the payment.', 500); } + + public function paymentData(array $data): array + { + $this->stripe->init(); + + $data['gateway'] = $this->stripe; + $data['return_url'] = $this->buildReturnUrl(); + $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); + $data['client'] = $this->stripe->client; + $data['customer'] = $this->stripe->findOrCreateCustomer()->id; + $data['country'] = $this->stripe->client->country->iso_3166_2; + + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $data['stripe_amount'], + 'currency' => 'eur', + 'payment_method_types' => ['ideal'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::IDEAL, + ], + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)])); + + $data['pi_client_secret'] = $intent->client_secret; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); + $this->stripe->payment_hash->save(); + + return $data; + } + + public function livewirePaymentView(array $data): string + { + return 'gateways.stripe.ideal.pay_livewire'; + } } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 42869afba180..5b9b1acbfb97 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -1042,8 +1042,8 @@ class StripePaymentDriver extends BaseDriver implements LivewireMethodInterface } - public function livewirePaymentView(): string + public function livewirePaymentView(array $data): string { - return $this->payment_method->livewirePaymentView(); + return $this->payment_method->livewirePaymentView($data); } } diff --git a/public/build/assets/authorize-stripe-acss-f6bd46c1.js b/public/build/assets/authorize-stripe-acss-f6bd46c1.js new file mode 100644 index 000000000000..34c2126d897c --- /dev/null +++ b/public/build/assets/authorize-stripe-acss-f6bd46c1.js @@ -0,0 +1,9 @@ +import{w as y}from"./wait-8f4ae121.js";/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */y("#stripe-acss-authorize").then(()=>f());function f(){var i,l,o;let n;const a=(i=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:i.content,r=(l=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:l.content;a&&a.length>0?n=Stripe(r,{stripeAccount:a}):n=Stripe(r);const c=document.getElementById("acss-name"),s=document.getElementById("acss-email-address"),t=document.getElementById("authorize-acss"),d=(o=document.querySelector('meta[name="stripe-pi-client-secret"]'))==null?void 0:o.content,e=document.getElementById("errors");t.addEventListener("click",async u=>{u.preventDefault(),e.hidden=!0,t.disabled=!0;const m=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;if(s.value.length<3||!s.value.match(m)){e.textContent="Please enter a valid email address.",e.hidden=!1,t.disabled=!1;return}if(c.value.length<3){e.textContent="Please enter a name for the account holder.",e.hidden=!1,t.disabled=!1;return}const{setupIntent:p,error:h}=await n.confirmAcssDebitSetup(d,{payment_method:{billing_details:{name:c.value,email:s.value}}});document.getElementById("gateway_response").value=JSON.stringify(p??h),document.getElementById("server_response").submit()})} diff --git a/public/build/assets/checkout-credit-card-ba005c24.js b/public/build/assets/checkout-credit-card-eba516f2.js similarity index 98% rename from public/build/assets/checkout-credit-card-ba005c24.js rename to public/build/assets/checkout-credit-card-eba516f2.js index 0b28ba71e3e1..c11da286bd27 100644 --- a/public/build/assets/checkout-credit-card-ba005c24.js +++ b/public/build/assets/checkout-credit-card-eba516f2.js @@ -1,4 +1,4 @@ -import{w as o}from"./wait-d71d9fed.js";/** +import{w as o}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository diff --git a/public/build/assets/stripe-ach-pay-22d14901.js b/public/build/assets/stripe-ach-pay-22d14901.js new file mode 100644 index 000000000000..afc3ee0a621e --- /dev/null +++ b/public/build/assets/stripe-ach-pay-22d14901.js @@ -0,0 +1,9 @@ +import{w as g}from"./wait-8f4ae121.js";/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */g("#stripe-ach-payment").then(()=>f());function f(){let d=document.getElementById("pay-now");d&&(Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(e=>e.addEventListener("click",n=>{document.querySelector("input[name=source]").value=n.target.dataset.token})),d.addEventListener("click",function(){let e=document.getElementById("pay-now");e.disabled=!0,e.querySelector("svg").classList.remove("hidden"),e.querySelector("span").classList.add("hidden"),document.getElementById("server-response").submit()})),document.getElementById("new-bank").addEventListener("click",e=>{var m,y;if(!document.getElementById("accept-terms").checked){errors.textContent="You must accept the mandate terms prior to making payment.",errors.hidden=!1;return}errors.hidden=!0;let n,t=document.querySelector('meta[name="stripe-publishable-key"]').content,o=(m=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:m.content;o?n=Stripe(t,{stripeAccount:o}):n=Stripe(t);let s=document.getElementById("new-bank");s.disabled=!0,s.querySelector("svg").classList.remove("hidden"),s.querySelector("span").classList.add("hidden"),e.preventDefault();const c=document.getElementById("account-holder-name-field"),r=document.getElementById("email-field"),u=(y=document.querySelector('meta[name="client_secret"]'))==null?void 0:y.content;n.collectBankAccountForPayment({clientSecret:u,params:{payment_method_type:"us_bank_account",payment_method_data:{billing_details:{name:c.value,email:r.value}}},expand:["payment_method"]}).then(({paymentIntent:i,error:l})=>{if(l)console.error(l.message),errors.textContent=l.message,errors.hidden=!1,a();else if(i.status==="requires_payment_method"){errors.textContent="We were unable to process the payment with this account, please try another one.",errors.hidden=!1,a();return}else if(i.status==="requires_confirmation"){let h=document.getElementById("bank_account_response");h.value=JSON.stringify(i),p(n,u)}a()})});function p(e,n){e.confirmUsBankAccountPayment(n).then(({paymentIntent:t,error:o})=>{var s,c;if(console.log(t),o)console.error(o.message);else if(t.status==="requires_payment_method")errors.textContent="We were unable to process the payment with this account, please try another one.",errors.hidden=!1,a();else if(t.status==="processing"){let r=document.getElementById("gateway_response");r.value=JSON.stringify(t),document.getElementById("server-response").submit()}else if(((s=t.next_action)==null?void 0:s.type)==="verify_with_microdeposits"||((c=t.next_action)==null?void 0:c.type)==="requires_source_action"){errors.textContent="You will receive an email with details on how to verify your bank account and process payment.",errors.hidden=!1,document.getElementById("new-bank").style.visibility="hidden";let r=document.getElementById("gateway_response");r.value=JSON.stringify(t),document.getElementById("server-response").submit()}})}function a(){let e=document.getElementById("new-bank");e.disabled=!1,e.querySelector("svg").classList.add("hidden"),e.querySelector("span").classList.remove("hidden")}} diff --git a/public/build/assets/stripe-acss-946fe54a.js b/public/build/assets/stripe-acss-1184fda8.js similarity index 72% rename from public/build/assets/stripe-acss-946fe54a.js rename to public/build/assets/stripe-acss-1184fda8.js index 8b12e28c4d42..be35b4d809df 100644 --- a/public/build/assets/stripe-acss-946fe54a.js +++ b/public/build/assets/stripe-acss-1184fda8.js @@ -1,4 +1,4 @@ -var c=Object.defineProperty;var i=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(i(n,typeof e!="symbol"?e+"":e,t),t);/** +var d=Object.defineProperty;var c=(o,e,t)=>e in o?d(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var a=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{i,w as l}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var c=Object.defineProperty;var i=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class l{constructor(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(e=>e.addEventListener("click",t=>{document.querySelector("input[name=token]").value=t.target.dataset.token,console.log(t.target.dataset.token)})),document.getElementById("toggle-payment-with-new-account")&&document.getElementById("toggle-payment-with-new-account").addEventListener("click",e=>{document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value=""}),document.getElementById("pay-now-with-token")?document.getElementById("pay-now-with-token").addEventListener("click",e=>{document.querySelector("input[name=token]").value,document.getElementById("pay-now-with-token").disabled=!0,document.querySelector("#pay-now-with-token > svg").classList.remove("hidden"),document.querySelector("#pay-now-with-token > span").classList.add("hidden"),document.getElementById("server-response").submit()}):document.getElementById("pay-now").addEventListener("click",e=>{let t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value);let o=document.getElementById("errors");if(o.textContent="",o.hidden=!0,document.getElementById("acss-name").value===""){document.getElementById("acss-name").focus(),o.textContent=document.querySelector("meta[name=translation-name-required]").content,o.hidden=!1;return}if(document.getElementById("acss-email-address").value===""){document.getElementById("acss-email-address").focus(),o.textContent=document.querySelector("meta[name=translation-email-required]").content,o.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmAcssDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("acss-name").value,email:document.getElementById("acss-email-address").value}}}).then(s=>s.error?this.handleFailure(s.error.message):this.handleSuccess(s))})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}handleSuccess(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit()}handleFailure(e){let t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}var a;const m=((a=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:a.content)??"";var d;const u=((d=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:d.content)??"";new l(m,u).setupStripe().handle(); + */class m{constructor(e,t){a(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));a(this,"handle",()=>{Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(e=>e.addEventListener("click",t=>{document.querySelector("input[name=token]").value=t.target.dataset.token,console.log(t.target.dataset.token)})),document.getElementById("toggle-payment-with-new-account")&&document.getElementById("toggle-payment-with-new-account").addEventListener("click",e=>{document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value=""}),document.getElementById("pay-now-with-token")?document.getElementById("pay-now-with-token").addEventListener("click",e=>{document.querySelector("input[name=token]").value,document.getElementById("pay-now-with-token").disabled=!0,document.querySelector("#pay-now-with-token > svg").classList.remove("hidden"),document.querySelector("#pay-now-with-token > span").classList.add("hidden"),document.getElementById("server-response").submit()}):document.getElementById("pay-now").addEventListener("click",e=>{let t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value);let n=document.getElementById("errors");if(n.textContent="",n.hidden=!0,document.getElementById("acss-name").value===""){document.getElementById("acss-name").focus(),n.textContent=document.querySelector("meta[name=translation-name-required]").content,n.hidden=!1;return}if(document.getElementById("acss-email-address").value===""){document.getElementById("acss-email-address").focus(),n.textContent=document.querySelector("meta[name=translation-email-required]").content,n.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmAcssDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("acss-name").value,email:document.getElementById("acss-email-address").value}}}).then(s=>s.error?this.handleFailure(s.error.message):this.handleSuccess(s))})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}handleSuccess(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit()}handleFailure(e){let t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}function r(){var t,n;const o=((t=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:t.content)??"",e=((n=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:n.content)??"";new m(o,e).setupStripe().handle()}i()?r():l("#stripe-acss-payment").then(()=>r()); diff --git a/public/build/assets/stripe-bacs-38c8b975.js b/public/build/assets/stripe-bacs-e1cfee99.js similarity index 76% rename from public/build/assets/stripe-bacs-38c8b975.js rename to public/build/assets/stripe-bacs-e1cfee99.js index d71314edc9a3..b4d5cef67f0a 100644 --- a/public/build/assets/stripe-bacs-38c8b975.js +++ b/public/build/assets/stripe-bacs-e1cfee99.js @@ -1,4 +1,4 @@ -var a=Object.defineProperty;var c=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var s=(n,e,t)=>(c(n,typeof e!="symbol"?e+"":e,t),t);/** +var i=Object.defineProperty;var a=(n,e,t)=>e in n?i(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var s=(n,e,t)=>(a(n,typeof e!="symbol"?e+"":e,t),t);import{w as c}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var a=Object.defineProperty;var c=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class d{constructor(e,t){s(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));s(this,"payment_data");s(this,"handle",()=>{this.onlyAuthorization?document.getElementById("authorize-bacs").addEventListener("click",e=>{document.getElementById("authorize-bacs").disabled=!0,document.querySelector("#authorize-bacs > svg").classList.remove("hidden"),document.querySelector("#authorize-bacs > span").classList.add("hidden"),location.href=document.querySelector("meta[name=stripe-redirect-url]").content}):(this.payNowButton=document.getElementById("pay-now"),document.getElementById("pay-now").addEventListener("click",e=>{this.payNowButton.disabled=!0,this.payNowButton.querySelector("svg").classList.remove("hidden"),this.payNowButton.querySelector("span").classList.add("hidden"),document.getElementById("server-response").submit()}),this.payment_data=Array.from(document.getElementsByClassName("toggle-payment-with-token")),this.payment_data.length>0?this.payment_data.forEach(e=>e.addEventListener("click",t=>{document.querySelector("input[name=token]").value=t.target.dataset.token})):(this.errors.textContent=document.querySelector("meta[name=translation-payment-method-required]").content,this.errors.hidden=!1,this.payNowButton.disabled=!0,this.payNowButton.querySelector("span").classList.remove("hidden"),this.payNowButton.querySelector("svg").classList.add("hidden")))});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t,this.onlyAuthorization=h}}var o;const u=((o=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:o.content)??"";var r;const l=((r=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:r.content)??"";var i;const h=((i=document.querySelector('meta[name="only-authorization"]'))==null?void 0:i.content)??"";new d(u,l).setupStripe().handle(); + */class d{constructor(e,t){s(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));s(this,"payment_data");s(this,"handle",()=>{this.onlyAuthorization?document.getElementById("authorize-bacs").addEventListener("click",e=>{document.getElementById("authorize-bacs").disabled=!0,document.querySelector("#authorize-bacs > svg").classList.remove("hidden"),document.querySelector("#authorize-bacs > span").classList.add("hidden"),location.href=document.querySelector("meta[name=stripe-redirect-url]").content}):(this.payNowButton=document.getElementById("pay-now"),document.getElementById("pay-now").addEventListener("click",e=>{this.payNowButton.disabled=!0,this.payNowButton.querySelector("svg").classList.remove("hidden"),this.payNowButton.querySelector("span").classList.add("hidden"),document.getElementById("server-response").submit()}),this.payment_data=Array.from(document.getElementsByClassName("toggle-payment-with-token")),this.payment_data.length>0?this.payment_data.forEach(e=>e.addEventListener("click",t=>{document.querySelector("input[name=token]").value=t.target.dataset.token})):(this.errors.textContent=document.querySelector("meta[name=translation-payment-method-required]").content,this.errors.hidden=!1,this.payNowButton.disabled=!0,this.payNowButton.querySelector("span").classList.remove("hidden"),this.payNowButton.querySelector("svg").classList.add("hidden")))});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t,this.onlyAuthorization=onlyAuthorization}}c("#stripe-bacs-payment").then(()=>{var t,o,r;const n=((t=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:t.content)??"",e=((o=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:o.content)??"";(r=document.querySelector('meta[name="only-authorization"]'))==null||r.content,new d(n,e).setupStripe().handle()}); diff --git a/public/build/assets/stripe-bancontact-743204e1.js b/public/build/assets/stripe-bancontact-743204e1.js new file mode 100644 index 000000000000..13347096a6c3 --- /dev/null +++ b/public/build/assets/stripe-bancontact-743204e1.js @@ -0,0 +1,9 @@ +var c=Object.defineProperty;var s=(n,t,e)=>t in n?c(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>(s(n,typeof t!="symbol"?t+"":t,e),e);import{w as a}from"./wait-8f4ae121.js";/** + * 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://www.elastic.co/licensing/elastic-license + */class i{constructor(t,e){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(!document.getElementById("bancontact-name").value){e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1,console.log("name");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmBancontactPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("bancontact-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}}a("#stripe-bancontact-payment").then(()=>{var e,o;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((o=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:o.content)??"";new i(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-bancontact-cb004d43.js b/public/build/assets/stripe-bancontact-cb004d43.js deleted file mode 100644 index 5545f86111b7..000000000000 --- a/public/build/assets/stripe-bancontact-cb004d43.js +++ /dev/null @@ -1,9 +0,0 @@ -var s=Object.defineProperty;var a=(n,e,t)=>e in n?s(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(a(n,typeof e!="symbol"?e+"":e,t),t);/** - * 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://www.elastic.co/licensing/elastic-license - */class i{constructor(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("bancontact-name").value){t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,console.log("name");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmBancontactPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("bancontact-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var o;const m=((o=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:o.content)??"";var c;const l=((c=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:c.content)??"";new i(m,l).setupStripe().handle(); diff --git a/public/build/assets/stripe-bank-transfer-801a4de6.js b/public/build/assets/stripe-bank-transfer-801a4de6.js new file mode 100644 index 000000000000..7ab3e60f09e6 --- /dev/null +++ b/public/build/assets/stripe-bank-transfer-801a4de6.js @@ -0,0 +1,9 @@ +import{w as u}from"./wait-8f4ae121.js";/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */u("#stripe-bank-transfer-payment").then(()=>p());function p(){var r,o,s;const c=(r=document.querySelector('meta[name="stripe-client-secret"]'))==null?void 0:r.content,m=(o=document.querySelector('meta[name="stripe-return-url"]'))==null?void 0:o.content,i={clientSecret:c,appearance:{theme:"stripe",variables:{colorPrimary:"#0570de",colorBackground:"#ffffff",colorText:"#30313d",colorDanger:"#df1b41",fontFamily:"Ideal Sans, system-ui, sans-serif",spacingUnit:"2px",borderRadius:"4px"}}},e=Stripe(document.querySelector('meta[name="stripe-publishable-key"]').getAttribute("content")),t=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";t&&(e.stripeAccount=t);const n=e.elements(i);n.create("payment").mount("#payment-element"),document.getElementById("payment-form").addEventListener("submit",async d=>{d.preventDefault(),document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden");const{error:a}=await e.confirmPayment({elements:n,confirmParams:{return_url:m}});if(a){document.getElementById("pay-now").disabled=!1,document.querySelector("svg").classList.remove("hidden"),document.querySelector("span").classList.add("hidden");const l=document.querySelector("#errors");l.textContent=a.message}})} diff --git a/public/build/assets/stripe-becs-4d1494ed.js b/public/build/assets/stripe-becs-ce05fb09.js similarity index 83% rename from public/build/assets/stripe-becs-4d1494ed.js rename to public/build/assets/stripe-becs-ce05fb09.js index 9dede5b9728a..d930c4350b9e 100644 --- a/public/build/assets/stripe-becs-4d1494ed.js +++ b/public/build/assets/stripe-becs-ce05fb09.js @@ -1,4 +1,4 @@ -var r=Object.defineProperty;var d=(n,t,e)=>t in n?r(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>(d(n,typeof t!="symbol"?t+"":t,e),e);/** +var a=Object.defineProperty;var c=(n,t,e)=>t in n?a(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>(c(n,typeof t!="symbol"?t+"":t,e),e);import{w as r}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var r=Object.defineProperty;var d=(n,t,e)=>t in n?r(n,t,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class i{constructor(t,e){o(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);const t=this.stripe.elements(),s={style:{base:{color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"},":-webkit-autofill":{color:"#32325d"}},invalid:{color:"#fa755a",iconColor:"#fa755a",":-webkit-autofill":{color:"#fa755a"}}},disabled:!1,hideIcon:!1,iconStyle:"default"};return this.auBankAccount=t.create("auBankAccount",s),this.auBankAccount.mount("#becs-iban"),this});o(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(document.getElementById("becs-name").value===""){document.getElementById("becs-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}if(document.getElementById("becs-email-address").value===""){document.getElementById("becs-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,e.hidden=!1;return}if(!document.getElementById("becs-mandate-acceptance").checked){document.getElementById("becs-mandate-acceptance").focus(),e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1,console.log("Terms");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmAuBecsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{au_becs_debit:this.auBankAccount,billing_details:{name:document.getElementById("becs-name").value,email:document.getElementById("becs-email-address").value}}}).then(s=>s.error?this.handleFailure(s.error.message):this.handleSuccess(s))})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}handleSuccess(t){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(t.paymentIntent),document.getElementById("server-response").submit()}handleFailure(t){let e=document.getElementById("errors");e.textContent="",e.textContent=t,e.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}var a;const l=((a=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:a.content)??"";var c;const m=((c=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:c.content)??"";new i(l,m).setupStripe().handle(); + */class d{constructor(t,e){o(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);const t=this.stripe.elements(),s={style:{base:{color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"},":-webkit-autofill":{color:"#32325d"}},invalid:{color:"#fa755a",iconColor:"#fa755a",":-webkit-autofill":{color:"#fa755a"}}},disabled:!1,hideIcon:!1,iconStyle:"default"};return this.auBankAccount=t.create("auBankAccount",s),this.auBankAccount.mount("#becs-iban"),this});o(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(document.getElementById("becs-name").value===""){document.getElementById("becs-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}if(document.getElementById("becs-email-address").value===""){document.getElementById("becs-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,e.hidden=!1;return}if(!document.getElementById("becs-mandate-acceptance").checked){document.getElementById("becs-mandate-acceptance").focus(),e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1,console.log("Terms");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmAuBecsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{au_becs_debit:this.auBankAccount,billing_details:{name:document.getElementById("becs-name").value,email:document.getElementById("becs-email-address").value}}}).then(s=>s.error?this.handleFailure(s.error.message):this.handleSuccess(s))})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}handleSuccess(t){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(t.paymentIntent),document.getElementById("server-response").submit()}handleFailure(t){let e=document.getElementById("errors");e.textContent="",e.textContent=t,e.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}r("#stripe-becs-payment").then(()=>{var e,s;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new d(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-browserpay-ac78fb26.js b/public/build/assets/stripe-browserpay-813e625e.js similarity index 92% rename from public/build/assets/stripe-browserpay-ac78fb26.js rename to public/build/assets/stripe-browserpay-813e625e.js index 5433bd793132..b13f13db8292 100644 --- a/public/build/assets/stripe-browserpay-ac78fb26.js +++ b/public/build/assets/stripe-browserpay-813e625e.js @@ -1,4 +1,4 @@ -/** +import{w as a}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class a{constructor(){var e;this.clientSecret=(e=document.querySelector("meta[name=stripe-pi-client-secret]"))==null?void 0:e.content}init(){var t,n;let e={};return document.querySelector("meta[name=stripe-account-id]")&&(e.apiVersion="2020-08-27",e.stripeAccount=(t=document.querySelector("meta[name=stripe-account-id]"))==null?void 0:t.content),this.stripe=Stripe((n=document.querySelector("meta[name=stripe-publishable-key]"))==null?void 0:n.content,e),this.elements=this.stripe.elements(),this}createPaymentRequest(){return this.paymentRequest=this.stripe.paymentRequest(JSON.parse(document.querySelector("meta[name=payment-request-data").content)),this}createPaymentRequestButton(){this.paymentRequestButton=this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest})}handlePaymentRequestEvents(e,t){document.querySelector("#errors").hidden=!0,this.paymentRequest.on("paymentmethod",function(n){e.confirmCardPayment(t,{payment_method:n.paymentMethod.id},{handleActions:!1}).then(function(r){r.error?(document.querySelector("#errors").innerText=r.error.message,document.querySelector("#errors").hidden=!1,n.complete("fail")):(n.complete("success"),r.paymentIntent.status==="requires_action"?e.confirmCardPayment(t).then(function(s){s.error?(n.complete("fail"),document.querySelector("#errors").innerText=s.error.message,document.querySelector("#errors").hidden=!1):(document.querySelector('input[name="gateway_response"]').value=JSON.stringify(s.paymentIntent),document.getElementById("server-response").submit())}):(document.querySelector('input[name="gateway_response"]').value=JSON.stringify(r.paymentIntent),document.getElementById("server-response").submit()))})})}handle(){this.init().createPaymentRequest().createPaymentRequestButton(),this.paymentRequest.canMakePayment().then(e=>{var t;if(e)return this.paymentRequestButton.mount("#payment-request-button");document.querySelector("#errors").innerHTML=JSON.parse((t=document.querySelector("meta[name=no-available-methods]"))==null?void 0:t.content),document.querySelector("#errors").hidden=!1}),this.handlePaymentRequestEvents(this.stripe,this.clientSecret)}}new a().handle(); + */class o{constructor(){var e;this.clientSecret=(e=document.querySelector("meta[name=stripe-pi-client-secret]"))==null?void 0:e.content}init(){var t,n;let e={};return document.querySelector("meta[name=stripe-account-id]")&&(e.apiVersion="2020-08-27",e.stripeAccount=(t=document.querySelector("meta[name=stripe-account-id]"))==null?void 0:t.content),this.stripe=Stripe((n=document.querySelector("meta[name=stripe-publishable-key]"))==null?void 0:n.content,e),this.elements=this.stripe.elements(),this}createPaymentRequest(){return this.paymentRequest=this.stripe.paymentRequest(JSON.parse(document.querySelector("meta[name=payment-request-data").content)),this}createPaymentRequestButton(){this.paymentRequestButton=this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest})}handlePaymentRequestEvents(e,t){document.querySelector("#errors").hidden=!0,this.paymentRequest.on("paymentmethod",function(n){e.confirmCardPayment(t,{payment_method:n.paymentMethod.id},{handleActions:!1}).then(function(r){r.error?(document.querySelector("#errors").innerText=r.error.message,document.querySelector("#errors").hidden=!1,n.complete("fail")):(n.complete("success"),r.paymentIntent.status==="requires_action"?e.confirmCardPayment(t).then(function(s){s.error?(n.complete("fail"),document.querySelector("#errors").innerText=s.error.message,document.querySelector("#errors").hidden=!1):(document.querySelector('input[name="gateway_response"]').value=JSON.stringify(s.paymentIntent),document.getElementById("server-response").submit())}):(document.querySelector('input[name="gateway_response"]').value=JSON.stringify(r.paymentIntent),document.getElementById("server-response").submit()))})})}handle(){this.init().createPaymentRequest().createPaymentRequestButton(),this.paymentRequest.canMakePayment().then(e=>{var t;if(e)return this.paymentRequestButton.mount("#payment-request-button");document.querySelector("#errors").innerHTML=JSON.parse((t=document.querySelector("meta[name=no-available-methods]"))==null?void 0:t.content),document.querySelector("#errors").hidden=!1}),this.handlePaymentRequestEvents(this.stripe,this.clientSecret)}}a("#stripe-browserpay-payment").then(()=>new o().handle()); diff --git a/public/build/assets/stripe-credit-card-ce33996a.js b/public/build/assets/stripe-credit-card-f3658509.js similarity index 99% rename from public/build/assets/stripe-credit-card-ce33996a.js rename to public/build/assets/stripe-credit-card-f3658509.js index 2b636374f5fd..df8678897249 100644 --- a/public/build/assets/stripe-credit-card-ce33996a.js +++ b/public/build/assets/stripe-credit-card-f3658509.js @@ -1,4 +1,4 @@ -import{w as l}from"./wait-d71d9fed.js";/** +import{w as l}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository diff --git a/public/build/assets/stripe-eps-6ebc87cd.js b/public/build/assets/stripe-eps-6ebc87cd.js deleted file mode 100644 index 5ca0fc192c8f..000000000000 --- a/public/build/assets/stripe-eps-6ebc87cd.js +++ /dev/null @@ -1,9 +0,0 @@ -var i=Object.defineProperty;var c=(n,e,t)=>e in n?i(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var s=(n,e,t)=>(c(n,typeof e!="symbol"?e+"":e,t),t);/** - * 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://www.elastic.co/licensing/elastic-license - */class a{constructor(e,t){s(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let e=this.stripe.elements();var t={style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}};return this.eps=e.create("epsBank",t),this.eps.mount("#eps-bank-element"),this});s(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("eps-name").value){t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmEpsPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{eps:this.eps,billing_details:{name:document.getElementById("eps-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var r;const l=((r=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:r.content)??"";var o;const m=((o=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:o.content)??"";new a(l,m).setupStripe().handle(); diff --git a/public/build/assets/stripe-eps-735c10bd.js b/public/build/assets/stripe-eps-735c10bd.js new file mode 100644 index 000000000000..5bbd7d09c88b --- /dev/null +++ b/public/build/assets/stripe-eps-735c10bd.js @@ -0,0 +1,9 @@ +var o=Object.defineProperty;var i=(n,t,e)=>t in n?o(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var s=(n,t,e)=>(i(n,typeof t!="symbol"?t+"":t,e),e);import{w as a}from"./wait-8f4ae121.js";/** + * 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://www.elastic.co/licensing/elastic-license + */class c{constructor(t,e){s(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let t=this.stripe.elements();var e={style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}};return this.eps=t.create("epsBank",e),this.eps.mount("#eps-bank-element"),this});s(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(!document.getElementById("eps-name").value){e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmEpsPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{eps:this.eps,billing_details:{name:document.getElementById("eps-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}}a("#stripe-eps-payment").then(()=>{var e,r;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((r=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:r.content)??"";new c(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-fpx-240a05e2.js b/public/build/assets/stripe-fpx-d93f7d79.js similarity index 67% rename from public/build/assets/stripe-fpx-240a05e2.js rename to public/build/assets/stripe-fpx-d93f7d79.js index 5cf0503f394c..4ba34ef6b4d0 100644 --- a/public/build/assets/stripe-fpx-240a05e2.js +++ b/public/build/assets/stripe-fpx-d93f7d79.js @@ -1,4 +1,4 @@ -var i=Object.defineProperty;var c=(n,t,e)=>t in n?i(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var s=(n,t,e)=>(c(n,typeof t!="symbol"?t+"":t,e),e);/** +var o=Object.defineProperty;var i=(n,t,e)=>t in n?o(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>(i(n,typeof t!="symbol"?t+"":t,e),e);import{w as a}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var i=Object.defineProperty;var c=(n,t,e)=>t in n?i(n,t,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class d{constructor(t,e){s(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let t=this.stripe.elements(),e={base:{padding:"10px 12px",color:"#32325d",fontSize:"16px"}};return this.fpx=t.create("fpxBank",{style:e,accountHolderType:"individual"}),this.fpx.mount("#fpx-bank-element"),this});s(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmFpxPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{fpx:this.fpx},return_url:document.querySelector('meta[name="return-url"]').content}).then(e=>{e.error&&this.handleFailure(e.error.message)})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}handleFailure(t){let e=document.getElementById("errors");e.textContent="",e.textContent=t,e.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}var r;const a=((r=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:r.content)??"";var o;const l=((o=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:o.content)??"";new d(a,l).setupStripe().handle(); + */class c{constructor(t,e){r(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let t=this.stripe.elements(),e={base:{padding:"10px 12px",color:"#32325d",fontSize:"16px"}};return this.fpx=t.create("fpxBank",{style:e,accountHolderType:"individual"}),this.fpx.mount("#fpx-bank-element"),this});r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmFpxPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{fpx:this.fpx},return_url:document.querySelector('meta[name="return-url"]').content}).then(e=>{e.error&&this.handleFailure(e.error.message)})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}handleFailure(t){let e=document.getElementById("errors");e.textContent="",e.textContent=t,e.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}a("#stripe-fpx-payment").then(()=>{var e,s;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new c(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-giropay-9d3bfbab.js b/public/build/assets/stripe-giropay-9d3bfbab.js deleted file mode 100644 index 5440e284156e..000000000000 --- a/public/build/assets/stripe-giropay-9d3bfbab.js +++ /dev/null @@ -1,9 +0,0 @@ -var c=Object.defineProperty;var i=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(i(n,typeof e!="symbol"?e+"":e,t),t);/** - * 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://www.elastic.co/licensing/elastic-license - */class a{constructor(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("giropay-mandate-acceptance").checked){t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,console.log("Terms");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmGiropayPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("giropay-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var o;const d=((o=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:o.content)??"";var s;const m=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new a(d,m).setupStripe().handle(); diff --git a/public/build/assets/stripe-giropay-bff9b7b5.js b/public/build/assets/stripe-giropay-bff9b7b5.js new file mode 100644 index 000000000000..8c1ac225f8c2 --- /dev/null +++ b/public/build/assets/stripe-giropay-bff9b7b5.js @@ -0,0 +1,9 @@ +var s=Object.defineProperty;var i=(n,t,e)=>t in n?s(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>(i(n,typeof t!="symbol"?t+"":t,e),e);import{w as c}from"./wait-8f4ae121.js";/** + * 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://www.elastic.co/licensing/elastic-license + */class a{constructor(t,e){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(!document.getElementById("giropay-mandate-acceptance").checked){e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1,console.log("Terms");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmGiropayPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("giropay-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}}c("#stripe-giropay-payment").then(()=>{var e,o;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((o=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:o.content)??"";new a(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-ideal-22b9f5cf.js b/public/build/assets/stripe-ideal-22b9f5cf.js new file mode 100644 index 000000000000..7715c89001b2 --- /dev/null +++ b/public/build/assets/stripe-ideal-22b9f5cf.js @@ -0,0 +1,9 @@ +var s=Object.defineProperty;var o=(n,t,e)=>t in n?s(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>(o(n,typeof t!="symbol"?t+"":t,e),e);import{w as a}from"./wait-8f4ae121.js";/** + * 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://www.elastic.co/licensing/elastic-license + */class l{constructor(t,e){r(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let t=this.stripe.elements();var e={style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}};return this.ideal=t.create("idealBank",e),this.ideal.mount("#ideal-bank-element"),this});r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(!document.getElementById("ideal-name").value){e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1,console.log("name");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmIdealPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{ideal:this.ideal,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}}a("#stripe-ideal-payment").then(()=>{var e,i;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((i=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:i.content)??"";new l(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-ideal-efa175e9.js b/public/build/assets/stripe-ideal-efa175e9.js deleted file mode 100644 index fed5af0ad5ac..000000000000 --- a/public/build/assets/stripe-ideal-efa175e9.js +++ /dev/null @@ -1,9 +0,0 @@ -var o=Object.defineProperty;var a=(n,e,t)=>e in n?o(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(a(n,typeof e!="symbol"?e+"":e,t),t);/** - * 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://www.elastic.co/licensing/elastic-license - */class l{constructor(e,t){r(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let e=this.stripe.elements();var t={style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}};return this.ideal=e.create("idealBank",t),this.ideal.mount("#ideal-bank-element"),this});r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("ideal-name").value){t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,console.log("name");return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmIdealPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{ideal:this.ideal,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var i;const c=((i=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:i.content)??"";var s;const d=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new l(c,d).setupStripe().handle(); diff --git a/public/build/assets/stripe-klarna-e45c946d.js b/public/build/assets/stripe-klarna-9ee067e7.js similarity index 64% rename from public/build/assets/stripe-klarna-e45c946d.js rename to public/build/assets/stripe-klarna-9ee067e7.js index 9fda752c30f3..2d19995fb9d9 100644 --- a/public/build/assets/stripe-klarna-e45c946d.js +++ b/public/build/assets/stripe-klarna-9ee067e7.js @@ -1,4 +1,4 @@ -var m=Object.defineProperty;var d=(n,e,t)=>e in n?m(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(d(n,typeof e!="symbol"?e+"":e,t),t);/** +var s=Object.defineProperty;var c=(n,e,t)=>e in n?s(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var o=(n,e,t)=>(c(n,typeof e!="symbol"?e+"":e,t),t);import{w as m}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var m=Object.defineProperty;var d=(n,e,t)=>e in n?m(n,e,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class l{constructor(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handleError",e=>{document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),this.errors.textContent="",this.errors.textContent=e,this.errors.hidden=!1});r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors"),o=document.getElementById("klarna-name").value;/^[A-Za-z\s]*$/.test(o)?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:o,email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=postal_code]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content}).then(a=>{if(a.hasOwnProperty("error"))return this.handleError(a.error.message)})):(document.getElementById("klarna-name-correction").hidden=!1,document.getElementById("klarna-name").textContent=o.replace(/^[A-Za-z\s]*$/,""),document.getElementById("klarna-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-without-special-characters]").content,t.hidden=!1)})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var c;const i=((c=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:c.content)??"";var s;const u=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new l(i,u).setupStripe().handle(); + */class d{constructor(e,t){o(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));o(this,"handleError",e=>{document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),this.errors.textContent="",this.errors.textContent=e,this.errors.hidden=!1});o(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors"),r=document.getElementById("klarna-name").value;/^[A-Za-z\s]*$/.test(r)?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:r,email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=postal_code]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content}).then(a=>{if(a.hasOwnProperty("error"))return this.handleError(a.error.message)})):(document.getElementById("klarna-name-correction").hidden=!1,document.getElementById("klarna-name").textContent=r.replace(/^[A-Za-z\s]*$/,""),document.getElementById("klarna-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-without-special-characters]").content,t.hidden=!1)})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}m("#stripe-klarna-payment").then(()=>{var t,r;const n=((t=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:t.content)??"",e=((r=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:r.content)??"";new d(n,e).setupStripe().handle()}); diff --git a/public/build/assets/stripe-przelewy24-f9154acf.js b/public/build/assets/stripe-przelewy24-7f03b69e.js similarity index 81% rename from public/build/assets/stripe-przelewy24-f9154acf.js rename to public/build/assets/stripe-przelewy24-7f03b69e.js index 88a19bfa445d..9071abf9f315 100644 --- a/public/build/assets/stripe-przelewy24-f9154acf.js +++ b/public/build/assets/stripe-przelewy24-7f03b69e.js @@ -1,4 +1,4 @@ -var d=Object.defineProperty;var s=(n,t,e)=>t in n?d(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>(s(n,typeof t!="symbol"?t+"":t,e),e);/** +var r=Object.defineProperty;var c=(n,t,e)=>t in n?r(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>(c(n,typeof t!="symbol"?t+"":t,e),e);import{w as d}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var d=Object.defineProperty;var s=(n,t,e)=>t in n?d(n,t,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class m{constructor(t,e){o(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let t=this.stripe.elements();var e={style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}};return this.p24bank=t.create("p24Bank",e),this.p24bank.mount("#p24-bank-element"),this});o(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(document.getElementById("p24-name").value===""){document.getElementById("p24-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}if(document.getElementById("p24-email-address").value===""){document.getElementById("p24-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,e.hidden=!1;return}if(!document.getElementById("p24-mandate-acceptance").checked){document.getElementById("p24-mandate-acceptance").focus(),e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:this.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},payment_method_options:{p24:{tos_shown_and_accepted:document.getElementById("p24-mandate-acceptance").checked}},return_url:document.querySelector('meta[name="return-url"]').content}).then(function(a){a.error?(e.textContent=a.error.message,e.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")):a.paymentIntent.status==="succeeded"&&(window.location=document.querySelector('meta[name="return-url"]').content)})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}}var r;const i=((r=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:r.content)??"";var c;const l=((c=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:c.content)??"";new m(i,l).setupStripe().handle(); + */class s{constructor(t,e){o(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);let t=this.stripe.elements();var e={style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}};return this.p24bank=t.create("p24Bank",e),this.p24bank.mount("#p24-bank-element"),this});o(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",t=>{let e=document.getElementById("errors");if(document.getElementById("p24-name").value===""){document.getElementById("p24-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}if(document.getElementById("p24-email-address").value===""){document.getElementById("p24-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,e.hidden=!1;return}if(!document.getElementById("p24-mandate-acceptance").checked){document.getElementById("p24-mandate-acceptance").focus(),e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:this.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},payment_method_options:{p24:{tos_shown_and_accepted:document.getElementById("p24-mandate-acceptance").checked}},return_url:document.querySelector('meta[name="return-url"]').content}).then(function(a){a.error?(e.textContent=a.error.message,e.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")):a.paymentIntent.status==="succeeded"&&(window.location=document.querySelector('meta[name="return-url"]').content)})})});this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=e}}d("#stripe-przelewy24-payment").then(()=>{var e,a;const n=((e=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:e.content)??"",t=((a=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:a.content)??"";new s(n,t).setupStripe().handle()}); diff --git a/public/build/assets/stripe-sepa-6dd487fc.js b/public/build/assets/stripe-sepa-554f6dfd.js similarity index 91% rename from public/build/assets/stripe-sepa-6dd487fc.js rename to public/build/assets/stripe-sepa-554f6dfd.js index 525db0c1e7b5..32af728f4325 100644 --- a/public/build/assets/stripe-sepa-6dd487fc.js +++ b/public/build/assets/stripe-sepa-554f6dfd.js @@ -1,4 +1,4 @@ -var s=Object.defineProperty;var l=(a,e,t)=>e in a?s(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>(l(a,typeof e!="symbol"?e+"":e,t),t);/** +var r=Object.defineProperty;var c=(a,e,t)=>e in a?r(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>(c(a,typeof e!="symbol"?e+"":e,t),t);import{w as s}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var s=Object.defineProperty;var l=(a,e,t)=>e in a?s(a,e,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class i{constructor(e,t){o(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);const e=this.stripe.elements();var t={base:{color:"#32325d",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',fontSmoothing:"antialiased",fontSize:"16px","::placeholder":{color:"#aab7c4"},":-webkit-autofill":{color:"#32325d"}},invalid:{color:"#fa755a",iconColor:"#fa755a",":-webkit-autofill":{color:"#fa755a"}}},n={style:t,supportedCountries:["SEPA"],placeholderCountry:document.querySelector('meta[name="country"]').content};return this.iban=e.create("iban",n),this.iban.mount("#sepa-iban"),document.getElementById("sepa-name").value=document.querySelector("meta[name=client_name]").content,document.getElementById("sepa-email-address").value=document.querySelector("meta[name=client_email]").content,this});o(this,"handle",()=>{let e=document.getElementById("errors");Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(t=>t.addEventListener("click",n=>{document.getElementById("stripe--payment-container").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=n.target.dataset.token})),document.getElementById("toggle-payment-with-new-bank-account").addEventListener("click",t=>{document.getElementById("stripe--payment-container").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value=""}),document.getElementById("pay-now").addEventListener("click",t=>{if(document.querySelector("input[name=token]").value.length!==0)document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:document.querySelector("input[name=token]").value}).then(n=>n.error?this.handleFailure(n.error.message):this.handleSuccess(n));else{if(document.getElementById("sepa-name").value===""){document.getElementById("sepa-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}if(document.getElementById("sepa-email-address").value===""){document.getElementById("sepa-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,e.hidden=!1;return}if(!document.getElementById("sepa-mandate-acceptance").checked){e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sepa_debit:this.iban,billing_details:{name:document.getElementById("sepa-name").value,email:document.getElementById("sepa-email-address").value}}}).then(n=>n.error?this.handleFailure(n.error.message):this.handleSuccess(n))}})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}handleSuccess(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent);let t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value),document.querySelector("input[name=token]").value.length>2&&(document.querySelector('input[name="store_card"]').value=!1),document.getElementById("server-response").submit()}handleFailure(e){let t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}handleSuccess(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent);let t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value),document.getElementById("server-response").submit()}}var r;const d=((r=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:r.content)??"";var c;const m=((c=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:c.content)??"";new i(d,m).setupStripe().handle(); + */class i{constructor(e,t){o(this,"setupStripe",()=>{this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key);const e=this.stripe.elements();var t={base:{color:"#32325d",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',fontSmoothing:"antialiased",fontSize:"16px","::placeholder":{color:"#aab7c4"},":-webkit-autofill":{color:"#32325d"}},invalid:{color:"#fa755a",iconColor:"#fa755a",":-webkit-autofill":{color:"#fa755a"}}},n={style:t,supportedCountries:["SEPA"],placeholderCountry:document.querySelector('meta[name="country"]').content};return this.iban=e.create("iban",n),this.iban.mount("#sepa-iban"),document.getElementById("sepa-name").value=document.querySelector("meta[name=client_name]").content,document.getElementById("sepa-email-address").value=document.querySelector("meta[name=client_email]").content,this});o(this,"handle",()=>{let e=document.getElementById("errors");Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(t=>t.addEventListener("click",n=>{document.getElementById("stripe--payment-container").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=n.target.dataset.token})),document.getElementById("toggle-payment-with-new-bank-account").addEventListener("click",t=>{document.getElementById("stripe--payment-container").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value=""}),document.getElementById("pay-now").addEventListener("click",t=>{if(document.querySelector("input[name=token]").value.length!==0)document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:document.querySelector("input[name=token]").value}).then(n=>n.error?this.handleFailure(n.error.message):this.handleSuccess(n));else{if(document.getElementById("sepa-name").value===""){document.getElementById("sepa-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,e.hidden=!1;return}if(document.getElementById("sepa-email-address").value===""){document.getElementById("sepa-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,e.hidden=!1;return}if(!document.getElementById("sepa-mandate-acceptance").checked){e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1;return}document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sepa_debit:this.iban,billing_details:{name:document.getElementById("sepa-name").value,email:document.getElementById("sepa-email-address").value}}}).then(n=>n.error?this.handleFailure(n.error.message):this.handleSuccess(n))}})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}handleSuccess(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent);let t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value),document.querySelector("input[name=token]").value.length>2&&(document.querySelector('input[name="store_card"]').value=!1),document.getElementById("server-response").submit()}handleFailure(e){let t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}handleSuccess(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent);let t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value),document.getElementById("server-response").submit()}}s("#stripe-sepa-payment").then(()=>{var t,n;const a=((t=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:t.content)??"",e=((n=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:n.content)??"";new i(a,e).setupStripe().handle()}); diff --git a/public/build/assets/stripe-sofort-18aeca06.js b/public/build/assets/stripe-sofort-6e4e7148.js similarity index 71% rename from public/build/assets/stripe-sofort-18aeca06.js rename to public/build/assets/stripe-sofort-6e4e7148.js index bb1601d347f4..59ebc243fe84 100644 --- a/public/build/assets/stripe-sofort-18aeca06.js +++ b/public/build/assets/stripe-sofort-6e4e7148.js @@ -1,4 +1,4 @@ -var c=Object.defineProperty;var i=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(i(n,typeof e!="symbol"?e+"":e,t),t);/** +var s=Object.defineProperty;var c=(n,e,t)=>e in n?s(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(c(n,typeof e!="symbol"?e+"":e,t),t);import{w as i}from"./wait-8f4ae121.js";/** * Invoice Ninja (https://invoiceninja.com) * * @link https://github.com/invoiceninja/invoiceninja source repository @@ -6,4 +6,4 @@ var c=Object.defineProperty;var i=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configura * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license - */class u{constructor(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmSofortPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sofort:{country:document.querySelector('meta[name="country"]').content}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var o;const a=((o=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:o.content)??"";var s;const m=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new u(a,m).setupStripe().handle(); + */class u{constructor(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmSofortPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sofort:{country:document.querySelector('meta[name="country"]').content}},return_url:document.querySelector('meta[name="return-url"]').content})})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}i("#stripe-sofort-payment").then(()=>{var t,o;const n=((t=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:t.content)??"",e=((o=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:o.content)??"";new u(n,e).setupStripe().handle()}); diff --git a/public/build/assets/wait-8f4ae121.js b/public/build/assets/wait-8f4ae121.js new file mode 100644 index 000000000000..ec3d03b10652 --- /dev/null +++ b/public/build/assets/wait-8f4ae121.js @@ -0,0 +1,9 @@ +/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */function i(...e){return new Promise(n=>{if(!e.length){n([]);return}const r=e.map(t=>document.querySelector(t)).filter(Boolean);if(r.length===e.length){n(r);return}const o=new MutationObserver(()=>{const t=e.map(u=>document.querySelector(u)).filter(Boolean);t.length===e.length&&(o.disconnect(),n(t))});o.observe(document.body,{childList:!0,subtree:!0})})}function a(){const e=document.querySelector('meta[name="instant-payment"]');return!!(e&&e instanceof HTMLMetaElement&&e.content==="yes")}export{a as i,i as w}; diff --git a/public/build/assets/wait-d71d9fed.js b/public/build/assets/wait-d71d9fed.js deleted file mode 100644 index 1bc4888178d9..000000000000 --- a/public/build/assets/wait-d71d9fed.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Invoice Ninja (https://invoiceninja.com). - * - * @link https://github.com/invoiceninja/invoiceninja source repository - * - * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) - * - * @license https://www.elastic.co/licensing/elastic-license - */function i(...e){return new Promise(t=>{if(!e.length){t([]);return}const r=e.map(n=>document.querySelector(n)).filter(Boolean);if(r.length===e.length){t(r);return}const o=new MutationObserver(()=>{const n=e.map(u=>document.querySelector(u)).filter(Boolean);n.length===e.length&&(o.disconnect(),t(n))});o.observe(document.body,{childList:!0,subtree:!0})})}export{i as w}; diff --git a/public/build/manifest.json b/public/build/manifest.json index efd8c8201849..a9d3a93a1cbe 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -8,8 +8,8 @@ "__commonjsHelpers-725317a4.js" ] }, - "_wait-d71d9fed.js": { - "file": "assets/wait-d71d9fed.js" + "_wait-8f4ae121.js": { + "file": "assets/wait-8f4ae121.js" }, "resources/js/app.js": { "file": "assets/app-234e3402.js", @@ -48,6 +48,14 @@ "isEntry": true, "src": "resources/js/clients/payment_methods/authorize-checkout-card.js" }, + "resources/js/clients/payment_methods/authorize-stripe-acss.js": { + "file": "assets/authorize-stripe-acss-f6bd46c1.js", + "imports": [ + "_wait-8f4ae121.js" + ], + "isEntry": true, + "src": "resources/js/clients/payment_methods/authorize-stripe-acss.js" + }, "resources/js/clients/payment_methods/braintree-ach.js": { "file": "assets/braintree-ach-b29d040e.js", "isEntry": true, @@ -74,9 +82,9 @@ "src": "resources/js/clients/payments/braintree-paypal.js" }, "resources/js/clients/payments/checkout-credit-card.js": { - "file": "assets/checkout-credit-card-ba005c24.js", + "file": "assets/checkout-credit-card-eba516f2.js", "imports": [ - "_wait-d71d9fed.js" + "_wait-8f4ae121.js" ], "isEntry": true, "src": "resources/js/clients/payments/checkout-credit-card.js" @@ -116,13 +124,24 @@ "isEntry": true, "src": "resources/js/clients/payments/square-credit-card.js" }, + "resources/js/clients/payments/stripe-ach-pay.js": { + "file": "assets/stripe-ach-pay-22d14901.js", + "imports": [ + "_wait-8f4ae121.js" + ], + "isEntry": true, + "src": "resources/js/clients/payments/stripe-ach-pay.js" + }, "resources/js/clients/payments/stripe-ach.js": { "file": "assets/stripe-ach-fe366ca7.js", "isEntry": true, "src": "resources/js/clients/payments/stripe-ach.js" }, "resources/js/clients/payments/stripe-acss.js": { - "file": "assets/stripe-acss-946fe54a.js", + "file": "assets/stripe-acss-1184fda8.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-acss.js" }, @@ -132,70 +151,114 @@ "src": "resources/js/clients/payments/stripe-alipay.js" }, "resources/js/clients/payments/stripe-bacs.js": { - "file": "assets/stripe-bacs-38c8b975.js", + "file": "assets/stripe-bacs-e1cfee99.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-bacs.js" }, "resources/js/clients/payments/stripe-bancontact.js": { - "file": "assets/stripe-bancontact-cb004d43.js", + "file": "assets/stripe-bancontact-743204e1.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-bancontact.js" }, + "resources/js/clients/payments/stripe-bank-transfer.js": { + "file": "assets/stripe-bank-transfer-801a4de6.js", + "imports": [ + "_wait-8f4ae121.js" + ], + "isEntry": true, + "src": "resources/js/clients/payments/stripe-bank-transfer.js" + }, "resources/js/clients/payments/stripe-becs.js": { - "file": "assets/stripe-becs-4d1494ed.js", + "file": "assets/stripe-becs-ce05fb09.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-becs.js" }, "resources/js/clients/payments/stripe-browserpay.js": { - "file": "assets/stripe-browserpay-ac78fb26.js", + "file": "assets/stripe-browserpay-813e625e.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-browserpay.js" }, "resources/js/clients/payments/stripe-credit-card.js": { - "file": "assets/stripe-credit-card-ce33996a.js", + "file": "assets/stripe-credit-card-f3658509.js", "imports": [ - "_wait-d71d9fed.js" + "_wait-8f4ae121.js" ], "isEntry": true, "src": "resources/js/clients/payments/stripe-credit-card.js" }, "resources/js/clients/payments/stripe-eps.js": { - "file": "assets/stripe-eps-6ebc87cd.js", + "file": "assets/stripe-eps-735c10bd.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-eps.js" }, "resources/js/clients/payments/stripe-fpx.js": { - "file": "assets/stripe-fpx-240a05e2.js", + "file": "assets/stripe-fpx-d93f7d79.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-fpx.js" }, "resources/js/clients/payments/stripe-giropay.js": { - "file": "assets/stripe-giropay-9d3bfbab.js", + "file": "assets/stripe-giropay-bff9b7b5.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-giropay.js" }, "resources/js/clients/payments/stripe-ideal.js": { - "file": "assets/stripe-ideal-efa175e9.js", + "file": "assets/stripe-ideal-22b9f5cf.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-ideal.js" }, "resources/js/clients/payments/stripe-klarna.js": { - "file": "assets/stripe-klarna-e45c946d.js", + "file": "assets/stripe-klarna-9ee067e7.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-klarna.js" }, "resources/js/clients/payments/stripe-przelewy24.js": { - "file": "assets/stripe-przelewy24-f9154acf.js", + "file": "assets/stripe-przelewy24-7f03b69e.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-przelewy24.js" }, "resources/js/clients/payments/stripe-sepa.js": { - "file": "assets/stripe-sepa-6dd487fc.js", + "file": "assets/stripe-sepa-554f6dfd.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-sepa.js" }, "resources/js/clients/payments/stripe-sofort.js": { - "file": "assets/stripe-sofort-18aeca06.js", + "file": "assets/stripe-sofort-6e4e7148.js", + "imports": [ + "_wait-8f4ae121.js" + ], "isEntry": true, "src": "resources/js/clients/payments/stripe-sofort.js" }, diff --git a/resources/js/clients/payment_methods/authorize-stripe-acss.js b/resources/js/clients/payment_methods/authorize-stripe-acss.js new file mode 100644 index 000000000000..dd8a0ca20f83 --- /dev/null +++ b/resources/js/clients/payment_methods/authorize-stripe-acss.js @@ -0,0 +1,80 @@ +/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */ + +import { wait } from '../wait'; + +wait('#stripe-acss-authorize').then(() => authorize()); + +function authorize() { + let stripe; + + const account_id = document.querySelector( + 'meta[name="stripe-account-id"]' + )?.content; + + const publishable_key = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content; + + if (account_id && account_id.length > 0) { + stripe = Stripe(publishable_key, { + stripeAccount: account_id, + }); + } else { + stripe = Stripe(publishable_key); + } + + const accountholderName = document.getElementById('acss-name'); + const email = document.getElementById('acss-email-address'); + const submitButton = document.getElementById('authorize-acss'); + const clientSecret = document.querySelector('meta[name="stripe-pi-client-secret"]')?.content; + const errors = document.getElementById('errors'); + + submitButton.addEventListener('click', async (event) => { + event.preventDefault(); + errors.hidden = true; + submitButton.disabled = true; + + const validEmailRegex = + /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; + + if (email.value.length < 3 || !email.value.match(validEmailRegex)) { + errors.textContent = 'Please enter a valid email address.'; + errors.hidden = false; + submitButton.disabled = false; + return; + } + + if (accountholderName.value.length < 3) { + errors.textContent = 'Please enter a name for the account holder.'; + errors.hidden = false; + submitButton.disabled = false; + return; + } + + const { setupIntent, error } = await stripe.confirmAcssDebitSetup( + clientSecret, + { + payment_method: { + billing_details: { + name: accountholderName.value, + email: email.value, + }, + }, + } + ); + + // Handle next step based on SetupIntent's status. + document.getElementById('gateway_response').value = JSON.stringify( + setupIntent ?? error + ); + document.getElementById('server_response').submit(); + }); +} diff --git a/resources/js/clients/payments/stripe-ach-pay.js b/resources/js/clients/payments/stripe-ach-pay.js new file mode 100644 index 000000000000..4eb00730b5ef --- /dev/null +++ b/resources/js/clients/payments/stripe-ach-pay.js @@ -0,0 +1,168 @@ +/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */ + +import { wait } from '../wait'; + +wait('#stripe-ach-payment').then(() => ach()); + +function ach() { + let payNow = document.getElementById('pay-now'); + + if (payNow) { + Array.from( + document.getElementsByClassName('toggle-payment-with-token') + ).forEach((element) => + element.addEventListener('click', (element) => { + document.querySelector('input[name=source]').value = + element.target.dataset.token; + }) + ); + payNow.addEventListener('click', function () { + let payNowButton = document.getElementById('pay-now'); + payNowButton.disabled = true; + payNowButton.querySelector('svg').classList.remove('hidden'); + payNowButton.querySelector('span').classList.add('hidden'); + document.getElementById('server-response').submit(); + }); + } + + document.getElementById('new-bank').addEventListener('click', (ev) => { + if (!document.getElementById('accept-terms').checked) { + errors.textContent = + 'You must accept the mandate terms prior to making payment.'; + errors.hidden = false; + return; + } + + errors.hidden = true; + + let stripe; + + let publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + ).content; + + let stripeConnect = document.querySelector( + 'meta[name="stripe-account-id"]' + )?.content; + + if (stripeConnect) { + stripe = Stripe(publishableKey, { stripeAccount: stripeConnect }); + } else { + stripe = Stripe(publishableKey); + } + + let newBankButton = document.getElementById('new-bank'); + newBankButton.disabled = true; + newBankButton.querySelector('svg').classList.remove('hidden'); + newBankButton.querySelector('span').classList.add('hidden'); + + ev.preventDefault(); + const accountHolderNameField = document.getElementById( + 'account-holder-name-field' + ); + const emailField = document.getElementById('email-field'); + const clientSecret = document.querySelector( + 'meta[name="client_secret"]' + )?.content; + // Calling this method will open the instant verification dialog. + stripe + .collectBankAccountForPayment({ + clientSecret: clientSecret, + params: { + payment_method_type: 'us_bank_account', + payment_method_data: { + billing_details: { + name: accountHolderNameField.value, + email: emailField.value, + }, + }, + }, + expand: ['payment_method'], + }) + .then(({ paymentIntent, error }) => { + if (error) { + console.error(error.message); + errors.textContent = error.message; + errors.hidden = false; + resetButtons(); + + // PaymentMethod collection failed for some reason. + } else if (paymentIntent.status === 'requires_payment_method') { + // Customer canceled the hosted verification modal. Present them with other + // payment method type options. + + errors.textContent = + 'We were unable to process the payment with this account, please try another one.'; + errors.hidden = false; + resetButtons(); + return; + } else if (paymentIntent.status === 'requires_confirmation') { + let bank_account_response = document.getElementById( + 'bank_account_response' + ); + bank_account_response.value = JSON.stringify(paymentIntent); + + confirmPayment(stripe, clientSecret); + } + + resetButtons(); + return; + }); + }); + + function confirmPayment(stripe, clientSecret) { + stripe + .confirmUsBankAccountPayment(clientSecret) + .then(({ paymentIntent, error }) => { + console.log(paymentIntent); + if (error) { + console.error(error.message); + // The payment failed for some reason. + } else if (paymentIntent.status === 'requires_payment_method') { + // Confirmation failed. Attempt again with a different payment method. + + errors.textContent = + 'We were unable to process the payment with this account, please try another one.'; + errors.hidden = false; + resetButtons(); + } else if (paymentIntent.status === 'processing') { + // Confirmation succeeded! The account will be debited. + + let gateway_response = + document.getElementById('gateway_response'); + gateway_response.value = JSON.stringify(paymentIntent); + document.getElementById('server-response').submit(); + } else if ( + paymentIntent.next_action?.type === + 'verify_with_microdeposits' || + paymentIntent.next_action?.type === 'requires_source_action' + ) { + errors.textContent = + 'You will receive an email with details on how to verify your bank account and process payment.'; + errors.hidden = false; + document.getElementById('new-bank').style.visibility = + 'hidden'; + + let gateway_response = + document.getElementById('gateway_response'); + gateway_response.value = JSON.stringify(paymentIntent); + document.getElementById('server-response').submit(); + } + }); + } + + function resetButtons() { + let newBankButton = document.getElementById('new-bank'); + newBankButton.disabled = false; + newBankButton.querySelector('svg').classList.add('hidden'); + newBankButton.querySelector('span').classList.remove('hidden'); + } +} diff --git a/resources/js/clients/payments/stripe-acss.js b/resources/js/clients/payments/stripe-acss.js index 613e8e373497..aa3f64a1c574 100644 --- a/resources/js/clients/payments/stripe-acss.js +++ b/resources/js/clients/payments/stripe-acss.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { instant, wait } from '../wait'; + class ProcessACSS { constructor(key, stripeConnect) { this.key = key; @@ -145,11 +147,16 @@ class ProcessACSS { } } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; +function boot() { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessACSS(publishableKey, stripeConnect).setupStripe().handle(); +} -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; +instant() ? boot() : wait('#stripe-acss-payment').then(() => boot()); -new ProcessACSS(publishableKey, stripeConnect).setupStripe().handle(); diff --git a/resources/js/clients/payments/stripe-bacs.js b/resources/js/clients/payments/stripe-bacs.js index a67c9057c588..36a6c783ef2c 100644 --- a/resources/js/clients/payments/stripe-bacs.js +++ b/resources/js/clients/payments/stripe-bacs.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessBACS { constructor(key, stripeConnect) { this.key = key; @@ -75,13 +77,15 @@ class ProcessBACS { } } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; -const onlyAuthorization = - document.querySelector('meta[name="only-authorization"]')?.content ?? ''; - -new ProcessBACS(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-bacs-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + const onlyAuthorization = + document.querySelector('meta[name="only-authorization"]')?.content ?? ''; + + new ProcessBACS(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-bancontact.js b/resources/js/clients/payments/stripe-bancontact.js index 35860607b775..c4a2afdf6435 100644 --- a/resources/js/clients/payments/stripe-bancontact.js +++ b/resources/js/clients/payments/stripe-bancontact.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessBANCONTACTPay { constructor(key, stripeConnect) { this.key = key; @@ -63,11 +65,14 @@ class ProcessBANCONTACTPay { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; +wait('#stripe-bancontact-payment').then(() => { -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessBANCONTACTPay(publishableKey, stripeConnect).setupStripe().handle(); + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessBANCONTACTPay(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-bank-transfer.js b/resources/js/clients/payments/stripe-bank-transfer.js new file mode 100644 index 000000000000..10b570a0b812 --- /dev/null +++ b/resources/js/clients/payments/stripe-bank-transfer.js @@ -0,0 +1,76 @@ +/** + * Invoice Ninja (https://invoiceninja.com). + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */ + +import { wait } from '../wait'; + +wait('#stripe-bank-transfer-payment').then(() => bankTransfer()); + +function bankTransfer() { + const secret = document.querySelector('meta[name="stripe-client-secret"]')?.content; + const return_url = document.querySelector('meta[name="stripe-return-url"]')?.content; + + const options = { + clientSecret: secret, + appearance: { + theme: 'stripe', + variables: { + colorPrimary: '#0570de', + colorBackground: '#ffffff', + colorText: '#30313d', + colorDanger: '#df1b41', + fontFamily: 'Ideal Sans, system-ui, sans-serif', + spacingUnit: '2px', + borderRadius: '4px', + // See all possible variables below + }, + }, + }; + + const stripe = Stripe( + document + .querySelector('meta[name="stripe-publishable-key"]') + .getAttribute('content') + ); + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + if (stripeConnect) stripe.stripeAccount = stripeConnect; + + // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in step 3 + const elements = stripe.elements(options); + // Create and mount the Payment Element + const paymentElement = elements.create('payment'); + paymentElement.mount('#payment-element'); + + const form = document.getElementById('payment-form'); + + form.addEventListener('submit', async (event) => { + event.preventDefault(); + + document.getElementById('pay-now').disabled = true; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + + const { error } = await stripe.confirmPayment({ + elements, + confirmParams: { + return_url, + }, + }); + + if (error) { + document.getElementById('pay-now').disabled = false; + document.querySelector('svg').classList.remove('hidden'); + document.querySelector('span').classList.add('hidden'); + const messageContainer = document.querySelector('#errors'); + messageContainer.textContent = error.message; + } + }); +} diff --git a/resources/js/clients/payments/stripe-becs.js b/resources/js/clients/payments/stripe-becs.js index 61544ccf53c7..573995e031af 100644 --- a/resources/js/clients/payments/stripe-becs.js +++ b/resources/js/clients/payments/stripe-becs.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessBECS { constructor(key, stripeConnect) { this.key = key; @@ -135,11 +137,13 @@ class ProcessBECS { } } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessBECS(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-becs-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessBECS(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-eps.js b/resources/js/clients/payments/stripe-eps.js index 2ae980bc321a..24eab60b9fc4 100644 --- a/resources/js/clients/payments/stripe-eps.js +++ b/resources/js/clients/payments/stripe-eps.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessEPSPay { constructor(key, stripeConnect) { this.key = key; @@ -80,11 +82,13 @@ class ProcessEPSPay { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessEPSPay(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-eps-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessEPSPay(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-fpx.js b/resources/js/clients/payments/stripe-fpx.js index 45db81feea30..1c5430d3a678 100644 --- a/resources/js/clients/payments/stripe-fpx.js +++ b/resources/js/clients/payments/stripe-fpx.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessFPXPay { constructor(key, stripeConnect) { this.key = key; @@ -81,13 +83,13 @@ class ProcessFPXPay { } } - - -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessFPXPay(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-fpx-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessFPXPay(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-giropay.js b/resources/js/clients/payments/stripe-giropay.js index 1a3903e9570f..7c0650bf0fe7 100644 --- a/resources/js/clients/payments/stripe-giropay.js +++ b/resources/js/clients/payments/stripe-giropay.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessGiroPay { constructor(key, stripeConnect) { this.key = key; @@ -64,11 +66,13 @@ class ProcessGiroPay { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessGiroPay(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-giropay-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessGiroPay(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-ideal.js b/resources/js/clients/payments/stripe-ideal.js index db397cb1e178..084bfec36404 100644 --- a/resources/js/clients/payments/stripe-ideal.js +++ b/resources/js/clients/payments/stripe-ideal.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessIDEALPay { constructor(key, stripeConnect) { this.key = key; @@ -81,11 +83,13 @@ class ProcessIDEALPay { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessIDEALPay(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-ideal-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessIDEALPay(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index cebbb6e42fcb..dbe99fd90c72 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessKlarna { constructor(key, stripeConnect) { this.key = key; @@ -91,11 +93,13 @@ class ProcessKlarna { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessKlarna(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-klarna-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessKlarna(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-przelewy24.js b/resources/js/clients/payments/stripe-przelewy24.js index 9f990240d0ec..6069b9939aa7 100644 --- a/resources/js/clients/payments/stripe-przelewy24.js +++ b/resources/js/clients/payments/stripe-przelewy24.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessPRZELEWY24 { constructor(key, stripeConnect) { this.key = key; @@ -113,11 +115,13 @@ class ProcessPRZELEWY24 { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessPRZELEWY24(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-przelewy24-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessPRZELEWY24(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-sepa.js b/resources/js/clients/payments/stripe-sepa.js index cafcf8e7cc9c..e7048c420cb3 100644 --- a/resources/js/clients/payments/stripe-sepa.js +++ b/resources/js/clients/payments/stripe-sepa.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessSEPA { constructor(key, stripeConnect) { this.key = key; @@ -233,11 +235,13 @@ class ProcessSEPA { } } -const publishableKey = - document.querySelector('meta[name="stripe-publishable-key"]')?.content ?? +wait('#stripe-sepa-payment').then(() => { + const publishableKey = + document.querySelector('meta[name="stripe-publishable-key"]')?.content ?? ''; -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; -new ProcessSEPA(publishableKey, stripeConnect).setupStripe().handle(); + new ProcessSEPA(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/payments/stripe-sofort.js b/resources/js/clients/payments/stripe-sofort.js index 394849697df4..0fe1711dcf24 100644 --- a/resources/js/clients/payments/stripe-sofort.js +++ b/resources/js/clients/payments/stripe-sofort.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait } from '../wait'; + class ProcessSOFORT { constructor(key, stripeConnect) { this.key = key; @@ -58,11 +60,13 @@ class ProcessSOFORT { }; } -const publishableKey = document.querySelector( - 'meta[name="stripe-publishable-key"]' -)?.content ?? ''; - -const stripeConnect = - document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; - -new ProcessSOFORT(publishableKey, stripeConnect).setupStripe().handle(); +wait('#stripe-sofort-payment').then(() => { + const publishableKey = document.querySelector( + 'meta[name="stripe-publishable-key"]' + )?.content ?? ''; + + const stripeConnect = + document.querySelector('meta[name="stripe-account-id"]')?.content ?? ''; + + new ProcessSOFORT(publishableKey, stripeConnect).setupStripe().handle(); +}); diff --git a/resources/js/clients/wait.js b/resources/js/clients/wait.js index ac83b278bbd8..3be06507caf8 100644 --- a/resources/js/clients/wait.js +++ b/resources/js/clients/wait.js @@ -41,3 +41,17 @@ export function wait(...selectors) { observer.observe(document.body, { childList: true, subtree: true }); }); } + +export function instant() { + const instant = document.querySelector('meta[name="instant-payment"]'); + + if ( + instant && + instant instanceof HTMLMetaElement && + instant.content === 'yes' + ) { + return true; + } + + return false; +} diff --git a/resources/views/portal/ninja2020/gateways/stripe/ach/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/ach/pay_livewire.blade.php new file mode 100644 index 000000000000..73fe15639cf1 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/ach/pay_livewire.blade.php @@ -0,0 +1,92 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + +
+ @csrf + + + + + + + + + + +
+ + @if(count($tokens) > 0) + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if(count($tokens) > 0) + + @endif + @endcomponent + + @include('portal.ninja2020.gateways.includes.pay_now') + + @else + + @component('portal.ninja2020.components.general.card-element-single') + + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_holder_name')]) + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.email')]) + + @endcomponent + +
+
+ Connect a bank account +
+
+ +
+
+ @endif +
+ +@assets + +@vite('resources/js/clients/payments/stripe-ach-pay.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/acss/authorize_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/acss/authorize_livewire.blade.php new file mode 100644 index 000000000000..3dd06e6d1a1c --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/acss/authorize_livewire.blade.php @@ -0,0 +1,70 @@ +
+ + @if($company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + +
+ @csrf + + + + + +
+ + + @component('portal.ninja2020.components.general.card-element-single', ['title' => 'SEPA', 'show_title' => false]) +

By clicking submit, you accept this Agreement and authorize {{ $company->present()->name() }} to debit the + specified bank account for any amount owed for charges arising from the use of services and/or purchase of + products.

+
+

Payments will be debited from the specified account when an invoice becomes due.

+
+

Where a scheduled debit date is not a business day, {{ $company->present()->name() }} will debit on the next + business day.

+
+

You agree that any payments due will be debited from your account immediately upon acceptance of this Agreement + and that confirmation of this Agreement may be sent within 5 (five) days of acceptance of this Agreement. You + further agree to be notified of upcoming debits up to 1 (one) day before payments are collected.

+
+

You have certain recourse rights if any debit does not comply with this agreement. For example, you have the + right to receive reimbursement for any debit that is not authorized or is not consistent with this PAD + Agreement. To obtain more information on your recourse rights, contact your financial institution.

+
+

You may amend or cancel this authorization at any time by providing the merchant with thirty (30) days notice at + {{ $company->owner()->email }}. To obtain a sample cancellation form, or further information on cancelling a PAD + agreement, please contact your financial institution.

+
+

{{ $company->present()->name() }} partners with Stripe to provide payment processing.

+ + +
+ + +
+ + @endcomponent + @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'authorize-acss']) + {{ ctrans('texts.add_payment_method') }} + @endcomponent +
+ +@assets + +@vite('resources/js/clients/payment_methods/authorize-stripe-acss.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/acss/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/acss/pay.blade.php index 0a6cbc457baf..aa4c7f6b7848 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/acss/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/acss/pay.blade.php @@ -8,7 +8,7 @@ @else @endif - + @@ -60,5 +60,4 @@ @push('footer') @vite('resources/js/clients/payments/stripe-acss.js') - @endpush diff --git a/resources/views/portal/ninja2020/gateways/stripe/acss/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/acss/pay_livewire.blade.php new file mode 100644 index 000000000000..3ab6a860c35a --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/acss/pay_livewire.blade.php @@ -0,0 +1,56 @@ +
+ + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + {{ ctrans('texts.acss') }} ({{ ctrans('texts.bank_transfer') }}) +
+ @csrf + + + + + + +
+ + + @include('portal.ninja2020.gateways.includes.pay_now', ['id' => 'pay-now-with-token']) + + @endcomponent + +
+ +@assets + +@vite('resources/js/clients/payments/stripe-acss.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/bacs/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bacs/pay_livewire.blade.php new file mode 100644 index 000000000000..30087735167f --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/bacs/pay_livewire.blade.php @@ -0,0 +1,47 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + +
+ @csrf + + + + + +
+ + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.bacs') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + + @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.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-bacs.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/bancontact/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bancontact/pay_livewire.blade.php new file mode 100644 index 000000000000..28daec0a0b22 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/bancontact/pay_livewire.blade.php @@ -0,0 +1,33 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.bancontact') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.stripe.bancontact.bancontact') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-bancontact.js') +@endassets diff --git a/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/pay_livewire.blade.php new file mode 100644 index 000000000000..119af03ef529 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/pay_livewire.blade.php @@ -0,0 +1,43 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + +
+ @csrf + +
+ +
+ +
+ +
+
+
+ +@assets + +@vite('resources/js/clients/payments/stripe-bank-transfer.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/becs/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/becs/pay_livewire.blade.php new file mode 100644 index 000000000000..7825735ec1e0 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/becs/pay_livewire.blade.php @@ -0,0 +1,36 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.becs') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + + @include('portal.ninja2020.gateways.stripe.becs.becs_debit') + @include('portal.ninja2020.gateways.includes.save_card') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + +@endassets diff --git a/resources/views/portal/ninja2020/gateways/stripe/eps/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/eps/pay_livewire.blade.php new file mode 100644 index 000000000000..3ae31d316e8e --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/eps/pay_livewire.blade.php @@ -0,0 +1,33 @@ +
+ + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.eps') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.stripe.eps.eps') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-eps.js') +@endassets diff --git a/resources/views/portal/ninja2020/gateways/stripe/fpx/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/fpx/pay_livewire.blade.php new file mode 100644 index 000000000000..0eb90a453270 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/fpx/pay_livewire.blade.php @@ -0,0 +1,31 @@ +
+ + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.fpx') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.stripe.fpx.fpx') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + +@vite('resources/js/clients/payments/stripe-fpx.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/giropay/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/giropay/pay_livewire.blade.php new file mode 100644 index 000000000000..b1750955022d --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/giropay/pay_livewire.blade.php @@ -0,0 +1,32 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.giropay') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.stripe.giropay.giropay') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-giropay.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/ideal/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/ideal/pay_livewire.blade.php new file mode 100644 index 000000000000..d4accb1efe42 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/ideal/pay_livewire.blade.php @@ -0,0 +1,32 @@ +
+ + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.ideal') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.stripe.ideal.ideal') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-ideal.js') +@endassets diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay_livewire.blade.php new file mode 100644 index 000000000000..476edea4699a --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay_livewire.blade.php @@ -0,0 +1,37 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.klarna') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.stripe.klarna.klarna') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-klarna.js') +@endassets diff --git a/resources/views/portal/ninja2020/gateways/stripe/przelewy24/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/przelewy24/pay_livewire.blade.php new file mode 100644 index 000000000000..9d7b89f15e15 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/przelewy24/pay_livewire.blade.php @@ -0,0 +1,35 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.przelewy24') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + + @include('portal.ninja2020.gateways.stripe.przelewy24.przelewy24') + @include('portal.ninja2020.gateways.includes.save_card') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-przelewy24.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/sepa/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/sepa/pay_livewire.blade.php new file mode 100644 index 000000000000..95840d1342dc --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/sepa/pay_livewire.blade.php @@ -0,0 +1,89 @@ +
+ + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + + +
+ @csrf + + + + + + +
+ + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.sepa') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if (count($tokens) > 0) + @foreach ($tokens as $token) + + @endforeach + @endisset + + + @endcomponent + + @component('portal.ninja2020.components.general.card-element-single') +
+ + + +
+ + +
+
+ @endcomponent + + @include('portal.ninja2020.gateways.includes.save_card') + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-sepa.js') +@endassets \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/stripe/sofort/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/stripe/sofort/pay_livewire.blade.php new file mode 100644 index 000000000000..5f11720f3a64 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/sofort/pay_livewire.blade.php @@ -0,0 +1,30 @@ +
+ @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + + + + + + + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.sofort') }} ({{ ctrans('texts.bank_transfer') }}) + @endcomponent + @include('portal.ninja2020.gateways.includes.pay_now') +
+ +@assets + + @vite('resources/js/clients/payments/stripe-sofort.js') +@endassets diff --git a/vite.config.ts b/vite.config.ts index a03c2f803612..9146a82b0833 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -50,6 +50,9 @@ export default defineConfig({ 'resources/js/clients/payments/stripe-przelewy24.js', 'resources/js/clients/payments/stripe-browserpay.js', 'resources/js/clients/payments/stripe-fpx.js', + 'resources/js/clients/payments/stripe-ach-pay.js', + 'resources/js/clients/payments/stripe-bank-transfer.js', + 'resources/js/clients/payment_methods/authorize-stripe-acss.js' ]), viteStaticCopy({ targets: [