diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index adc7f4408cda..7e78b6aceeef 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -319,7 +319,8 @@ class PaymentController extends Controller * @return Response The response view */ public function credit_response(Request $request) - { + { + $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..348b0573938e 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}"); @@ -514,7 +522,7 @@ class SubscriptionService */ private function handlePlanChange($payment_hash) { - +nlog("handle plan change"); $old_recurring_invoice = RecurringInvoice::find($payment_hash->data->billing_context->recurring_invoice); $recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice); diff --git a/config/ninja.php b/config/ninja.php index d0afe5adc806..675ce11ae92d 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -15,7 +15,7 @@ return [ 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), 'app_version' => '5.2.7', - 'app_tag' => '5.2.7-release', + 'app_tag' => '5.2.7', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),