diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index 24ff46adb4d1..7d059d0d7b54 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -26,6 +26,7 @@ use App\Models\Invoice; use App\Models\RecurringInvoice; use App\Models\Subscription; use App\Notifications\Ninja\NewAccountNotification; +use App\Repositories\RecurringInvoiceRepository; use App\Repositories\SubscriptionRepository; use App\Utils\Ninja; use App\Utils\Traits\MakesHash; @@ -178,6 +179,15 @@ class NinjaPlanController extends Controller ->increment() ->queue(); + + $old_recurring = RecurringInvoice::where('company_id', config('ninja.ninja_default_company_id'))->where('client_id', $client->id)->first(); + + if($old_recurring) { + $old_recurring->service()->stop()->save(); + $old_recurring_repo = new RecurringInvoiceRepository(); + $old_recurring_repo->archive($old_recurring); + } + $ninja_company = Company::on('db-ninja-01')->find(config('ninja.ninja_default_company_id')); $ninja_company->notification(new NewAccountNotification($subscription->company->account, $client))->ninja(); diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 8ceb727514d2..2da3e9564946 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -631,7 +631,6 @@ class StripePaymentDriver extends BaseDriver // if($request->type === 'payment_intent.requires_action') // nlog($request->all()); - //payment_intent.succeeded - this will confirm or cancel the payment if($request->type === 'customer.source.updated') { $ach = new ACH($this); $ach->updateBankAccount($request->all()); @@ -639,10 +638,10 @@ class StripePaymentDriver extends BaseDriver if($request->type === 'payment_intent.processing') { PaymentIntentProcessingWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(2)); - return response()->json([], 200); } + //payment_intent.succeeded - this will confirm or cancel the payment if ($request->type === 'payment_intent.succeeded') { PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(5, 10)));