mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 01:34:30 -04:00
* make container nicer * assets rebuild * authorize powerband card (3ds) * add reference to build file * update authorize (3ds) view * assets rebuild * unify 3ds and non-3ds auth/pay * assets rebuild * authorize * pay * update vite refs * pay * hide authorize button * intercepting form on authorize * assets build * wip * init powerboard in data ref * fixes for blank placeholders * reset the form on failed 3ds * handling unsuccessful errors * send email on payment failed * fixes for 3ds fail on auth * assets rebuild * make card_name required * make card_name required (on auth) * fixes for blocked pay-now button * fixes for reload * fixes for reload * build * Fixes for broken powerboard * make client name required * skip fields checking if no required fields * on request, return json response * check for plain not_authenticated response * flash message when no action is present * fixes for exec order on token * assets build * check for plain not_authenticated response (pay) * assets build * adjustments for minimum payments * Add text decoration to terms button * Improvements for subscriptions and new payment flow --------- Co-authored-by: Benjamin Beganović <k1pstabug@gmail.com>
80 lines
2.5 KiB
PHP
80 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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
|
|
*/
|
|
|
|
namespace App\Livewire\Flow2;
|
|
|
|
use App\Utils\Number;
|
|
use App\Utils\Traits\WithSecureContext;
|
|
use Livewire\Component;
|
|
|
|
class UnderOverPayment extends Component
|
|
{
|
|
|
|
use WithSecureContext;
|
|
|
|
public $payableAmount;
|
|
|
|
public $currency;
|
|
|
|
public $invoice_amount;
|
|
|
|
public $errors = '';
|
|
|
|
public $payableInvoices = [];
|
|
|
|
public function mount()
|
|
{
|
|
|
|
$this->invoice_amount = array_sum(array_column($this->getContext()['payable_invoices'], 'amount'));
|
|
$this->currency = $this->getContext()['invitation']->contact->client->currency();
|
|
$this->payableInvoices = $this->getContext()['payable_invoices'];
|
|
}
|
|
|
|
public function checkValue(array $payableInvoices)
|
|
{
|
|
$this->errors = '';
|
|
|
|
$settings = $this->getContext()['settings'];
|
|
|
|
foreach($payableInvoices as $key => $invoice){
|
|
$payableInvoices[$key]['amount'] = Number::parseFloat($invoice['formatted_amount']);
|
|
$payableInvoices[$key]['formatted_currency'] = Number::FormatMoney($payableInvoices[$key]['amount'], $this->getContext()['invitation']->contact->client);
|
|
}
|
|
|
|
$input_amount = collect($payableInvoices)->sum('amount');
|
|
|
|
if($settings->client_portal_allow_under_payment)
|
|
{
|
|
if($input_amount <= $settings->client_portal_under_payment_minimum || $input_amount <= 0){
|
|
// return error message under payment too low.
|
|
$this->errors = ctrans('texts.minimum_required_payment', ['amount' => max($settings->client_portal_under_payment_minimum, 1)]);
|
|
$this->dispatch('errorMessageUpdate', errors: $this->errors);
|
|
}
|
|
}
|
|
|
|
if(!$settings->client_portal_allow_over_payment && ($input_amount > $this->invoice_amount)){
|
|
$this->errors = ctrans('texts.over_payments_disabled');
|
|
$this->dispatch('errorMessageUpdate', errors: $this->errors);
|
|
}
|
|
|
|
if(!$this->errors){
|
|
$this->setContext('payable_invoices', $payableInvoices);
|
|
$this->dispatch('payable-amount', payable_amount: $input_amount );
|
|
}
|
|
}
|
|
|
|
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
{
|
|
return render('flow2.under-over-payments');
|
|
}
|
|
}
|