app_manager 2.2.0 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -3
- data/README.md +7 -4
- data/app/controllers/app_manager/charges_controller.rb +5 -5
- data/lib/app_manager/model.rb +32 -10
- data/lib/app_manager/version.rb +1 -1
- 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: fb1084d39db6c9e21c292a640e1a9d646787250891f7296d238b6d833a844883
|
4
|
+
data.tar.gz: 529a1d620ba1540bba2ab8696ba75112abd92dae02e7ff74514f4bc4316e67f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b1be10cc3bc40500409ac5a32a7b5d261fb8a5023d87d39ade414377fd19410177ac39f2dbdfdabfdff7e016f853883aecd54bd6ce6fdc631bc6bb1af58001f
|
7
|
+
data.tar.gz: fab06e313b8694aa7478956184647a3f695c31ed20e47e240f8260a9e0a0f9b9ab053c6718a5b334e2409a56b238ab6924c9091b6e2b6aa7eaa3407e849e3715
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_manager (2.2.
|
4
|
+
app_manager (2.2.3)
|
5
5
|
activerecord-import (~> 1.4)
|
6
6
|
httparty
|
7
7
|
kaminari (>= 0.16.3)
|
@@ -97,6 +97,7 @@ GEM
|
|
97
97
|
crack (0.4.5)
|
98
98
|
rexml
|
99
99
|
crass (1.0.6)
|
100
|
+
csv (3.3.0)
|
100
101
|
date (3.3.4)
|
101
102
|
diff-lcs (1.5.0)
|
102
103
|
dotenv (2.1.2)
|
@@ -105,7 +106,8 @@ GEM
|
|
105
106
|
globalid (1.2.1)
|
106
107
|
activesupport (>= 6.1)
|
107
108
|
hashdiff (1.0.1)
|
108
|
-
httparty (0.
|
109
|
+
httparty (0.22.0)
|
110
|
+
csv
|
109
111
|
mini_mime (>= 1.0.0)
|
110
112
|
multi_xml (>= 0.5.2)
|
111
113
|
i18n (1.14.4)
|
@@ -201,7 +203,7 @@ GEM
|
|
201
203
|
rake (13.0.6)
|
202
204
|
rdoc (6.6.3.1)
|
203
205
|
psych (>= 4.0.0)
|
204
|
-
reline (0.5.
|
206
|
+
reline (0.5.4)
|
205
207
|
io-console (~> 0.5)
|
206
208
|
rexml (3.2.5)
|
207
209
|
rspec (3.11.0)
|
data/README.md
CHANGED
@@ -198,7 +198,9 @@ and then you can use follwing methods with your shop objects.
|
|
198
198
|
|
199
199
|
@shop.get_active_charge_app_manager # return active charge hash from app manager otherwise nil
|
200
200
|
|
201
|
-
@shop.update_app_manager_charge # return true if shop has shopify recurring charge but app manager doesn't then it update to app manager and return true otherwise nil
|
201
|
+
@shop.update_app_manager_charge # return true if shop has shopify recurring charge but app manager doesn't then it update to app manager and return true otherwise nil. This method also accepts current shopify charge id, so you can pass it if you already. This will reduce the extra call like this @shop.update_app_manager_charge("xx23432434")
|
202
|
+
|
203
|
+
@shop.update_app_manager_charge_with_plan_id # same as update_app_manager_charge method, the only difference is that, it will not check the plan_id in the shop table is valid from app manager. This method also accepts two parameters, first is current shopify charge id and second is plan_id .It shop table doesn't have plan_id saved then you can pass in second parameter. @shop.update_app_manager_charge_with_plan_id("xx23432434",23)
|
202
204
|
|
203
205
|
@shop.get_current_shopify_charge # return active charge hash from shopify https://shopify.dev/docs/api/admin-graphql/2022-10/queries/currentAppInstallation otherwise nil
|
204
206
|
|
@@ -217,19 +219,20 @@ and then you can use follwing methods with your shop objects.
|
|
217
219
|
* Update app manager gem in your project's Gemfile
|
218
220
|
|
219
221
|
```ruby
|
220
|
-
gem 'app_manager', '2.
|
222
|
+
gem 'app_manager', '2.2.3'
|
221
223
|
```
|
222
224
|
* In Rails project, in application.rb, add following line after require "rails/all" line
|
223
225
|
|
224
226
|
```ruby
|
225
|
-
require 'app_manager/
|
227
|
+
require 'app_manager/set_local_storage'
|
226
228
|
```
|
227
229
|
|
228
230
|
* In route.rb file, add following route with constraints
|
229
231
|
```ruby
|
230
232
|
condition = ->(request) { request.path_info.include?('/discount/') }
|
233
|
+
plan_url = "https://admin.shopify.com/admin/apps/#{ENV['SHOPIFY_APP_SLUG']}/home/plan"
|
231
234
|
constraints(condition) do
|
232
|
-
get '/discount/*any', to: AppManager::
|
235
|
+
get '/discount/*any', to: AppManager::SetLocalStorage.new(Rails.application, condition, plan_url)
|
233
236
|
end
|
234
237
|
```
|
235
238
|
* If updating gem from 1.6.1, then run these commands on rails root.
|
@@ -31,7 +31,7 @@ module AppManager
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
rescue Exception => e
|
34
|
-
Rollbar.error("APP MANAGER Process Plan Failed #{e}")
|
34
|
+
Rollbar.error("APP MANAGER Process Plan Failed #{e.inspect}-#{e.backtrace}")
|
35
35
|
end
|
36
36
|
@trial_activated_field = AppManager.configuration.field_names['trial_activated_at']
|
37
37
|
update_info = {@plan_field => params[:plan_id], @trial_activated_field => nil,grandfathered_field => 0}
|
@@ -49,7 +49,7 @@ module AppManager
|
|
49
49
|
"shopify_domain" => params[:shop]
|
50
50
|
})
|
51
51
|
rescue Exception => e
|
52
|
-
Rollbar.error("APP MANAGER Error in Process Plan #{e}")
|
52
|
+
Rollbar.error("APP MANAGER Error in Process Plan #{e.inspect}-#{e.backtrace}")
|
53
53
|
end
|
54
54
|
AppManager.clear_cache
|
55
55
|
# render json: {'redirect_url' => "#{app_url}?shop=#{params[:shop]}"} and return true
|
@@ -135,7 +135,7 @@ module AppManager
|
|
135
135
|
"shopify_domain" => params[:shop]
|
136
136
|
})
|
137
137
|
rescue Exception => e
|
138
|
-
Rollbar.error("Error in APP MANAGER Charge Created Callback >>>> #{e.inspect}")
|
138
|
+
Rollbar.error("Error in APP MANAGER Charge Created Callback >>>> #{e.inspect}-#{e.backtrace}")
|
139
139
|
end
|
140
140
|
|
141
141
|
begin
|
@@ -146,8 +146,8 @@ module AppManager
|
|
146
146
|
plan_obj.discount_used(@shop[shopify_domain], params[:discount])
|
147
147
|
end
|
148
148
|
end
|
149
|
-
rescue
|
150
|
-
Rollbar.error("Error in APP MANAGER Discount used API call >>>> #{e.inspect}")
|
149
|
+
rescue Exception => e
|
150
|
+
Rollbar.error("Error in APP MANAGER Discount used API call >>>> #{e.inspect}-#{e.backtrace}")
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
data/lib/app_manager/model.rb
CHANGED
@@ -148,7 +148,7 @@ module AppManager
|
|
148
148
|
plan_obj.cancel_charge(shop_domain, shop_plan_id)
|
149
149
|
end
|
150
150
|
rescue Exception => e
|
151
|
-
return "#{e.inspect}"
|
151
|
+
return "#{e.inspect}-#{e.backtrace}"
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -170,7 +170,7 @@ module AppManager
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
rescue Exception => e
|
173
|
-
return "#{e.inspect}"
|
173
|
+
return "#{e.inspect}-#{e.backtrace}"
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -182,7 +182,7 @@ module AppManager
|
|
182
182
|
return data["data"]["currentAppInstallation"]["activeSubscriptions"].first
|
183
183
|
end
|
184
184
|
rescue Exception => e
|
185
|
-
Rollbar.error("Warning in APP MANAGER, trying to get_current_shopify_charge >>>> #{e.inspect}")
|
185
|
+
Rollbar.error("Warning in APP MANAGER, trying to get_current_shopify_charge >>>> #{e.inspect}-#{e.backtrace}")
|
186
186
|
return nil
|
187
187
|
end
|
188
188
|
end
|
@@ -217,7 +217,28 @@ module AppManager
|
|
217
217
|
end
|
218
218
|
return charge_updated
|
219
219
|
rescue Exception => e
|
220
|
-
Rollbar.error("Warning in APP MANAGER, trying to get update_app_manager_charge >>>> #{e.inspect}")
|
220
|
+
Rollbar.error("Warning in APP MANAGER, trying to get update_app_manager_charge >>>> #{e.inspect}-#{e.backtrace}")
|
221
|
+
return nil
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def update_app_manager_charge_with_plan_id(current_shopify_charge_id=nil,shop_custom_plan_id=nil)
|
226
|
+
charge_updated = nil
|
227
|
+
begin
|
228
|
+
shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
|
229
|
+
shop_domain = self[AppManager.configuration.shopify_domain_field]
|
230
|
+
current_charge_id = current_shopify_charge_id.present? ? current_shopify_charge_id : active_shopify_charge_id
|
231
|
+
plan_id = shop_custom_plan_id.present? ? shop_custom_plan_id : shop_plan_id
|
232
|
+
if current_charge_id.present?
|
233
|
+
if plan_id.present?
|
234
|
+
if charge_update_call(self,plan_id,current_charge_id)
|
235
|
+
charge_updated = true
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
return charge_updated
|
240
|
+
rescue Exception => e
|
241
|
+
Rollbar.error("Warning in APP MANAGER, trying to get update_app_manager_charge_with_plan_id >>>> #{e.inspect}-#{e.backtrace}")
|
221
242
|
return nil
|
222
243
|
end
|
223
244
|
end
|
@@ -236,7 +257,7 @@ module AppManager
|
|
236
257
|
return nil
|
237
258
|
end
|
238
259
|
rescue Exception => e
|
239
|
-
Rollbar.error("Warning in APP MANAGER, trying to get active shopify charge id >>>> #{e.inspect}")
|
260
|
+
Rollbar.error("Warning in APP MANAGER, trying to get active shopify charge id >>>> #{e.inspect}-#{e.backtrace}")
|
240
261
|
return nil
|
241
262
|
end
|
242
263
|
end
|
@@ -300,15 +321,16 @@ module AppManager
|
|
300
321
|
"shopify_domain" => shop_domain
|
301
322
|
})
|
302
323
|
rescue Exception => e
|
303
|
-
Rollbar.error("Warning in APP MANAGER model Charge Created Callback Event Fire>>>> #{e.inspect}")
|
324
|
+
Rollbar.error("Warning in APP MANAGER model Charge Created Callback Event Fire>>>> #{e.inspect}-#{e.backtrace}")
|
304
325
|
end
|
326
|
+
Thread.exit # Terminate the thread once processing is done
|
305
327
|
end
|
306
328
|
end
|
307
329
|
end
|
308
330
|
end
|
309
331
|
return charge_callback_done
|
310
332
|
# rescue Exception => e
|
311
|
-
# Rollbar.error("Warning in APP MANAGER model charge_callback, trying to update active shopify charge in app manager>>>> #{e.inspect}")
|
333
|
+
# Rollbar.error("Warning in APP MANAGER model charge_callback, trying to update active shopify charge in app manager>>>> #{e.inspect}-#{e.backtrace}")
|
312
334
|
# return nil
|
313
335
|
# end
|
314
336
|
end
|
@@ -351,7 +373,7 @@ module AppManager
|
|
351
373
|
self.save
|
352
374
|
end
|
353
375
|
rescue Exception => e
|
354
|
-
return "#{e.inspect}"
|
376
|
+
return "#{e.inspect}-#{e.backtrace}"
|
355
377
|
end
|
356
378
|
end
|
357
379
|
|
@@ -365,10 +387,10 @@ module AppManager
|
|
365
387
|
plans = plan_obj.get_plans(shop_domain)
|
366
388
|
plans = plans.select { |x| x['interval'] == 'EVERY_30_DAYS' && x['public'] == true }
|
367
389
|
plans.each do |plan|
|
368
|
-
next if (params && !params.nil? && params == "exclude_current_plan" && !shop_plan_id.nil? && plan["id"] == shop_plan_id)
|
390
|
+
next if (params && !params.nil? && params == "exclude_current_plan" && !shop_plan_id.nil? && !plan["id"].nil? && plan["id"] == shop_plan_id)
|
369
391
|
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?)
|
370
392
|
plan_feature_slugs = plan['features'].values.collect { |c| c['slug'] }.sort
|
371
|
-
if (feature_slugs & plan_feature_slugs).any? && ((feature_slugs & plan_feature_slugs).sort == feature_slugs.sort)
|
393
|
+
if plan_feature_slugs && (feature_slugs & plan_feature_slugs).any? && ((feature_slugs & plan_feature_slugs).sort == feature_slugs.sort)
|
372
394
|
plan_data.push(plan)
|
373
395
|
end
|
374
396
|
end
|
data/lib/app_manager/version.rb
CHANGED
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: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahul Tiwari @ Hulkapps
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|