diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 8ec26e7238..d037bcf64b 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -236,6 +236,7 @@ class CreateSingleAccount extends Command $webhook_config = [ 'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan', 'post_purchase_rest_method' => 'POST', + 'post_purchase_headers' => [], ]; $sub = SubscriptionFactory::create($company->id, $user->id); diff --git a/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php b/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php index 2a185cf82f..1dbe98ca4b 100644 --- a/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php +++ b/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php @@ -34,8 +34,15 @@ class SubscriptionPlanSwitchController extends Controller $amount = $recurring_invoice->subscription->service()->calculateUpgradePrice($recurring_invoice, $target); +nlog($amount); + + //if($amount == null) + //please show account upgrade unavailable + //@ben + return render('subscriptions.switch', [ - 'subscription' => $subscription, + 'subscription' => $recurring_invoice->subscription, + 'recurring_invoice' => $recurring_invoice, 'target' => $target, 'amount' => $amount, ]); diff --git a/app/Http/Livewire/SubscriptionPlanSwitch.php b/app/Http/Livewire/SubscriptionPlanSwitch.php index a6afc69c44..b6a07279df 100644 --- a/app/Http/Livewire/SubscriptionPlanSwitch.php +++ b/app/Http/Livewire/SubscriptionPlanSwitch.php @@ -19,11 +19,21 @@ use Livewire\Component; class SubscriptionPlanSwitch extends Component { + /** + * @var RecurringInvoice + */ + public $recurring_invoice; + /** * @var Subscription */ public $subscription; + /** + * @var ?float + */ + public $amount; + /** * @var Subscription */ @@ -62,7 +72,9 @@ class SubscriptionPlanSwitch extends Component public function mount() { - $this->total = $this->subscription->service()->getPriceBetweenSubscriptions($this->subscription, $this->target); + // $this->total = $this->subscription->service()->getPriceBetweenSubscriptions($this->subscription, $this->target); + + $this->total = $this->amount; $this->methods = $this->contact->client->service()->getPaymentMethods(100); diff --git a/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php b/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php index 8877fb060e..4c05a0fbab 100644 --- a/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php +++ b/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php @@ -17,7 +17,7 @@ class ShowPlanSwitchRequest extends FormRequest */ public function authorize() { - return (bool)$this->subscription->allow_plan_changes; + return (bool)$this->recurring_invoice->subscription->allow_plan_changes; } /** diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index ed38ba8abd..ab8a41ab4a 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -209,7 +209,8 @@ class CheckoutComPaymentDriver extends BaseDriver $payment = new \Checkout\Models\Payments\Payment($method, $this->client->getCurrencyCode()); $payment->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode()); - $payment->reference = $cgt->meta->last4 . '-' . now(); + //$payment->reference = $cgt->meta->last4 . '-' . now(); + $payment->reference = $invoice->number . '-' . now(); $request = new PaymentResponseRequest(); $request->setMethod('POST'); diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index f372bcd7c0..0a6fc384e3 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -196,7 +196,8 @@ class SubscriptionService ->where('balance', '>', 0); $outstanding_amounts = $outstanding->sum('balance'); - $outstanding_invoices = $outstanding->get(); + // $outstanding_invoices = $outstanding->get(); + $outstanding_invoices = $outstanding; if ($outstanding->count() == 0){ //nothing outstanding