芝麻web文件管理V1.00
编辑当前文件:/home/digitalh/yeahea.digitalhubbd.com/app/Jobs/SubscribeShopToNewPlan.php
merchant = $merchant; $this->plan = $plan; $this->payment_method = $payment_method; } /** * Execute the job. * * @return void */ public function handle() { $shop = $this->merchant->owns; // Create subscription intance $subscriptionPlan = SubscriptionPlan::findOrFail($this->plan); $subscription = $shop->newSubscription($subscriptionPlan); // Subtract the used trial days with the new subscription if ($shop->onGenericTrial()) { $trialDays = Carbon::now()->lt($shop->trial_ends_at) ? Carbon::now()->diffInDays($shop->trial_ends_at) : null; } else { $trialDays = (bool) config('system_settings.trial_days') ? config('system_settings.trial_days') : null; } // Set trial days if ($trialDays) { $subscription->trialDays($trialDays); } else { $subscription->skipTrial(); } // Create subscription try { $subscription = $subscription->create($this->payment_method, [ 'email' => $this->merchant->email, ]); // Update shop model $shop->forceFill([ 'current_billing_plan' => $this->plan, 'trial_ends_at' => $subscription->trial_ends_at, ])->save(); } catch (IncompletePayment $e) { return redirect()->route('cashier.payment', [$e->payment->id, 'redirect' => route('home')]); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } } }