Merge pull request #6158 from turbo124/v5-develop

Fixes for subscriptions
This commit is contained in:
David Bomba 2021-06-29 17:27:06 +10:00 committed by GitHub
commit 1ac4aa61a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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', ''),