shopify-gold 5.0.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59f64edfc44f572a2fdbf18a0c7d4e87f282ec34c496f670d25639f4ea680874
4
- data.tar.gz: 4da2cdbd7b0438f483abc4aa04fa904a7f0be3f6afa93a5024505235ab1c34bc
3
+ metadata.gz: 626161bde9c84b77043dda68cd9c989f9a5b8d0e20238bc9cfef5762ea5812e1
4
+ data.tar.gz: 9e2180c3e8a4471c4ae9a3e29d52e6374b16a647dc2602f3e2e88add1df1e39b
5
5
  SHA512:
6
- metadata.gz: 31917b72d24e6fc5c27e3bdaccb0246194344e57272f6da64e7d6cd361d1f57255920d9a8e33990cebb5c050ffb57f64a5806496e9b7ff27196fe8d946c41054
7
- data.tar.gz: 1280caec87e5918c86a0f84d4162141ad4909812d2ce90cf28f7b03a066d702119e9b42287a5b96db95891166b44d049fe0d714d76663b8dc1a02ea31c489c06
6
+ metadata.gz: 69377f5547134f2e571ba9a4dadf7cdef990489bfae31f998548ec8cc701078f907719fc7c66dcc07297c79910bb44a4c3c875d8e22b1a8db66585322dbe69dc
7
+ data.tar.gz: aca74451cd78c8543067fadcf69cc9c7473a16ca2920f1880b94129f421f31c98f1bf08a270cc1fd12379cbc47ebdbe56e7b72aefdc35516e77695f0f8e185fb
@@ -57,7 +57,7 @@ module Gold
57
57
  case outcome
58
58
  when SameTier, TierApplied
59
59
  cookies.delete(:gold_tier_id)
60
- redirect_to main_app.root_url
60
+ redirect_to Gold.configuration.after_tier_redirect_path
61
61
  when CannotSelectTier
62
62
  flash.now[:error] = "Your shop is not eligible for this plan"
63
63
  render :tier
@@ -98,7 +98,7 @@ module Gold
98
98
  Gold.logger.info("[#{billing.id}] Charge is ready")
99
99
  end
100
100
 
101
- redirect_to main_app.root_url
101
+ redirect_to Gold.configuration.after_tier_redirect_path
102
102
  else
103
103
  raise "Not sure how to handle #{outcome} on outstanding charge"
104
104
  end
@@ -112,7 +112,7 @@ module Gold
112
112
  case outcome
113
113
  when ActiveCharge
114
114
  ApplyTierOp.new(billing).call
115
- outer_redirect_to_main
115
+ outer_redirect(Gold.configuration.after_tier_redirect_path)
116
116
  when DeclinedCharge
117
117
  redirect_to declined_charge_url
118
118
  when ExpiredCharge
@@ -165,14 +165,14 @@ module Gold
165
165
 
166
166
  # If embedded app, redirect directly through the Shopify admin. This can provide
167
167
  # a better experience than the page rendering and JS kicking off a redirect
168
- def outer_redirect_to_main
168
+ def outer_redirect(redirect_path)
169
169
  if ShopifyApp.configuration.embedded_app
170
170
  shopify_domain = billing.shop.shopify_domain
171
171
  api_key = ShopifyApp.configuration.api_key
172
- fullpath = "/admin/apps/#{api_key}#{main_app.root_path}"
172
+ fullpath = "/admin/apps/#{api_key}#{redirect_path}"
173
173
  redirect_to URI::HTTPS.build(host: shopify_domain, path: fullpath).to_s
174
174
  else
175
- redirect_to main_app.root_url
175
+ redirect_to redirect_path
176
176
  end
177
177
  end
178
178
 
@@ -49,7 +49,7 @@ module Gold
49
49
  Gold.logger.info("Confronting billing, state is '#{state}'")
50
50
 
51
51
  case state
52
- when nil, :new
52
+ when nil, :new, :install
53
53
  Gold.logger.info("Redirecting to terms page...")
