diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index adc7f4408cda..1b9926c9b08f 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -319,7 +319,10 @@ class PaymentController extends Controller * @return Response The response view */ public function credit_response(Request $request) - { + { + nlog("credit response"); + nlog($request->all()); + $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first(); /* Hydrate the $payment */ diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 6960b8dd73ae..be96f56ea20f 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -309,6 +309,9 @@ class SubscriptionService */ private function calculateProRataRefundItems($invoice, $is_credit = false) :array { + if(!$invoice) + return []; + /* depending on whether we are creating an invoice or a credit*/ $multiplier = $is_credit ? 1 : -1; @@ -444,6 +447,8 @@ class SubscriptionService ->withTrashed() ->orderBy('id', 'desc') ->first(); + if(!$last_invoice) + return true; if($last_invoice->balance > 0) { @@ -489,7 +494,10 @@ class SubscriptionService ->orderBy('id', 'desc') ->first(); - if($last_invoice->balance > 0) + if(!$last_invoice){ + //do nothing + } + else if($last_invoice->balance > 0) { $pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription); nlog("pro rata charge = {$pro_rata_charge_amount}");