mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 04:48:40 -05:00 
			
		
		
		
	Merge pull request #6158 from turbo124/v5-develop
Fixes for subscriptions
This commit is contained in:
		
						commit
						1ac4aa61a9
					
				@ -320,6 +320,7 @@ class PaymentController extends Controller
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function credit_response(Request $request)
 | 
					    public function credit_response(Request $request)
 | 
				
			||||||
    {   
 | 
					    {   
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
 | 
					        $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Hydrate the $payment */
 | 
					        /* Hydrate the $payment */
 | 
				
			||||||
 | 
				
			|||||||
@ -309,6 +309,9 @@ class SubscriptionService
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private function calculateProRataRefundItems($invoice, $is_credit = false) :array
 | 
					    private function calculateProRataRefundItems($invoice, $is_credit = false) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if(!$invoice)
 | 
				
			||||||
 | 
					            return [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* depending on whether we are creating an invoice or a credit*/
 | 
					        /* depending on whether we are creating an invoice or a credit*/
 | 
				
			||||||
        $multiplier = $is_credit ? 1 : -1;
 | 
					        $multiplier = $is_credit ? 1 : -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -444,6 +447,8 @@ class SubscriptionService
 | 
				
			|||||||
                                         ->withTrashed()
 | 
					                                         ->withTrashed()
 | 
				
			||||||
                                         ->orderBy('id', 'desc')
 | 
					                                         ->orderBy('id', 'desc')
 | 
				
			||||||
                                         ->first();
 | 
					                                         ->first();
 | 
				
			||||||
 | 
					        if(!$last_invoice)
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($last_invoice->balance > 0)
 | 
					        if($last_invoice->balance > 0)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -489,7 +494,10 @@ class SubscriptionService
 | 
				
			|||||||
                                         ->orderBy('id', 'desc')
 | 
					                                         ->orderBy('id', 'desc')
 | 
				
			||||||
                                         ->first();
 | 
					                                         ->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);
 | 
					            $pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription);
 | 
				
			||||||
            nlog("pro rata charge = {$pro_rata_charge_amount}");
 | 
					            nlog("pro rata charge = {$pro_rata_charge_amount}");
 | 
				
			||||||
@ -514,7 +522,7 @@ class SubscriptionService
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private function handlePlanChange($payment_hash)
 | 
					    private function handlePlanChange($payment_hash)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					nlog("handle plan change");
 | 
				
			||||||
        $old_recurring_invoice = RecurringInvoice::find($payment_hash->data->billing_context->recurring_invoice);
 | 
					        $old_recurring_invoice = RecurringInvoice::find($payment_hash->data->billing_context->recurring_invoice);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice);
 | 
					        $recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice);
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@ return [
 | 
				
			|||||||
    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
					    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
				
			||||||
    'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
 | 
					    'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
 | 
				
			||||||
    'app_version' => '5.2.7',
 | 
					    'app_version' => '5.2.7',
 | 
				
			||||||
    'app_tag' => '5.2.7-release',
 | 
					    'app_tag' => '5.2.7',
 | 
				
			||||||
    'minimum_client_version' => '5.0.16',
 | 
					    'minimum_client_version' => '5.0.16',
 | 
				
			||||||
    'terms_version' => '1.0.1',
 | 
					    'terms_version' => '1.0.1',
 | 
				
			||||||
    'api_secret' => env('API_SECRET', ''),
 | 
					    'api_secret' => env('API_SECRET', ''),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user