mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Updated flow
This commit is contained in:
parent
76f6c51a1b
commit
985cdafdc2
@ -12,15 +12,16 @@
|
|||||||
|
|
||||||
namespace App\Livewire;
|
namespace App\Livewire;
|
||||||
|
|
||||||
use App\Livewire\Flow2\Terms;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Livewire\Flow2\PaymentMethod;
|
|
||||||
use App\Livewire\Flow2\Signature;
|
|
||||||
use Livewire\Attributes\On;
|
use Livewire\Attributes\On;
|
||||||
|
use App\Livewire\Flow2\Terms;
|
||||||
|
use App\Livewire\Flow2\Signature;
|
||||||
use Livewire\Attributes\Computed;
|
use Livewire\Attributes\Computed;
|
||||||
use Livewire\Attributes\Reactive;
|
use Livewire\Attributes\Reactive;
|
||||||
|
use App\Livewire\Flow2\PaymentMethod;
|
||||||
|
use App\Livewire\Flow2\ProcessPayment;
|
||||||
|
|
||||||
class InvoicePay extends Component
|
class InvoicePay extends Component
|
||||||
{
|
{
|
||||||
@ -30,33 +31,58 @@ class InvoicePay extends Component
|
|||||||
|
|
||||||
public $settings;
|
public $settings;
|
||||||
|
|
||||||
private $invite;
|
|
||||||
|
|
||||||
private $variables;
|
|
||||||
|
|
||||||
public $terms_accepted = false;
|
public $terms_accepted = false;
|
||||||
|
|
||||||
public $signature_accepted = false;
|
public $signature_accepted = false;
|
||||||
|
|
||||||
|
public $payment_method_accepted = false;
|
||||||
|
|
||||||
|
public array $context = [];
|
||||||
|
|
||||||
|
#[On('update.context')]
|
||||||
|
public function handleContext(string $property, $value): self
|
||||||
|
{
|
||||||
|
|
||||||
|
data_set($this->context, $property, $value);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('terms-accepted')]
|
||||||
|
public function termsAccepted()
|
||||||
|
{
|
||||||
|
nlog("Terms accepted");
|
||||||
|
// $this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations();
|
||||||
|
$this->terms_accepted =true;
|
||||||
|
}
|
||||||
|
|
||||||
#[On('signature-captured')]
|
#[On('signature-captured')]
|
||||||
public function signatureCaptured($base64)
|
public function signatureCaptured($base64)
|
||||||
{
|
{
|
||||||
nlog("signature captured");
|
nlog("signature captured");
|
||||||
|
|
||||||
$this->signature_accepted = true;
|
$this->signature_accepted = true;
|
||||||
$this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations();
|
$invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations();
|
||||||
$this->invite->signature_base64 = $base64;
|
$invite->signature_base64 = $base64;
|
||||||
$this->invite->signature_date = now()->addSeconds($this->invite->contact->client->timezone_offset());
|
$invite->signature_date = now()->addSeconds($invite->contact->client->timezone_offset());
|
||||||
$this->invite->save();
|
$this->context['signature'] = $base64;
|
||||||
|
$invite->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[On('terms-accepted')]
|
#[On('payment-method-selected')]
|
||||||
public function termsAccepted()
|
public function paymentMethodSelected($company_gateway_id, $gateway_type_id, $amount)
|
||||||
{
|
{
|
||||||
nlog("Terms accepted");
|
$this->context['company_gateway_id'] = $company_gateway_id;
|
||||||
$this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations();
|
$this->context['gateway_type_id'] = $gateway_type_id;
|
||||||
$this->terms_accepted =true;
|
$this->context['amount'] = $amount;
|
||||||
|
$this->context['pre_payment'] = false;
|
||||||
|
$this->context['is_recurring'] = false;
|
||||||
|
$this->context['payable_invoices'] = ['invoice_id' => $this->context['invoice']->hashed_id, 'amount' => $this->context['invoice']->balance];
|
||||||
|
$this->context['invitation_id'] = $this->invitation_id;
|
||||||
|
|
||||||
|
// $this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations();
|
||||||
|
$this->payment_method_accepted =true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Computed()]
|
#[Computed()]
|
||||||
@ -68,7 +94,10 @@ class InvoicePay extends Component
|
|||||||
if(!$this->signature_accepted)
|
if(!$this->signature_accepted)
|
||||||
return Signature::class;
|
return Signature::class;
|
||||||
|
|
||||||
return PaymentMethod::class;
|
if(!$this->payment_method_accepted)
|
||||||
|
return PaymentMethod::class;
|
||||||
|
|
||||||
|
return ProcessPayment::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Computed()]
|
#[Computed()]
|
||||||
@ -83,25 +112,19 @@ class InvoicePay extends Component
|
|||||||
MultiDB::setDb($this->db);
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
// @phpstan-ignore-next-line
|
// @phpstan-ignore-next-line
|
||||||
$this->invite = \App\Models\InvoiceInvitation::with('invoice','contact.client','company')->withTrashed()->find($this->invitation_id);
|
$invite = \App\Models\InvoiceInvitation::with('invoice','contact.client','company')->withTrashed()->find($this->invitation_id);
|
||||||
$invoice = $this->invite->invoice;
|
$client = $invite->contact->client;
|
||||||
$company = $this->invite->company;
|
$variables = ($invite && auth()->guard('contact')->user()->client->getSetting('show_accept_invoice_terms')) ? (new HtmlEngine($invite))->generateLabelsAndValues() : false;
|
||||||
$contact = $this->invite->contact;
|
$settings = $client->getMergedSettings();
|
||||||
$client = $this->invite->contact->client;
|
$this->context['variables'] = $variables;
|
||||||
$this->variables = ($this->invite && auth()->guard('contact')->user()->client->getSetting('show_accept_invoice_terms')) ? (new HtmlEngine($this->invite))->generateLabelsAndValues() : false;
|
$this->context['invoice'] = $invite->invoice;
|
||||||
|
$this->context['settings'] = $settings;
|
||||||
$this->settings = $client->getMergedSettings();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return render('components.livewire.invoice-pay', [
|
return render('components.livewire.invoice-pay', [
|
||||||
'context' => [
|
'context' => $this->context
|
||||||
'settings' => $this->settings,
|
|
||||||
'invoice' => $this->invite->invoice,
|
|
||||||
'variables' => $this->variables,
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -183,6 +183,21 @@ class PaymentMethod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (($this->client->getSetting('use_credits_payment') == 'option' || $this->client->getSetting('use_credits_payment') == 'always') && $this->client->service()->getCreditBalance() > 0) {
|
||||||
|
// Show credits as only payment option if both statements are true. //?this does not really make sense as it does nothing....
|
||||||
|
// if (
|
||||||
|
// $this->client->service()->getCreditBalance() > $this->amount
|
||||||
|
// && $this->client->getSetting('use_credits_payment') == 'always') {
|
||||||
|
// $payment_urls = [];
|
||||||
|
// }
|
||||||
|
|
||||||
|
$this->payment_urls[] = [
|
||||||
|
'label' => ctrans('texts.apply_credit'),
|
||||||
|
'company_gateway_id' => CompanyGateway::GATEWAY_CREDIT,
|
||||||
|
'gateway_type_id' => GatewayType::CREDIT,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if (($this->client->getSetting('use_credits_payment') == 'option' || $this->client->getSetting('use_credits_payment') == 'always') && $this->client->service()->getCreditBalance() > 0) {
|
if (($this->client->getSetting('use_credits_payment') == 'option' || $this->client->getSetting('use_credits_payment') == 'always') && $this->client->service()->getCreditBalance() > 0) {
|
||||||
// Show credits as only payment option if both statements are true.
|
// Show credits as only payment option if both statements are true.
|
||||||
|
1
public/build/assets/app-4cad835a.css
vendored
Normal file
1
public/build/assets/app-4cad835a.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,10 @@
|
|||||||
|
<div>
|
||||||
|
@foreach($methods as $index => $method)
|
||||||
|
|
||||||
|
<button @click="$wire.dispatch('payment-method-selected', { company_gateway_id: {{ $method['company_gateway_id'] }}, gateway_type_id: {{ $method['gateway_type_id'] }}, amount: {{ $amount }} })">
|
||||||
|
{{ $method['label'] }}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user