From fdd1601120e0ddd6a010c35a7e96cf6931ed4f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Sat, 20 Mar 2021 23:15:26 +0100 Subject: [PATCH] wip --- app/Http/Livewire/BillingPortalPurchase.php | 2 ++ app/PaymentDrivers/BaseDriver.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 619a9a8366..8ffca446e9 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -133,6 +133,7 @@ class BillingPortalPurchase extends Component 'client_contact_id' => $this->contact->hashed_id, ]], 'user_input_promo_code' => $this->coupon, + 'coupon' => $this->coupon, 'quantity' => 1, // Option to increase quantity ]; @@ -144,6 +145,7 @@ class BillingPortalPurchase extends Component ->save(); Cache::put($this->hash, [ + 'billing_subscription_id' => $this->billing_subscription->id, 'email' => $this->email ?? $this->contact->email, 'client_id' => $this->contact->client->id, 'invoice_id' => $this->invoice->id], diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 03ef21bb33..a9250582a1 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -241,7 +241,11 @@ class BaseDriver extends AbstractPaymentDriver event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); - (new BillingSubscriptionService)->completePurchase($this->payment_hash); +// if (property_exists($this->payment_hash->data, 'billing_context')) { +// $billing_subscription = \App\Models\BillingSubscription::find($this->payment_hash->data->billing_context->billing_subscription_id); +// +// (new BillingSubscriptionService($billing_subscription))->completePurchase($this->payment_hash); +// } return $payment->service()->applyNumber()->save(); }