54
54
  return @context.redirect_to(@engine.terms_url)
55
55
  when :select_tier, :reinstalled, :accepted_terms
@@ -12,6 +12,9 @@ module Gold
12
12
 
13
13
  state :new, initial: true
14
14
 
15
+ # A merchant has installed the app
16
+ state :install
17
+
15
18
  # Before merchants can use our app, they will need to review and accept our
16
19
  # Terms of Service.
17
20
  state :accepted_terms
@@ -165,7 +168,8 @@ module Gold
165
168
 
166
169
  # Transitions
167
170
 
168
- transition from: :new, to: %i[accepted_terms marked_as_uninstalled]
171
+ transition from: :new, to: %i[install marked_as_uninstalled]
172
+ transition from: :install, to: %i[accepted_terms marked_as_uninstalled]
169
173
  transition from: :accepted_terms, to: %i[select_tier marked_as_uninstalled]
170
174
 
171
175
  before_transition to: :select_tier, &require_metadata(:tier_id)
@@ -230,7 +234,8 @@ module Gold
230
234
  apply_free_tier
231
235
  change_tier
232
236
  staff
233
- optional_charge]
237
+ optional_charge
238
+ marked_as_uninstalled]
234
239
 
235
240
  before_transition to: :optional_charge, &require_metadata(:charge_id)
236
241
  guard_transition to: :optional_charge, &ensure_plan_is(:paying?)
@@ -238,7 +243,8 @@ module Gold
238
243
  optional_charge_accepted
239
244
  optional_charge_declined
240
245
  marked_as_uninstalled]
241
- transition from: :optional_charge_declined, to: :billing
246
+ transition from: :optional_charge_declined, to: %i[billing
247
+ marked_as_uninstalled]
242
248
 
243
249
  transition from: :optional_charge_accepted, to: %i[charge_activated
244
250
  marked_as_uninstalled]
@@ -256,13 +262,17 @@ module Gold
256
262
  marked_as_uninstalled]
257
263
 
258
264
  transition from: :delayed_charge_expired, to: %i[delayed_charge
259
- marked_as_delinquent]
265
+ marked_as_delinquent
266
+ marked_as_uninstalled]
260
267
  transition from: :delayed_charge_declined, to: %i[marked_as_delinquent
261
- delayed_charge]
268
+ delayed_charge
269
+ marked_as_uninstalled]
262
270
 
263
271
  guard_transition to: :marked_as_delinquent,
264
272
  &ensure_min_days_in_state(Gold.configuration.days_until_delinquent)
265
- transition from: :marked_as_delinquent, to: :delinquent
273
+ transition from: :marked_as_delinquent, to: %i[delinquent
274
+ marked_as_uninstalled]
275
+
266
276
  transition from: :delinquent, to: %i[marked_as_uninstalled delayed_charge cleanup]
267
277
 
268
278
  guard_transition to: :affiliate, &ensure_plan_is(:affiliate?)
@@ -20,14 +20,16 @@ module Gold
20
20
 
21
21
  # Returns true if this is a development (non-live) shop.
22
22
  def affiliate?
23
- plan == "affiliate"
23
+ plans = %w[affiliate partner_test]
24
+ plans.include?(plan)
24
25
  end
25
26
 
26
27
  # Returns true if this is a shop owned by Shopify staff. This specifically
27
28
  # excludes Shopify Business shops, as we believe those are paid stores that
28
29
  # Shopify employees use for their own businesses.
29
30
  def staff?
30
- plan == "staff"
31
+ plans = %w[plus_partner_sandbox staff]
32
+ plans.include?(plan)
31
33
  end
32
34
 
33
35
  # Returns true if this shop has been frozen by Shopify for non-payment.
@@ -79,11 +79,11 @@ module Gold
79
79
  end
80
80
 
81
81
  def qualifications
82
- parent ? parent.qualifications : @qualifications
82
+ parent ? parent.qualifications.merge(@qualifications) : @qualifications
83
83
  end
84
84
 
85
85
  def features
