app_manager 1.1.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile.lock +2 -2
 - data/README.md +20 -1
 - data/app/controllers/app_manager/charges_controller.rb +17 -3
 - data/app/controllers/app_manager/plans_controller.rb +20 -5
 - data/lib/app_manager/client/plans.rb +4 -0
 - data/lib/app_manager/fail_safe.rb +55 -11
 - data/lib/app_manager/graphql_helper.rb +26 -0
 - data/lib/app_manager/model.rb +74 -17
 - data/lib/app_manager/version.rb +1 -1
 - data/lib/generators/app_manager/install/templates/app_manager.rb.tt +1 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3ef86306a34e83be7d439ecda3ca318a33146373c0a5f8cd910d5da1cf06d587
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1239cc87364f045b966f9f2ccc24ca770c7fdd07dda704b25d7b37bf2a49dc05
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: db78e088159f14d5bad35456c2a3b41e87e5e813bcd92a12c32562d8882ba698e6eae97f6a7807e8b94ccf6673234f6cd58ef3c8846c40e6df3a97dbe6e8f266
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d9d6dcb07015cde6b085473762cdffa39f12bf03ed7d2af0c9c79fe6849b29338b839f0f31712fd362fa7b037318bf9fa72754e0847ca09fe3a5f86a4f974a75
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                app_manager (1. 
     | 
| 
      
 4 
     | 
    
         
            +
                app_manager (1.2.0)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  httparty
         
     | 
| 
       6 
6 
     | 
    
         
             
                  kaminari (>= 0.16.3)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  rails (>= 5.2.0)
         
     | 
| 
         @@ -146,7 +146,7 @@ GEM 
     | 
|
| 
       146 
146 
     | 
    
         
             
                  method_source (~> 1.0)
         
     | 
| 
       147 
147 
     | 
    
         
             
                public_suffix (4.0.6)
         
     | 
| 
       148 
148 
     | 
    
         
             
                racc (1.6.0)
         
     | 
| 
       149 
     | 
    
         
            -
                rack (2.2. 
     | 
| 
      
 149 
     | 
    
         
            +
                rack (2.2.4)
         
     | 
| 
       150 
150 
     | 
    
         
             
                rack-test (2.0.2)
         
     | 
| 
       151 
151 
     | 
    
         
             
                  rack (>= 1.3)
         
     | 
| 
       152 
152 
     | 
    
         
             
                rails (7.0.3)
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -171,7 +171,26 @@ and then you can use follwing methods with your shop objects. 
     | 
|
| 
       171 
171 
     | 
    
         | 
| 
       172 
172 
     | 
    
         
             
            @shop.get_plan # return current plan hash
         
     | 
| 
       173 
173 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
            @shop. 
     | 
| 
      
 174 
     | 
    
         
            +
            	if you pass @shop.get_plan(plan_id) it will return that particular plan hash like @shop.get_plan(311)
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
            @shop.get_charge # return current charge hash, it will return nil if current plan is free
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
            @shop.set_default_plan(plan_id=nil)  #if plan id is passed nil, then it will set the free(public and $0 price) to active and if passed it will set that plan to active plan
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
            @shop.get_plans_by_features(feature_slugs)  # pass feature_slugs as an array even if one slug and it will return plans array which have that slug found. Example: 
         
     | 
| 
      
 181 
     | 
    
         
            +
            	
         
     | 
| 
      
 182 
     | 
    
         
            +
            	@shop.get_plans_by_features(['quantity-based-discount'])
         
     | 
| 
      
 183 
     | 
    
         
            +
            	@shop.get_plans_by_features(['quantity-based-discount','multiple-discount-types'])
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
            	you can pass string argument 'exclude_current_plan' which will return all plans that matching features except current plan
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
      
 188 
     | 
    
         
            +
            	@shop.get_plans_by_features(['quantity-based-discount'],'exclude_current_plan')
         
     | 
| 
      
 189 
     | 
    
         
            +
            	@shop.get_plans_by_features(['quantity-based-discount','multiple-discount-types'],'exclude_current_plan')
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
            @shop.get_all_plans # return all app plans array
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
       175 
194 
     | 
    
         
             
            ```
         
     | 
| 
       176 
195 
     | 
    
         | 
| 
       177 
196 
     | 
    
         | 
| 
         @@ -13,8 +13,22 @@ module AppManager 
     | 
|
| 
       13 
13 
     | 
    
         
             
            	    		if !@shop.nil?
         
     | 
| 
       14 
14 
     | 
    
         
             
            	    		 plan_obj = AppManager::Client.new
         
     | 
| 
       15 
15 
     | 
    
         
             
            	    		 plan_data = plan_obj.get_plan(params[:plan_id],params[:shop])
         
     | 
| 
      
 16 
     | 
    
         
            +
            	    		 # render json: plan_data and return #use this to test plan failsafe api
         
     | 
| 
       16 
17 
     | 
    
         
             
            	    		 if plan_data.present? && plan_data.is_a?(Hash) 
         
     | 
| 
       17 
18 
     | 
    
         
             
                        		if plan_data['price'] == 0
         
     | 
| 
      
 19 
     | 
    
         
            +
                        			active_charge_data = plan_obj.get_charge(params[:shop])
         
     | 
| 
      
 20 
     | 
    
         
            +
                        			begin
         
     | 
| 
      
 21 
     | 
    
         
            +
                        				if active_charge_data && active_charge_data.any? && !active_charge_data['active_charge']['charge_id'].nil?
         
     | 
| 
      
 22 
     | 
    
         
            +
            	        					gq_obj = AppManager::GraphqlHelper.new(@shop.shopify_domain,@shop.shopify_token)
         
     | 
| 
      
 23 
     | 
    
         
            +
            	        					rec_cancel_data = gq_obj.recurring_charge_cancel_api_call(active_charge_data['active_charge']['charge_id'],@shop)
         
     | 
| 
      
 24 
     | 
    
         
            +
            								if !rec_cancel_data["errors"].present? && (rec_cancel_data["data"].present? && rec_cancel_data["data"]["appSubscriptionCancel"].present? && !rec_cancel_data["data"]["appSubscriptionCreate"]["userErrors"].any? && (rec_cancel_data["data"]["appSubscriptionCancel"]["appSubscription"]["status"] == 'CANCELLED'))
         
     | 
| 
      
 25 
     | 
    
         
            +
            									plan_obj.cancel_charge(params[:shop],active_charge_data['active_charge']['plan_id'])
         
     | 
| 
      
 26 
     | 
    
         
            +
            								end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    					end
         
     | 
| 
      
 28 
     | 
    
         
            +
                        			rescue Exception => e
         
     | 
| 
      
 29 
     | 
    
         
            +
                        				Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
      
 30 
     | 
    
         
            +
                        			end
         
     | 
| 
      
 31 
     | 
    
         
            +
                    				
         
     | 
| 
       18 
32 
     | 
    
         
             
                        			if @shop.update(@plan_field => params[:plan_id])
         
     | 
| 
       19 
33 
     | 
    
         
             
                        				begin
         
     | 
| 
       20 
34 
     | 
    
         
             
                        					AppManager::EventHandler.new('charge_created',{
         
     | 
| 
         @@ -23,7 +37,7 @@ module AppManager 
     | 
|
| 
       23 
37 
     | 
    
         
             
            								"previous_charge" => nil 	
         
     | 
| 
       24 
38 
     | 
    
         
             
            								})
         
     | 
| 
       25 
39 
     | 
    
         
             
                        				rescue Exception => e
         
     | 
| 
       26 
     | 
    
         
            -
                        					Rails.logger.info "APP  
     | 
| 
      
 40 
     | 
    
         
            +
                        					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       27 
41 
     | 
    
         
             
                        				end
         
     | 
| 
       28 
42 
     | 
    
         
             
                        				AppManager.clear_cache
         
     | 
| 
       29 
43 
     | 
    
         
             
                        				render json: {'redirect_url' => "#{app_url}?shop=#{params[:shop]}"}  and return true
         
     | 
| 
         @@ -78,7 +92,7 @@ module AppManager 
     | 
|
| 
       78 
92 
     | 
    
         
             
            							begin
         
     | 
| 
       79 
93 
     | 
    
         
             
            								plan_obj.cancel_charge(@shop[shopify_domain],@shop[@plan_field])
         
     | 
| 
       80 
94 
     | 
    
         
             
            							rescue Exception => e
         
     | 
| 
       81 
     | 
    
         
            -
            								Rails.logger.info "APP  
     | 
| 
      
 95 
     | 
    
         
            +
            								Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       82 
96 
     | 
    
         
             
            							end
         
     | 
| 
       83 
97 
     | 
    
         
             
            						end
         
     | 
| 
       84 
98 
     | 
    
         | 
| 
         @@ -96,7 +110,7 @@ module AppManager 
     | 
|
| 
       96 
110 
     | 
    
         
             
            								"previous_charge" => charge_data ? (charge_data['cancelled_charge'] || nil) : nil 	
         
     | 
| 
       97 
111 
     | 
    
         
             
            								})
         
     | 
| 
       98 
112 
     | 
    
         
             
            							rescue Exception => e
         
     | 
| 
       99 
     | 
    
         
            -
            								Rails.logger.info "APP  
     | 
| 
      
 113 
     | 
    
         
            +
            								Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
         
     | 
| 
       100 
114 
     | 
    
         
             
            							end
         
     | 
| 
       101 
115 
     | 
    
         
             
            						end     					
         
     | 
| 
       102 
116 
     | 
    
         
             
            						redirect_to "#{app_url}?shop=#{params[:shop]}", :status => 301 and return
         
     | 
| 
         @@ -36,10 +36,10 @@ module AppManager 
     | 
|
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
            				    end
         
     | 
| 
       38 
38 
     | 
    
         
             
            				else
         
     | 
| 
       39 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 39 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>>  Either model is defined wrong or config.plan_id_or_name_field is nil in initializer ==="	
         
     | 
| 
       40 
40 
     | 
    
         
             
            				end	
         
     | 
| 
       41 
41 
     | 
    
         
             
            			else
         
     | 
| 
       42 
     | 
    
         
            -
                			 Rails.logger.info "APP  
     | 
| 
      
 42 
     | 
    
         
            +
                			 Rails.logger.info "APP MANAGER >>>>  Either params missing store_domain or config.plan_features is nil in initializer ==="	
         
     | 
| 
       43 
43 
     | 
    
         
             
            			end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         | 
| 
         @@ -119,8 +119,23 @@ module AppManager 
     | 
|
| 
       119 
119 
     | 
    
         
             
            			if params[:shop_domain].present? && params[:plan_id].present? && model
         
     | 
| 
       120 
120 
     | 
    
         
             
            				@shop = shop_data
         
     | 
| 
       121 
121 
     | 
    
         
             
            				@trial_activated_field = AppManager.configuration.field_names['trial_activated_at'] 
         
     | 
| 
       122 
     | 
    
         
            -
            				@shop.update(@plan_field => params[:plan_id],@trial_activated_field => DateTime.now)
         
     | 
| 
      
 122 
     | 
    
         
            +
            				if @shop.update(@plan_field => params[:plan_id],@trial_activated_field => DateTime.now)
         
     | 
| 
      
 123 
     | 
    
         
            +
            				begin
         
     | 
| 
      
 124 
     | 
    
         
            +
            							 plan_obj = AppManager::Client.new
         
     | 
| 
      
 125 
     | 
    
         
            +
            	    		 			 plan_data = plan_obj.get_plan(params[:plan_id],params[:shop_domain]) rescue nil
         
     | 
| 
      
 126 
     | 
    
         
            +
                        					AppManager::EventHandler.new('charge_created',{
         
     | 
| 
      
 127 
     | 
    
         
            +
            								"plan" => plan_data,
         
     | 
| 
      
 128 
     | 
    
         
            +
            								"charge" => nil,
         
     | 
| 
      
 129 
     | 
    
         
            +
            								"previous_charge" => nil,
         
     | 
| 
      
 130 
     | 
    
         
            +
            								"choose_later" => true 	
         
     | 
| 
      
 131 
     | 
    
         
            +
            								})
         
     | 
| 
      
 132 
     | 
    
         
            +
                        				rescue Exception => e
         
     | 
| 
      
 133 
     | 
    
         
            +
                        					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
      
 134 
     | 
    
         
            +
                        				end
         
     | 
| 
       123 
135 
     | 
    
         
             
            				render json: {'status' => true}
         
     | 
| 
      
 136 
     | 
    
         
            +
            				else
         
     | 
| 
      
 137 
     | 
    
         
            +
            					render json: {'status' => false,'error' => "#{@shop.errors.full_messages.to_sentence}"}, status: 422
         
     | 
| 
      
 138 
     | 
    
         
            +
            				end
         
     | 
| 
       124 
139 
     | 
    
         
             
            			else
         
     | 
| 
       125 
140 
     | 
    
         
             
            				render json: {'status' => false,'error' => 'Shop not found or missing shop'}, status: 422
         
     | 
| 
       126 
141 
     | 
    
         
             
            			end
         
     | 
| 
         @@ -140,13 +155,13 @@ module AppManager 
     | 
|
| 
       140 
155 
     | 
    
         
             
            		    	begin
         
     | 
| 
       141 
156 
     | 
    
         
             
            		    		@fs.sync_app_manager	
         
     | 
| 
       142 
157 
     | 
    
         
             
            		    	rescue Exception => e
         
     | 
| 
       143 
     | 
    
         
            -
            		    		Rails.logger.info "APP  
     | 
| 
      
 158 
     | 
    
         
            +
            		    		Rails.logger.info "APP MANAGER >>>> LOCAL DB couldn't sync with POTAL DB #{e.inspect}"
         
     | 
| 
       144 
159 
     | 
    
         
             
            		    	end
         
     | 
| 
       145 
160 
     | 
    
         | 
| 
       146 
161 
     | 
    
         
             
            		    	begin
         
     | 
| 
       147 
162 
     | 
    
         
             
            		    	@fs.save_api_data(params)
         
     | 
| 
       148 
163 
     | 
    
         
             
            		    	rescue Exception => e
         
     | 
| 
       149 
     | 
    
         
            -
            		    	Rails.logger.info "APP  
     | 
| 
      
 164 
     | 
    
         
            +
            		    	Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       150 
165 
     | 
    
         
             
            		    	end
         
     | 
| 
       151 
166 
     | 
    
         
             
            		    	AppManager.clear_cache
         
     | 
| 
       152 
167 
     | 
    
         
             
            		    end
         
     | 
| 
         @@ -18,6 +18,10 @@ module AppManager 
     | 
|
| 
       18 
18 
     | 
    
         
             
            			  	  post("/cancel-charge", {shop_domain: shop_domain,plan_id: plan_id})
         
     | 
| 
       19 
19 
     | 
    
         
             
            			  end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
                		  def update_charge(shop_domain,plan_id)
         
     | 
| 
      
 22 
     | 
    
         
            +
                		  	  post("/update-charge", {shop_domain: shop_domain,plan_id: plan_id})
         
     | 
| 
      
 23 
     | 
    
         
            +
                		  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       21 
25 
     | 
    
         
             
            			  def sync_charge(options = {})
         
     | 
| 
       22 
26 
     | 
    
         
             
            			  	  post("/sync-charge", options)
         
     | 
| 
       23 
27 
     | 
    
         
             
            			  end
         
     | 
| 
         @@ -28,37 +28,37 @@ module AppManager 
     | 
|
| 
       28 
28 
     | 
    
         
             
            				begin
         
     | 
| 
       29 
29 
     | 
    
         
             
            					save_api_plans(params["plans"])
         
     | 
| 
       30 
30 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       31 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 31 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       32 
32 
     | 
    
         
             
            				end
         
     | 
| 
       33 
33 
     | 
    
         
             
            				begin
         
     | 
| 
       34 
34 
     | 
    
         
             
            					save_api_charges(params["charges"])
         
     | 
| 
       35 
35 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       36 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 36 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       37 
37 
     | 
    
         
             
            				end
         
     | 
| 
       38 
38 
     | 
    
         
             
            				begin
         
     | 
| 
       39 
39 
     | 
    
         
             
            					save_api_apps(params["apps"])
         
     | 
| 
       40 
40 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       41 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 41 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       42 
42 
     | 
    
         
             
            				end
         
     | 
| 
       43 
43 
     | 
    
         
             
            				begin
         
     | 
| 
       44 
44 
     | 
    
         
             
            					save_api_app_structures(params["app_structures"])
         
     | 
| 
       45 
45 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       46 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 46 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       47 
47 
     | 
    
         
             
            				end
         
     | 
| 
       48 
48 
     | 
    
         
             
            				begin
         
     | 
| 
       49 
49 
     | 
    
         
             
            					save_api_discount_plans(params["discount_plans"])
         
     | 
| 
       50 
50 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       51 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 51 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       52 
52 
     | 
    
         
             
            				end
         
     | 
| 
       53 
53 
     | 
    
         
             
            				begin
         
     | 
| 
       54 
54 
     | 
    
         
             
            					save_api_extend_trials(params["extend_trials"])
         
     | 
| 
       55 
55 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       56 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 56 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       57 
57 
     | 
    
         
             
            				end
         
     | 
| 
       58 
58 
     | 
    
         
             
            				begin
         
     | 
| 
       59 
59 
     | 
    
         
             
            					save_api_plan_users(params["plan_users"])
         
     | 
| 
       60 
60 
     | 
    
         
             
            				rescue Exception => e
         
     | 
| 
       61 
     | 
    
         
            -
            					Rails.logger.info "APP  
     | 
| 
      
 61 
     | 
    
         
            +
            					Rails.logger.info "APP MANAGER >>>> #{e.inspect}"	
         
     | 
| 
       62 
62 
     | 
    
         
             
            				end
         
     | 
| 
       63 
63 
     | 
    
         
             
            		end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
         @@ -194,11 +194,22 @@ module AppManager 
     | 
|
| 
       194 
194 
     | 
    
         | 
| 
       195 
195 
     | 
    
         | 
| 
       196 
196 
     | 
    
         
             
            		def get_local_plans(params)
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
       197 
198 
     | 
    
         
             
            		    plans_data = []
         
     | 
| 
       198 
199 
     | 
    
         | 
| 
       199 
200 
     | 
    
         
             
                        active_plan_id = nil
         
     | 
| 
      
 201 
     | 
    
         
            +
                        active_charge_price = nil
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
       200 
203 
     | 
    
         
             
                        charges = @apm_db.execute( "SELECT * FROM charges WHERE shop_domain = ? ",params['shop_domain'])
         
     | 
| 
       201 
     | 
    
         
            -
                         
     | 
| 
      
 204 
     | 
    
         
            +
                        
         
     | 
| 
      
 205 
     | 
    
         
            +
            			if charges.any?
         
     | 
| 
      
 206 
     | 
    
         
            +
            				active_plan_id = charges.first['plan_id'] 
         
     | 
| 
      
 207 
     | 
    
         
            +
            				active_charge_price = charges.first['price'] 
         
     | 
| 
      
 208 
     | 
    
         
            +
            			elsif params['active_plan_id'].present? && !params['active_plan_id'].nil?
         
     | 
| 
      
 209 
     | 
    
         
            +
            				active_plan_id = params['active_plan_id']
         
     | 
| 
      
 210 
     | 
    
         
            +
            				plan_data = @apm_db.execute( "SELECT * FROM plans WHERE id = ?", active_plan_id)
         
     | 
| 
      
 211 
     | 
    
         
            +
            				active_charge_price = plan_data.first['price'] if plan_data.any?
         
     | 
| 
      
 212 
     | 
    
         
            +
            			end
         
     | 
| 
       202 
213 
     | 
    
         | 
| 
       203 
214 
     | 
    
         
             
                        custom_plan_ids = []
         
     | 
| 
       204 
215 
     | 
    
         
             
                        plan_users = @apm_db.execute( "SELECT * FROM plan_users WHERE shop_domain = ? ",params['shop_domain'])
         
     | 
| 
         @@ -232,7 +243,7 @@ module AppManager 
     | 
|
| 
       232 
243 
     | 
    
         
             
            							new_plan[key] = val.collect{|e|e['value']}
         
     | 
| 
       233 
244 
     | 
    
         
             
            						elsif ['affiliate'].include?(key)
         
     | 
| 
       234 
245 
     | 
    
         
             
            							new_plan[key] = eval(value)
         
     | 
| 
       235 
     | 
    
         
            -
            						elsif ['is_custom','public','store_base_plan'].include?(key)
         
     | 
| 
      
 246 
     | 
    
         
            +
            						elsif ['is_custom','public','store_base_plan','choose_later_plan'].include?(key)
         
     | 
| 
       236 
247 
     | 
    
         
             
            							new_plan[key] = (value == 0 ? false : true)
         
     | 
| 
       237 
248 
     | 
    
         
             
            						elsif ['test'].include?(key)
         
     | 
| 
       238 
249 
     | 
    
         
             
            							new_plan[key] = (value == 0 ? nil : true)
         
     | 
| 
         @@ -255,12 +266,41 @@ module AppManager 
     | 
|
| 
       255 
266 
     | 
    
         
             
            					features_by_plan.each do |fp|
         
     | 
| 
       256 
267 
     | 
    
         
             
            					fp['name'] = features.find{|e| e['uuid'] == fp['feature_id']}['name'] rescue nil
         
     | 
| 
       257 
268 
     | 
    
         
             
            					fp['format'] = features.find{|e| e['uuid'] == fp['feature_id']}['format'] rescue nil
         
     | 
| 
      
 269 
     | 
    
         
            +
            					fp['slug'] = features.find{|e| e['uuid'] == fp['feature_id']}['slug'] rescue nil
         
     | 
| 
       258 
270 
     | 
    
         
             
            					features_by_plans_data.push(fp)
         
     | 
| 
       259 
271 
     | 
    
         
             
            					end
         
     | 
| 
       260 
272 
     | 
    
         
             
            				end
         
     | 
| 
       261 
273 
     | 
    
         
             
            			end
         
     | 
| 
       262 
274 
     | 
    
         | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
            			custom_discounts_data = []
         
     | 
| 
      
 277 
     | 
    
         
            +
            			if params["shop_domain"].present? && plan_data
         
     | 
| 
      
 278 
     | 
    
         
            +
            						custom_discounts = @apm_db.execute( "SELECT * FROM discount_plans WHERE shop_domain = ? ORDER BY created_at DESC", params["shop_domain"]) 
         
     | 
| 
      
 279 
     | 
    
         
            +
            						if custom_discounts.any?
         
     | 
| 
      
 280 
     | 
    
         
            +
            							custom_discounts.each do |custom_discount|
         
     | 
| 
      
 281 
     | 
    
         
            +
            								new_custom_discount = {}
         
     | 
| 
      
 282 
     | 
    
         
            +
            								custom_discount.each_with_index do |(key, value), index|
         
     | 
| 
      
 283 
     | 
    
         
            +
            									new_custom_discount[key] = value unless key.class == Integer
         
     | 
| 
      
 284 
     | 
    
         
            +
            								end
         
     | 
| 
      
 285 
     | 
    
         
            +
            								custom_discounts_data.push(new_custom_discount)
         
     | 
| 
      
 286 
     | 
    
         
            +
            							end
         
     | 
| 
      
 287 
     | 
    
         
            +
            						end
         
     | 
| 
      
 288 
     | 
    
         
            +
            			end
         
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
       263 
290 
     | 
    
         
             
            				plans_data.each do |plan|
         
     | 
| 
      
 291 
     | 
    
         
            +
            					if (!active_plan_id.nil? && plan['id'] == active_plan_id) 
         
     | 
| 
      
 292 
     | 
    
         
            +
            					plan['price'] = active_charge_price
         
     | 
| 
      
 293 
     | 
    
         
            +
            					end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
            					if custom_discounts_data.any? && custom_discounts_data.select{|e| e['plan_id'] == plan['id']}.size > 0 
         
     | 
| 
      
 296 
     | 
    
         
            +
            						cd_hash = {}
         
     | 
| 
      
 297 
     | 
    
         
            +
            						custom_discounts_data.select{|e| e['plan_id'] == plan['id']}.each do |cd|
         
     | 
| 
      
 298 
     | 
    
         
            +
            					 		plan['discount'] = cd['discount']  
         
     | 
| 
      
 299 
     | 
    
         
            +
            							plan['discount_type'] = cd['discount_type']  
         
     | 
| 
      
 300 
     | 
    
         
            +
            							plan['cycle_count'] = cd['cycle_count']  
         
     | 
| 
      
 301 
     | 
    
         
            +
            					 	end
         
     | 
| 
      
 302 
     | 
    
         
            +
            					end
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
       264 
304 
     | 
    
         
             
            					if features_by_plans_data.select{|e| e['plan_id'] == plan['id']}.size > 0 
         
     | 
| 
       265 
305 
     | 
    
         
             
            					 feature_hash = {}
         
     | 
| 
       266 
306 
     | 
    
         
             
            					 features_by_plans_data.select{|e| e['plan_id'] == plan['id']}.each do |fp|
         
     | 
| 
         @@ -271,11 +311,14 @@ module AppManager 
     | 
|
| 
       271 
311 
     | 
    
         
             
            					 features = nil
         
     | 
| 
       272 
312 
     | 
    
         
             
            					end
         
     | 
| 
       273 
313 
     | 
    
         
             
            					plan['features'] = features
         
     | 
| 
      
 314 
     | 
    
         
            +
            					plan['old_plan_id'] = nil
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
       274 
316 
     | 
    
         
             
            				end
         
     | 
| 
       275 
317 
     | 
    
         | 
| 
       276 
318 
     | 
    
         
             
            				plans = plans_data
         
     | 
| 
       277 
319 
     | 
    
         
             
            			end
         
     | 
| 
       278 
320 
     | 
    
         | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
       279 
322 
     | 
    
         
             
            			return plans
         
     | 
| 
       280 
323 
     | 
    
         
             
            		end
         
     | 
| 
       281 
324 
     | 
    
         | 
| 
         @@ -291,7 +334,7 @@ module AppManager 
     | 
|
| 
       291 
334 
     | 
    
         
             
            						 new_plan[key] = val
         
     | 
| 
       292 
335 
     | 
    
         
             
            						elsif ['shopify_plans','affiliate','features'].include?(key)
         
     | 
| 
       293 
336 
     | 
    
         
             
            						 new_plan[key] = eval(value)
         
     | 
| 
       294 
     | 
    
         
            -
            						elsif ['is_custom','public','store_base_plan'].include?(key)
         
     | 
| 
      
 337 
     | 
    
         
            +
            						elsif ['is_custom','public','store_base_plan','choose_later_plan'].include?(key)
         
     | 
| 
       295 
338 
     | 
    
         
             
            						 new_plan[key] = (value == 0 ? false : true)
         
     | 
| 
       296 
339 
     | 
    
         
             
            						elsif ['test'].include?(key)
         
     | 
| 
       297 
340 
     | 
    
         
             
            						 new_plan[key] = (value == 0 ? nil : true)
         
     | 
| 
         @@ -308,7 +351,7 @@ module AppManager 
     | 
|
| 
       308 
351 
     | 
    
         
             
            						end
         
     | 
| 
       309 
352 
     | 
    
         
             
            						plan_data['app'] = app_data
         
     | 
| 
       310 
353 
     | 
    
         
             
            					end
         
     | 
| 
       311 
     | 
    
         
            -
             
     | 
| 
      
 354 
     | 
    
         
            +
            					plan_data['old_plan_id'] = nil # Temporary for migration puspose only
         
     | 
| 
       312 
355 
     | 
    
         
             
            					if params["shop_domain"].present? && plan_data
         
     | 
| 
       313 
356 
     | 
    
         
             
            						@apm_db.execute( "SELECT * FROM discount_plans WHERE plan_id = ? AND shop_domain = ? ", params["plan_id"],params["shop_domain"]) do |cd|
         
     | 
| 
       314 
357 
     | 
    
         
             
            							plan_data['discount'] = cd['discount'] if cd rescue plan_data['discount']
         
     | 
| 
         @@ -322,6 +365,7 @@ module AppManager 
     | 
|
| 
       322 
365 
     | 
    
         
             
            			end
         
     | 
| 
       323 
366 
     | 
    
         | 
| 
       324 
367 
     | 
    
         
             
            			end
         
     | 
| 
      
 368 
     | 
    
         
            +
             
     | 
| 
       325 
369 
     | 
    
         
             
            			return plan_data
         
     | 
| 
       326 
370 
     | 
    
         
             
            		end
         
     | 
| 
       327 
371 
     | 
    
         | 
| 
         @@ -122,6 +122,32 @@ module AppManager 
     | 
|
| 
       122 
122 
     | 
    
         
             
                    return data
         
     | 
| 
       123 
123 
     | 
    
         
             
               end
         
     | 
| 
       124 
124 
     | 
    
         | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
               def recurring_charge_cancel_api_call(charge_id,shop)
         
     | 
| 
      
 127 
     | 
    
         
            +
                  query = 'mutation(
         
     | 
| 
      
 128 
     | 
    
         
            +
                    $id: ID!
         
     | 
| 
      
 129 
     | 
    
         
            +
                    ){
         
     | 
| 
      
 130 
     | 
    
         
            +
                      appSubscriptionCancel(
         
     | 
| 
      
 131 
     | 
    
         
            +
                      id: $id
         
     | 
| 
      
 132 
     | 
    
         
            +
                      ) {
         
     | 
| 
      
 133 
     | 
    
         
            +
                      userErrors {
         
     | 
| 
      
 134 
     | 
    
         
            +
                        field
         
     | 
| 
      
 135 
     | 
    
         
            +
                        message
         
     | 
| 
      
 136 
     | 
    
         
            +
                      }
         
     | 
| 
      
 137 
     | 
    
         
            +
                      appSubscription {
         
     | 
| 
      
 138 
     | 
    
         
            +
                        id
         
     | 
| 
      
 139 
     | 
    
         
            +
                        status
         
     | 
| 
      
 140 
     | 
    
         
            +
                      }
         
     | 
| 
      
 141 
     | 
    
         
            +
                    }
         
     | 
| 
      
 142 
     | 
    
         
            +
                  }
         
     | 
| 
      
 143 
     | 
    
         
            +
                  '
         
     | 
| 
      
 144 
     | 
    
         
            +
                      variables = {
         
     | 
| 
      
 145 
     | 
    
         
            +
                          "id":  "gid://shopify/AppSubscription/#{charge_id}" 
         
     | 
| 
      
 146 
     | 
    
         
            +
                      }
         
     | 
| 
      
 147 
     | 
    
         
            +
                      data = run_graph_api(query,variables)
         
     | 
| 
      
 148 
     | 
    
         
            +
                      return data
         
     | 
| 
      
 149 
     | 
    
         
            +
               end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
       125 
151 
     | 
    
         
             
              end
         
     | 
| 
       126 
152 
     | 
    
         
             
            end
         
     | 
| 
       127 
153 
     | 
    
         | 
    
        data/lib/app_manager/model.rb
    CHANGED
    
    | 
         @@ -31,7 +31,8 @@ module AppManager 
     | 
|
| 
       31 
31 
     | 
    
         
             
                def plan_features
         
     | 
| 
       32 
32 
     | 
    
         
             
                	plan_id = self[AppManager.configuration.plan_id_or_name_field]
         
     | 
| 
       33 
33 
     | 
    
         
             
                	if !plan_id
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
                        Rails.logger.info "Plan id found nil or not set in DB"
         
     | 
| 
      
 35 
     | 
    
         
            +
                		return []
         
     | 
| 
       35 
36 
     | 
    
         
             
                	end
         
     | 
| 
       36 
37 
     | 
    
         
             
            		plan_obj = AppManager::Client.new
         
     | 
| 
       37 
38 
     | 
    
         
             
            		plans = plan_obj.get_plan(plan_id)
         
     | 
| 
         @@ -64,34 +65,86 @@ module AppManager 
     | 
|
| 
       64 
65 
     | 
    
         
             
                end
         
     | 
| 
       65 
66 
     | 
    
         | 
| 
       66 
67 
     | 
    
         
             
                def get_remaining_days
         
     | 
| 
       67 
     | 
    
         
            -
                     
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 69 
     | 
    
         
            +
                        shop_domain = self[AppManager.configuration.shopify_domain_field]
         
     | 
| 
      
 70 
     | 
    
         
            +
                        trial_activated_at_field = AppManager.configuration.field_names['trial_activated_at']
         
     | 
| 
      
 71 
     | 
    
         
            +
                        trial_activated_at_val = self[trial_activated_at_field]
         
     | 
| 
      
 72 
     | 
    
         
            +
                        plan_field = AppManager.configuration.field_names['plan_id']
         
     | 
| 
      
 73 
     | 
    
         
            +
                        plan_id = self[plan_field]
         
     | 
| 
      
 74 
     | 
    
         
            +
                        plan_obj = AppManager::Client.new
         
     | 
| 
      
 75 
     | 
    
         
            +
                        shop_domain ? plan_obj.get_remaining_days(shop_domain,trial_activated_at_val,plan_id) : 0
         
     | 
| 
      
 76 
     | 
    
         
            +
                    rescue Exception => e
         
     | 
| 
      
 77 
     | 
    
         
            +
                        return "#{e.inspect}" 
         
     | 
| 
      
 78 
     | 
    
         
            +
                    end
         
     | 
| 
       74 
79 
     | 
    
         
             
                end
         
     | 
| 
       75 
80 
     | 
    
         | 
| 
       76 
81 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
                def get_plan
         
     | 
| 
       78 
     | 
    
         
            -
                     
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
      
 82 
     | 
    
         
            +
                def get_plan(plan_id=nil)
         
     | 
| 
      
 83 
     | 
    
         
            +
                    req_plan_id = nil
         
     | 
| 
      
 84 
     | 
    
         
            +
                    if !plan_id.nil? 
         
     | 
| 
      
 85 
     | 
    
         
            +
                        req_plan_id = plan_id
         
     | 
| 
      
 86 
     | 
    
         
            +
                    else
         
     | 
| 
      
 87 
     | 
    
         
            +
                        shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
         
     | 
| 
      
 88 
     | 
    
         
            +
                        if shop_plan_id && !shop_plan_id.nil?
         
     | 
| 
      
 89 
     | 
    
         
            +
                          req_plan_id = shop_plan_id
         
     | 
| 
      
 90 
     | 
    
         
            +
                        else
         
     | 
| 
      
 91 
     | 
    
         
            +
                          Rails.logger.info "Invalid params, must have charge_id,shop && plan"
         
     | 
| 
      
 92 
     | 
    
         
            +
                          return {}
         
     | 
| 
      
 93 
     | 
    
         
            +
                        end
         
     | 
| 
       80 
94 
     | 
    
         
             
                    end
         
     | 
| 
       81 
     | 
    
         
            -
                    plan_obj = AppManager::Client.new
         
     | 
| 
       82 
     | 
    
         
            -
                    return plan_obj.get_plan( 
     | 
| 
      
 95 
     | 
    
         
            +
                    plan_obj = AppManager::Client.new if req_plan_id
         
     | 
| 
      
 96 
     | 
    
         
            +
                    return req_plan_id ? plan_obj.get_plan(req_plan_id) : {}
         
     | 
| 
       83 
97 
     | 
    
         
             
                end
         
     | 
| 
       84 
98 
     | 
    
         | 
| 
       85 
99 
     | 
    
         
             
                def get_charge
         
     | 
| 
      
 100 
     | 
    
         
            +
                    shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
         
     | 
| 
      
 101 
     | 
    
         
            +
                    found_free_plan = false
         
     | 
| 
      
 102 
     | 
    
         
            +
                    if shop_plan_id && !shop_plan_id.nil?
         
     | 
| 
      
 103 
     | 
    
         
            +
                        plan_obj = AppManager::Client.new 
         
     | 
| 
      
 104 
     | 
    
         
            +
                        plan = plan_obj.get_plan(shop_plan_id) rescue nil
         
     | 
| 
      
 105 
     | 
    
         
            +
                        if plan && plan['price'] == 0 && plan['public'] == true
         
     | 
| 
      
 106 
     | 
    
         
            +
                            found_free_plan = true
         
     | 
| 
      
 107 
     | 
    
         
            +
                            return nil
         
     | 
| 
      
 108 
     | 
    
         
            +
                        end
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end
         
     | 
| 
      
 110 
     | 
    
         
            +
                    if !found_free_plan
         
     | 
| 
      
 111 
     | 
    
         
            +
                        begin
         
     | 
| 
      
 112 
     | 
    
         
            +
                            shop_domain = self[AppManager.configuration.shopify_domain_field]
         
     | 
| 
      
 113 
     | 
    
         
            +
                            plan_obj = AppManager::Client.new
         
     | 
| 
      
 114 
     | 
    
         
            +
                          return  plan_obj.get_charge(shop_domain) 
         
     | 
| 
      
 115 
     | 
    
         
            +
                        rescue Exception => e
         
     | 
| 
      
 116 
     | 
    
         
            +
                          Rails.logger.info "#{e.inspect}" 
         
     | 
| 
      
 117 
     | 
    
         
            +
                          return nil
         
     | 
| 
      
 118 
     | 
    
         
            +
                        end
         
     | 
| 
      
 119 
     | 
    
         
            +
                    end
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                def get_all_plans
         
     | 
| 
       86 
123 
     | 
    
         
             
                    begin
         
     | 
| 
       87 
124 
     | 
    
         
             
                        shop_domain = self[AppManager.configuration.shopify_domain_field]
         
     | 
| 
      
 125 
     | 
    
         
            +
                        shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
         
     | 
| 
      
 126 
     | 
    
         
            +
                        active_plan_id = shop_plan_id && shop_plan_id.nil? ? nil : shop_plan_id
         
     | 
| 
       88 
127 
     | 
    
         
             
                        plan_obj = AppManager::Client.new
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 128 
     | 
    
         
            +
                        return plan_obj.get_plans(shop_domain,active_plan_id)
         
     | 
| 
       90 
129 
     | 
    
         
             
                    rescue Exception => e
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 130 
     | 
    
         
            +
                        Rails.logger.info "#{e.inspect}" 
         
     | 
| 
      
 131 
     | 
    
         
            +
                        return []
         
     | 
| 
       92 
132 
     | 
    
         
             
                    end
         
     | 
| 
       93 
133 
     | 
    
         
             
                end
         
     | 
| 
       94 
134 
     | 
    
         | 
| 
      
 135 
     | 
    
         
            +
                def cancel_charge
         
     | 
| 
      
 136 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 137 
     | 
    
         
            +
                        shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
         
     | 
| 
      
 138 
     | 
    
         
            +
                        shop_domain = self[AppManager.configuration.shopify_domain_field]
         
     | 
| 
      
 139 
     | 
    
         
            +
                        if shop_plan_id && shop_domain
         
     | 
| 
      
 140 
     | 
    
         
            +
                            plan_obj = AppManager::Client.new
         
     | 
| 
      
 141 
     | 
    
         
            +
                            plan_obj.cancel_charge(shop_domain,shop_plan_id)
         
     | 
| 
      
 142 
     | 
    
         
            +
                        end
         
     | 
| 
      
 143 
     | 
    
         
            +
                    rescue Exception => e
         
     | 
| 
      
 144 
     | 
    
         
            +
                        return "#{e.inspect}" 
         
     | 
| 
      
 145 
     | 
    
         
            +
                    end     
         
     | 
| 
      
 146 
     | 
    
         
            +
                end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
       95 
148 
     | 
    
         
             
                def set_default_plan(plan_id=nil)
         
     | 
| 
       96 
149 
     | 
    
         
             
                    begin
         
     | 
| 
       97 
150 
     | 
    
         
             
                        if plan_id.nil?
         
     | 
| 
         @@ -117,15 +170,17 @@ module AppManager 
     | 
|
| 
       117 
170 
     | 
    
         | 
| 
       118 
171 
     | 
    
         | 
| 
       119 
172 
     | 
    
         | 
| 
       120 
     | 
    
         
            -
                def get_plans_by_features(feature_slugs)
         
     | 
| 
      
 173 
     | 
    
         
            +
                def get_plans_by_features(feature_slugs,params="false")
         
     | 
| 
       121 
174 
     | 
    
         
             
                    if feature_slugs.any?
         
     | 
| 
      
 175 
     | 
    
         
            +
                        shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
         
     | 
| 
       122 
176 
     | 
    
         
             
                        plan_data = []
         
     | 
| 
       123 
177 
     | 
    
         
             
                        shop_domain = self[AppManager.configuration.shopify_domain_field]
         
     | 
| 
       124 
178 
     | 
    
         
             
                        plan_obj = AppManager::Client.new
         
     | 
| 
       125 
179 
     | 
    
         
             
                        plans = plan_obj.get_plans(shop_domain)
         
     | 
| 
       126 
180 
     | 
    
         
             
                        plans = plans.select{|x| x['interval'] == 'EVERY_30_DAYS'  && x['public'] == true}
         
     | 
| 
       127 
181 
     | 
    
         
             
                        plans.each do |plan|
         
     | 
| 
       128 
     | 
    
         
            -
                            if  
     | 
| 
      
 182 
     | 
    
         
            +
                            next if (params && !params.nil? && params == "exclude_current_plan" && !shop_plan_id.nil? && plan["id"] == shop_plan_id)
         
     | 
| 
      
 183 
     | 
    
         
            +
                            if plan && (plan['features'] && plan['features'].any?) && (plan['features'].values && plan['features'].values.any?) && (plan['features'].values.collect{|c| c['slug']} && plan['features'].values.collect{|c| c['slug']}.any?)
         
     | 
| 
       129 
184 
     | 
    
         
             
                             plan_feature_slugs = plan['features'].values.collect{|c| c['slug']}.sort
         
     | 
| 
       130 
185 
     | 
    
         
             
                             if (feature_slugs & plan_feature_slugs).any? && ((feature_slugs & plan_feature_slugs).sort == feature_slugs.sort)
         
     | 
| 
       131 
186 
     | 
    
         
             
                                    plan_data.push(plan)      
         
     | 
| 
         @@ -138,6 +193,8 @@ module AppManager 
     | 
|
| 
       138 
193 
     | 
    
         
             
                    end
         
     | 
| 
       139 
194 
     | 
    
         
             
                end
         
     | 
| 
       140 
195 
     | 
    
         | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
       141 
198 
     | 
    
         
             
                private
         
     | 
| 
       142 
199 
     | 
    
         | 
| 
       143 
200 
     | 
    
         
             
                def casted_value(value,value_type)
         
     | 
    
        data/lib/app_manager/version.rb
    CHANGED
    
    
| 
         @@ -84,5 +84,6 @@ end 
     | 
|
| 
       84 
84 
     | 
    
         
             
            ActiveSupport::Notifications.subscribe "charge_created"  do |name, start, finish, id, payload|
         
     | 
| 
       85 
85 
     | 
    
         
             
               Rails.logger.debug "========APP MANAGER========="
         
     | 
| 
       86 
86 
     | 
    
         
             
               Rails.logger.debug "DATA : #{payload}"
         
     | 
| 
      
 87 
     | 
    
         
            +
               #payload hash contains 3 keys, "plan", "charge", "previous_charge" and an extra key "choose_later" => "true" renders when clicked on choose later  
         
     | 
| 
       87 
88 
     | 
    
         
             
               Rails.logger.debug "========APP MANAGER========="
         
     | 
| 
       88 
89 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: app_manager
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Hulkapps
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-07-05 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: httparty
         
     |