1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Working on payment submissions

This commit is contained in:
David Bomba 2024-02-20 16:05:00 +11:00
parent f3316277c3
commit c8f7e9e250
4 changed files with 36 additions and 9 deletions

View File

@ -29,7 +29,6 @@ class Methods extends Component
{
if (auth()->guard('contact')->guest()) {
$this->dispatch('purchase.forward', component: Authentication::class);
return;
}
@ -51,12 +50,11 @@ class Methods extends Component
$this->context['client_id'] = $contact->client->hashed_id;
nlog($this->context);
$invoice = $this->subscription
->calc()
->buildPurchaseInvoice($this->context)
->service()
->markSent()
->fillDefaults()
->adjustInventory()
->save();
@ -75,6 +73,8 @@ class Methods extends Component
? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency())
: \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency());
nlog($invoice->toArray());
$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);

View File

@ -13,6 +13,7 @@
namespace App\Livewire\BillingPortal;
use Livewire\Component;
use App\Services\ClientPortal\InstantPayment;
class Submit extends Component
{
@ -21,6 +22,28 @@ class Submit extends Component
public function mount()
{
// This is right place to check if everything is set up correctly.
// <input type="hidden" name="action" value="payment">
// <input type="hidden" name="invoices[]" value="{{ $context['form']['invoice_hashed_id'] ?? '' }}">
// <input type="hidden" name="payable_invoices[0][amount]" value="{{ $context['form']['payable_amount'] ?? '' }}">
// <input type="hidden" name="payable_invoices[0][invoice_id]" value="{{ $context['form']['invoice_hashed_id'] ?? '' }}">
// <input type="hidden" name="company_gateway_id" value="{{ $context['form']['company_gateway_id'] ?? '' }}"/>
// <input type="hidden" name="payment_method_id" value="{{ $context['form']['payment_method_id'] ?? '' }}"/>
//hash
//sidebar = h
// $request = new \Illuminate\Http\Request([
// 'sidebar' => 'hidden',
// 'hash' => $this->context['hash'],
// 'action' => 'payment',
// 'invoices[]' => $this->context['form']['invoice_hashed_id'],
// 'payable_invoices[0][amount]' => $this->context['form']['payable_amount'],
// 'payable_invoices[0][invoice_id]' => $this->context['form']['invoice_hashed_id'],
// 'company_gateway_id' => $this->context['form']['company_gateway_id'],
// 'payment_method_id' => $this->context['form']['payment_method_id'],
// ]);
// return (new InstantPayment($request))->run();
$this->dispatch('purchase.submit');
}

View File

@ -46,6 +46,7 @@ class InstantPayment
{
nlog($this->request->all());
/** @var \App\Models\ClientContact $cc */
$cc = auth()->guard('contact')->user();
$cc->first_name = $this->request->contact_first_name;

View File

@ -13,14 +13,12 @@ namespace App\Services\Subscription;
use App\Models\Invoice;
use App\Models\Subscription;
use App\Models\ClientContact;
use Illuminate\Support\Carbon;
use App\DataMapper\InvoiceItem;
use App\Factory\InvoiceFactory;
use App\Utils\Traits\MakesHash;
use App\Helpers\Invoice\ProRata;
use App\Repositories\InvoiceRepository;
use App\Repositories\SubscriptionRepository;
/**
* SubscriptionCalculator.
@ -30,7 +28,13 @@ class SubscriptionCalculator
use MakesHash;
public function __construct(public Subscription $subscription){}
/**
* BuildPurchaseInvoice
*
* @param array $context
* @return Invoice
*/
public function buildPurchaseInvoice(array $context): Invoice
{
@ -54,7 +58,9 @@ class SubscriptionCalculator
/**
* Build Line Items
*
* @param array $context
*
* @return array
*/
private function buildItems(array $context): array
@ -69,9 +75,6 @@ class SubscriptionCalculator
return $product['quantity'] >= 1;
});
nlog("items");
nlog($items);
return collect($items)->map(function ($item){
$line_item = new InvoiceItem();
$line_item->product_key = $item['product']['product_key'];