mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-08-07 10:01:47 -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.9 KiB
PHP
80 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/
|
|
|
|
namespace App\Livewire\BillingPortal\Payments;
|
|
|
|
use Livewire\Component;
|
|
use App\Models\Subscription;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class Methods extends Component
|
|
{//@todo this breaks down when the cart is in front of the login - we have no context on the user - nor their country/currency
|
|
public Subscription $subscription;
|
|
|
|
public array $context;
|
|
|
|
public array $methods;
|
|
|
|
public function mount(): void
|
|
{
|
|
$total = collect($this->context['products'])->sum('total_raw');
|
|
|
|
$methods = auth()->guard('contact')->user()->client->service()->getPaymentMethods($total); //@todo this breaks down when the cart is in front of the login - we have no context on the user - nor their country/currency()
|
|
$this->methods = $methods;
|
|
}
|
|
|
|
public function handleSelect(string $company_gateway_id, string $gateway_type_id)
|
|
{
|
|
/** @var \App\Models\ClientContact $contact */
|
|
$contact = auth()->guard('contact')->user();
|
|
|
|
$this->dispatch('purchase.context', property: 'client_id', value: $contact->client->hashed_id);
|
|
|
|
$this->context['client_id'] = $contact->client->hashed_id;
|
|
|
|
$invoice = $this->subscription
|
|
->calc()
|
|
->buildPurchaseInvoice($this->context)
|
|
->service()
|
|
->markSent()
|
|
->fillDefaults()
|
|
->adjustInventory()
|
|
->save();
|
|
|
|
Cache::put($this->context['hash'], [
|
|
'subscription_id' => $this->subscription->hashed_id,
|
|
'email' => $contact->email,
|
|
'client_id' => $contact->client->hashed_id,
|
|
'invoice_id' => $invoice->hashed_id,
|
|
'context' => 'purchase',
|
|
'campaign' => $this->context['campaign'],
|
|
'bundle' => $this->context['bundle'],
|
|
], now()->addMinutes(60));
|
|
|
|
$payable_amount = $invoice->partial > 0
|
|
? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency())
|
|
: \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency());
|
|
|
|
$this->dispatch('purchase.context', property: 'form.company_gateway_id', value: $company_gateway_id);
|
|
$this->dispatch('purchase.context', property: 'form.payment_method_id', value: $gateway_type_id);
|
|
$this->dispatch('purchase.context', property: 'form.invoice_hashed_id', value: $invoice->hashed_id);
|
|
$this->dispatch('purchase.context', property: 'form.payable_amount', value: $payable_amount);
|
|
|
|
$this->dispatch('purchase.next');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('billing-portal.v3.payments.methods');
|
|
}
|
|
}
|