shopify-gold 5.0.0 → 5.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59f64edfc44f572a2fdbf18a0c7d4e87f282ec34c496f670d25639f4ea680874
4
- data.tar.gz: 4da2cdbd7b0438f483abc4aa04fa904a7f0be3f6afa93a5024505235ab1c34bc
3
+ metadata.gz: 27bbc1ba14621fd2a39291faa1df4d52e004cb512858d82f04e29fdefd4f43fc
4
+ data.tar.gz: 237848311344321a2b5a218ddbfaed88e133efb7ec9ca3b094718c4db1ac382b
5
5
  SHA512:
6
- metadata.gz: 31917b72d24e6fc5c27e3bdaccb0246194344e57272f6da64e7d6cd361d1f57255920d9a8e33990cebb5c050ffb57f64a5806496e9b7ff27196fe8d946c41054
7
- data.tar.gz: 1280caec87e5918c86a0f84d4162141ad4909812d2ce90cf28f7b03a066d702119e9b42287a5b96db95891166b44d049fe0d714d76663b8dc1a02ea31c489c06
6
+ metadata.gz: f3293e0897c04ad38929c80a2dbb528f5ebfd3f24563e3dcfdcaa68b0a37562ff97406112f4821711ef74d3d539f336a7ccd22de171d6496839be838fc5bde7c
7
+ data.tar.gz: 06c96b494db7fd61e25a3d4189d004b7cedfe4a93d1636795bcf0923f3036f9fb6cc67be48944991d881195564287ab066fc8866b83c8639aefe3ce50b1b2c9c
@@ -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
 
@@ -230,7 +230,8 @@ module Gold
230
230
  apply_free_tier
231
231
  change_tier
232
232
  staff
233
- optional_charge]
233
+ optional_charge
234
+ marked_as_uninstalled]
234
235
 
235
236
  before_transition to: :optional_charge, &require_metadata(:charge_id)
236
237
  guard_transition to: :optional_charge, &ensure_plan_is(:paying?)
@@ -238,7 +239,8 @@ module Gold
238
239
  optional_charge_accepted
239
240
  optional_charge_declined
240
241
  marked_as_uninstalled]
241
- transition from: :optional_charge_declined, to: :billing
242
+ transition from: :optional_charge_declined, to: %i[billing
243
+ marked_as_uninstalled]
242
244
 
243
245
  transition from: :optional_charge_accepted, to: %i[charge_activated
244
246
  marked_as_uninstalled]
@@ -256,13 +258,17 @@ module Gold
256
258
  marked_as_uninstalled]
257
259
 
258
260
  transition from: :delayed_charge_expired, to: %i[delayed_charge
259
- marked_as_delinquent]
261
+ marked_as_delinquent
262
+ marked_as_uninstalled]
260
263
  transition from: :delayed_charge_declined, to: %i[marked_as_delinquent
261
- delayed_charge]
264
+ delayed_charge
265
+ marked_as_uninstalled]
262
266
 
263
267
  guard_transition to: :marked_as_delinquent,
264
268
  &ensure_min_days_in_state(Gold.configuration.days_until_delinquent)
265
- transition from: :marked_as_delinquent, to: :delinquent
269
+ transition from: :marked_as_delinquent, to: %i[delinquent
270
+ marked_as_uninstalled]
271
+
266
272
  transition from: :delinquent, to: %i[marked_as_uninstalled delayed_charge cleanup]
267
273
 
268
274
  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.
@@ -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.1.1".freeze
3
3
  end
@@ -90,8 +90,17 @@ namespace :gold do
90
90
  end
91
91
 
92
92
  billing.shop.with_shopify_session do
93
- Gold::MarkAsDelinquentOp.new(billing).call
94
- puts "Shop '#{billing.shop.shopify_domain}' is delinquent"
93
+ domain = billing.shop.shopify_domain
94
+
95
+ begin
96
+ Gold::MarkAsDelinquentOp.new(billing).call
97
+ puts "Shop '#{domain}' is delinquent"
98
+ rescue ActiveResource::UnauthorizedAccess
99
+ puts "It looks like '#{domain}' uninstalled, running op..."
100
+ Gold::UninstallOp.new(billing).call
101
+ rescue ActiveResource::ClientError => e
102
+ puts "Error for '#{domain}', #{e}"
103
+ end
95
104
  end
96
105
  end
97
106
  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.1.1
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: 2020-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails