diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index a16544e1e5b3..b3a5148c7fc4 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -262,6 +262,7 @@ class BillingPortalPurchase extends Component 'client_contact_id' => $this->contact->hashed_id, ]], 'user_input_promo_code' => $this->coupon, + 'coupon' => $this->coupon, 'quantity' => $this->quantity, ]; @@ -273,6 +274,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 afba9ba52f23..cb639b5e219f 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(); }