diff --git a/app/Livewire/BillingPortal/Payments/Methods.php b/app/Livewire/BillingPortal/Payments/Methods.php
index 895d09d75b..1d0eba9259 100644
--- a/app/Livewire/BillingPortal/Payments/Methods.php
+++ b/app/Livewire/BillingPortal/Payments/Methods.php
@@ -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);
diff --git a/app/Livewire/BillingPortal/Submit.php b/app/Livewire/BillingPortal/Submit.php
index 20b2070c2e..cc9d03520a 100644
--- a/app/Livewire/BillingPortal/Submit.php
+++ b/app/Livewire/BillingPortal/Submit.php
@@ -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.
+ //
+ //
+ //
+ //
+ //
+ //
+ //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');
}
diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php
index 8868a3df8d..3b5451cb54 100644
--- a/app/Services/ClientPortal/InstantPayment.php
+++ b/app/Services/ClientPortal/InstantPayment.php
@@ -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;
diff --git a/app/Services/Subscription/SubscriptionCalculator.php b/app/Services/Subscription/SubscriptionCalculator.php
index 223fb5b67c..59a152cee1 100644
--- a/app/Services/Subscription/SubscriptionCalculator.php
+++ b/app/Services/Subscription/SubscriptionCalculator.php
@@ -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'];