86
- parent ? parent.features : @features
86
+ parent ? parent.features.merge(@features) : @features
87
87
  end
88
88
 
89
89
  def parent
@@ -10,11 +10,13 @@ module Gold
10
10
  end
11
11
 
12
12
  def call
13
- # If possible, transition to reinstalled
13
+ # Transition to reinstalled, if possible
14
14
  @billing.transition_to(:reinstalled)
15
15
 
16
16
  case @billing.current_state
17
17
  when :new, :reinstalled
18
+ # Transition to install, if possible
19
+ @billing.transition_to(:install)
18
20
  Gold.configuration.on_install&.call(@billing)
19
21
  when :frozen
20
22
  return CheckChargeOp.new(@billing).call
@@ -45,6 +45,8 @@ module Gold
45
45
  trial_starts_at: @trial_starts_at
46
46
  )
47
47
 
48
+ @billing.transition_to! :install
49
+
48
50
  lookup_tier!
49
51
  accept_terms
50
52
  select_tier
@@ -13,7 +13,8 @@ module Gold
13
13
  :days_until_cleanup,
14
14
  :shop_domain_attribute,
15
15
  :force_embedded_redirect,
16
- :app_listing_url
16
+ :app_listing_url,
17
+ :after_tier_redirect_path
17
18
 
18
19
  # Callbacks
19
20
  attr_accessor :on_terms,
@@ -72,6 +73,10 @@ module Gold
72
73
  # The URL to follow after a referral code is tracked
73
74
  # (e.g. https://apps.shopify.com/customr)
74
75
  @app_listing_url = "https://apps.shopify.com/"
76
+
77
+ # The redirect path after a tier is applied. Use this path to welcome a
78
+ # merchant if they just installed
79
+ @after_tier_redirect_path = "/"
75
80
  end
76
81
 
77
82
  def shop_class
@@ -1,3 +1,3 @@
1
1
  module Gold
2
- VERSION = "5.0.0".freeze
2
+ VERSION = "5.4.0".freeze
3
3
  end
@@ -66,6 +66,8 @@ namespace :gold do
66
66
  Gold::UninstallOp.new(billing).call
67
67
  rescue ActiveResource::ClientError => e
68
68
  puts "Error for '#{billing.shop.shopify_domain}', #{e}"
69
+ rescue Statesman::GuardFailedError => e
70
+ puts "Cannot transition: #{e.message}"
69
71
  end
70
72
  end
71
73
  end
@@ -90,8 +92,17 @@ namespace :gold do
90
92
  end
91
93
 
92
94
  billing.shop.with_shopify_session do
93
- Gold::MarkAsDelinquentOp.new(billing).call
94
- puts "Shop '#{billing.shop.shopify_domain}' is delinquent"
95
+ domain = billing.shop.shopify_domain
96
+
97
+ begin
98
+ Gold::MarkAsDelinquentOp.new(billing).call
99
+ puts "Shop '#{domain}' is delinquent"
100
+ rescue ActiveResource::UnauthorizedAccess
101
+ puts "It looks like '#{domain}' uninstalled, running op..."
102
+ Gold::UninstallOp.new(billing).call
103
+ rescue ActiveResource::ClientError => e
104
+ puts "Error for '#{domain}', #{e}"
105
+ end
95
106
  end
96
107
  end
97
108
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-gold
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-09 00:00:00.000000000 Z
12
+ date: 2021-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '13'
48
+ version: '16'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '13'
55
+ version: '16'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: statesman
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -157,14 +157,14 @@ dependencies:
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: '13'
160
+ version: '16'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '13'
167
+ version: '16'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: sqlite3
170
170
  requirement: !ruby/object:Gem::Requirement
@@ -317,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  - !ruby/object:Gem::Version
318
318
  version: '0'
319
319
  requirements: []
320
- rubygems_version: 3.1.2
320
+ rubygems_version: 3.0.3
321
321
  signing_key:
322
322
  specification_version: 4
323
323
  summary: Helium's approach to billing for Shopify apps