shopify-gold 3.1.5 → 3.1.6

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: 5adc0c1d861847ba415b25018a12a0ea9707e5786015e88f92948a95c19ab03c
4
- data.tar.gz: d6dcd501764c4d1838de734179e13d1d67cf4c1c9e0e23fc77d7765a70d3347c
3
+ metadata.gz: b25280b1c511ebf2f9e0764bffdf3583af068260d3a9e08a46d4327c5dca52f1
4
+ data.tar.gz: 97dd3fc9a7854145683a0b3e85a2ff935e1be8b5d495d193c8ad8d163701359d
5
5
  SHA512:
6
- metadata.gz: 4b641e7b4e8b9ce1b391f7b82051b227e6d61dd4af40920a0540f8fe59edc065d427bf4cdd5c92939c958b7f52ca1cdac6942fa6c6ca62c37e93b91c579d0ea2
7
- data.tar.gz: 9712751b0835d99bd4b47c260213463256e03b224b338446e16ccb2fcc354bfb06deba75f32808b4b0cc94031e17a58fb60eccabbad237f97347d09fb27604c6
6
+ metadata.gz: ab1f2a8fff58ee961ccb0f573ab69ca53dd5638bd8065d3e8fe4e125b76c445221356152c58426bd5b557a5df3100bf581809eca8c8deabd2b162a2bed794467
7
+ data.tar.gz: ab03be2a520dc46553f27727e33aa46bf8e8b6fe6be7b5ac3992e4ade0841da107e978671c8570bf14c2c4a9eadbc92878faa78245e98719e92a215c9587e2df
@@ -103,8 +103,7 @@ module Gold
103
103
 
104
104
  # Unsuspend a shop
105
105
  def unsuspend
106
- UnsuspendOp.new(billing).call
107
- outcome = CheckChargeOp.new(billing).call
106
+ outcome = UnsuspendOp.new(billing).call
108
107
 
109
108
  Gold::ChargeOp.new(billing, process_charge_url).call unless outcome.ok?
110
109
 
@@ -122,13 +122,19 @@ module Gold
122
122
  # Ensure that a shop has a certain type of plan before allowing a transition.
123
123
  def self.ensure_plan_is(query_method)
124
124
  test = proc { |billing| billing.shopify_plan.send(query_method) }
125
- test.define_singleton_method(:to_s) { "Billing is #{query_method}" }
125
+ test.define_singleton_method(:to_s) { "Billing is #{query_method}?" }
126
126
  test
127
127
  end
128
128
 
129
129
  def self.ensure_tier_is_not_free
130
130
  test = proc { |billing| !billing.tier&.free? }
131
- test.define_singleton_method(:to_s) { "Tier is not free" }
131
+ test.define_singleton_method(:to_s) { "Tier is not free?" }
132
+ test
133
+ end
134
+
135
+ def self.ensure_tier_is_free
136
+ test = proc { |billing| billing.tier&.free? }
137
+ test.define_singleton_method(:to_s) { "Tier is free?" }
132
138
  test
133
139
  end
134
140
 
@@ -196,7 +202,7 @@ module Gold
196
202
  issue_credit
197
203
  marked_as_suspended
198
204
  marked_as_uninstalled]
199
-
205
+ guard_transition to: :check_charge, &ensure_tier_is_not_free
200
206
  transition from: :check_charge, to: %i[check_charge
201
207
  billing
202
208
  charge_missing
@@ -276,7 +282,9 @@ module Gold
276
282
  transition from: :marked_as_suspended, to: :suspended
277
283
  transition from: :suspended, to: %i[affiliate
278
284
  check_charge
285
+ billing
279
286
  cleanup]
287
+ guard_transition from: :suspended, to: :billing, &ensure_tier_is_free
280
288
 
281
289
  transition from: :marked_as_uninstalled, to: %i[uninstalled]
282
290
  transition from: :uninstalled, to: %i[cleanup reinstalled]
@@ -8,13 +8,15 @@ module Gold
8
8
  end
9
9
 
10
10
  def call
11
- if @billing.can_transition_to?(:affiliate)
12
- @billing.transition_to!(:affiliate)
11
+ # Transition to appropriate location
12
+ if @billing.transition_to(:affiliate)
13
+ Success.new
14
+ elsif @billing.transition_to(:check_charge)
15
+ CheckChargeOp.new(@billing).call
13
16
  else
14
- @billing.transition_to!(:check_charge)
17
+ @billing.transition_to!(:billing)
18
+ Success.new
15
19
  end
16
-
17
- Success.new
18
20
  end
19
21
  end
20
22
  end
data/lib/gold/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gold
2
- VERSION = "3.1.5".freeze
2
+ VERSION = "3.1.6".freeze
3
3
  end
@@ -54,7 +54,9 @@ namespace :gold do
54
54
  billing.shop.with_shopify_session do
55
55
  outcome = Gold::CheckChargeOp.new(billing).call
56
56
 
57
- unless outcome.ok?
57
+ if outcome.ok?
58
+ print "✅"
59
+ else
58
60
  puts "Check charge for shop '#{billing.shop.shopify_domain}': #{outcome}"
59
61
  Gold::ChargeOp.new(billing,
60
62
  Gold::Engine.routes.url_helpers.process_charge_url).call
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: 3.1.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith