diff --git a/app/Helpers/ClientPortal.php b/app/Helpers/ClientPortal.php index d635a1aea65e..f5bea3f91554 100644 --- a/app/Helpers/ClientPortal.php +++ b/app/Helpers/ClientPortal.php @@ -26,7 +26,7 @@ function isActive($page, bool $boolean = false) $current_page = Route::currentRouteName(); $action = Route::currentRouteAction(); // string - $show = str_replace(['.show','payment_methodss','documentss','subscriptionss'],['s.index','payment_methods','documents','subscriptions'], $current_page); + $show = str_replace(['.show','payment_methodss','documentss','subscriptionss','paymentss'],['s.index','payment_methods','documents','subscriptions','payments'], $current_page); if ($page == $current_page && $boolean) { return true; diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 9267853d0af6..115009ccdd55 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -160,7 +160,7 @@ class PaymentController extends Controller } if (property_exists($payment_hash->data, 'billing_context')) { - $billing_subscription = \App\Models\Subscription::find($payment_hash->data->billing_context->subscription_id); + $billing_subscription = \App\Models\Subscription::find($this->decodePrimaryKey($payment_hash->data->billing_context->subscription_id)); return (new SubscriptionService($billing_subscription))->completePurchase($payment_hash); } diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 496c241b79aa..8ec53b204e60 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -403,10 +403,10 @@ class BillingPortalPurchase extends Component ->save(); Cache::put($this->hash, [ - 'subscription_id' => $this->subscription->id, + 'subscription_id' => $this->subscription->hashed_id, 'email' => $this->email ?? $this->contact->email, - 'client_id' => $this->contact->client->id, - 'invoice_id' => $this->invoice->id, + 'client_id' => $this->contact->client->hashed_id, + 'invoice_id' => $this->invoice->hashed_id, 'context' => 'purchase', 'campaign' => $this->campaign, ], now()->addMinutes(60)); diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index 8ff7b6114434..f4dd70ac1310 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -526,7 +526,7 @@ class BillingPortalPurchasev2 extends Component } $data = [ - 'client_id' => $this->contact->client->id, + 'client_id' => $this->contact->client->hashed_id, 'date' => now()->format('Y-m-d'), 'invitations' => [[ 'key' => '', @@ -547,10 +547,10 @@ class BillingPortalPurchasev2 extends Component ->save(); Cache::put($this->hash, [ - 'subscription_id' => $this->subscription->id, + 'subscription_id' => $this->subscription->hashed_id, 'email' => $this->email ?? $this->contact->email, - 'client_id' => $this->contact->client->id, - 'invoice_id' => $this->invoice->id, + 'client_id' => $this->contact->client->hashed_id, + 'invoice_id' => $this->invoice->hashed_id, 'context' => 'purchase', 'campaign' => $this->campaign, 'bundle' => $this->bundle, @@ -567,8 +567,8 @@ class BillingPortalPurchasev2 extends Component return $this->subscription->service()->startTrial([ 'email' => $this->email ?? $this->contact->email, 'quantity' => $this->quantity, - 'contact_id' => $this->contact->id, - 'client_id' => $this->contact->client->id, + 'contact_id' => $this->contact->hashed_id, + 'client_id' => $this->contact->client->hashed_id, 'bundle' => $this->bundle, ]); } diff --git a/app/Http/Livewire/SubscriptionPlanSwitch.php b/app/Http/Livewire/SubscriptionPlanSwitch.php index 47e4ce5a0935..e5a46238ff9d 100644 --- a/app/Http/Livewire/SubscriptionPlanSwitch.php +++ b/app/Http/Livewire/SubscriptionPlanSwitch.php @@ -106,11 +106,11 @@ class SubscriptionPlanSwitch extends Component ]); Cache::put($this->hash, [ - 'subscription_id' => $this->target->id, - 'target_id' => $this->target->id, - 'recurring_invoice' => $this->recurring_invoice->id, - 'client_id' => $this->recurring_invoice->client->id, - 'invoice_id' => $this->state['invoice']->id, + 'subscription_id' => $this->target->hashed_id, + 'target_id' => $this->target->hashed_id, + 'recurring_invoice' => $this->recurring_invoice->hashed_id, + 'client_id' => $this->recurring_invoice->client->hashed_id, + 'invoice_id' => $this->state['invoice']->hashed_id, 'context' => 'change_plan', now()->addMinutes(60), ] ); diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index 12d79b9b80b5..708206c15a3f 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -319,7 +319,7 @@ class MatchBankTransactions implements ShouldQueue }); - }, 1); + }, 2); if(!$this->invoice) return; diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index e17e3f648518..1568a0658021 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -289,7 +289,7 @@ class BaseDriver extends AbstractPaymentDriver event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); if (property_exists($this->payment_hash->data, 'billing_context') && $status == Payment::STATUS_COMPLETED) { - $billing_subscription = \App\Models\Subscription::find($this->payment_hash->data->billing_context->subscription_id); + $billing_subscription = \App\Models\Subscription::find($this->decodePrimaryKey($this->payment_hash->data->billing_context->subscription_id)); // To access campaign hash => $this->payment_hash->data->billing_context->campaign; // To access campaign data => Cache::get(CAMPAIGN_HASH) diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 3fb7b920f0ce..3a12be819285 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -42,7 +42,7 @@ class ClientService $this->client->balance += $amount; $this->client->save(); - }, 1); + }, 2); } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); @@ -63,7 +63,7 @@ class ClientService $this->client->paid_to_date += $paid_to_date; $this->client->save(); - }, 1); + }, 2); } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); @@ -82,7 +82,7 @@ class ClientService $this->client->paid_to_date += $amount; $this->client->save(); - }, 1); + }, 2); return $this; diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index e002ad1288d7..775a3dbd29f9 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -230,6 +230,14 @@ class InstantPayment elseif($this->request->hash){ $hash_data['billing_context'] = Cache::get($this->request->hash); } + elseif($old_hash = PaymentHash::where('fee_invoice_id', $first_invoice->id)->whereNull('payment_id')->first()) { + + if(isset($old_hash->data->billing_context)) + { + $hash_data['billing_context'] = $old_hash->data->billing_context; + } + + } $payment_hash = new PaymentHash; $payment_hash->hash = Str::random(32); diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index a5a769ba2f5d..d14dbdd91228 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -51,7 +51,7 @@ class DeletePayment } - }, 1); + }, 2); return $this->payment; diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 3af24a43ea7a..732fca034623 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -167,7 +167,7 @@ class SubscriptionService public function startTrial(array $data) { // Redirects from here work just fine. Livewire will respect it. - $client_contact = ClientContact::find($data['contact_id']); + $client_contact = ClientContact::find($this->decodePrimaryKey($data['contact_id'])); if(!$this->subscription->trial_enabled) return new \Exception("Trials are disabled for this product"); @@ -734,7 +734,7 @@ class SubscriptionService { nlog("handle plan change"); - $old_recurring_invoice = RecurringInvoice::find($payment_hash->data->billing_context->recurring_invoice); + $old_recurring_invoice = RecurringInvoice::find($this->decodePrimaryKey($payment_hash->data->billing_context->recurring_invoice)); if(!$old_recurring_invoice) return $this->handleRedirect('/client/recurring_invoices/'); diff --git a/app/Utils/Traits/SubscriptionHooker.php b/app/Utils/Traits/SubscriptionHooker.php index e23fa58a4eff..8dfaba0171fc 100644 --- a/app/Utils/Traits/SubscriptionHooker.php +++ b/app/Utils/Traits/SubscriptionHooker.php @@ -28,7 +28,7 @@ trait SubscriptionHooker ]; if(!isset($subscription->webhook_configuration['post_purchase_url']) && !isset($subscription->webhook_configuration['post_purchase_rest_method'])) - return; + return []; if (count($subscription->webhook_configuration['post_purchase_headers']) >= 1) { $headers = array_merge($headers, $subscription->webhook_configuration['post_purchase_headers']);