shopify-gold 3.1.0 → 3.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 +4 -4
- data/app/operations/gold/apply_tier_op.rb +25 -22
- data/app/operations/gold/select_tier_op.rb +10 -10
- data/lib/gold/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: e78293868f6e71725d206a8702fa7a21b464a4e064b92e66b071438b167bea14
|
|
4
|
+
data.tar.gz: 11b2059ff87e7cb99ad4773f72b1558da33f90e2208272c11ab53fe0219fc894
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6c36f6b7843d26a206f3136b3fc15cd0e858fa4eccd8c60ca6b8c360da3796dcee0491098a91824704d7e1eff426267e341cf071ae25b92189ccf3d9bf985b3
|
|
7
|
+
data.tar.gz: 3e792f82164acc2c22926eab91a8b59d924edb1b69944fc70ad07dbaeaad03cb80015408cab17b98e6482220a1d2e3d884533d9feb0b523827ef85994034eab8
|
|
@@ -15,35 +15,38 @@ module Gold
|
|
|
15
15
|
return TierNotFound.new(e.message)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@billing.
|
|
18
|
+
@billing.transaction do
|
|
19
|
+
unless %i[apply_tier apply_free_tier].include?(@billing.current_state)
|
|
20
|
+
if tier.free?
|
|
21
|
+
@billing.transition_to!(:apply_free_tier, tier_id: tier.id)
|
|
22
|
+
elsif @billing.shopify_plan.paying?
|
|
23
|
+
@billing.transition_to!(:apply_tier, tier_id: tier.id)
|
|
24
|
+
end
|
|
23
25
|
end
|
|
24
|
-
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
@billing.tier = tier
|
|
28
|
+
@billing.save!
|
|
29
|
+
|
|
30
|
+
if tier.free?
|
|
31
|
+
if Gold.configuration.allow_automated_charge_cancellation
|
|
32
|
+
# Remove any outstanding active charges
|
|
33
|
+
if (charge = ShopifyAPI::RecurringApplicationCharge.current)
|
|
34
|
+
request_with_retries do
|
|
35
|
+
Gold.logger.info("[#{@billing.id}] Free tier applied, canceling " \
|
|
36
|
+
"charge '#{charge.price}' for " \
|
|
37
|
+
"'#{@billing.shop.shopify_domain}'")
|
|
38
|
+
charge.cancel
|
|
39
|
+
end
|
|
38
40
|
end
|
|
41
|
+
else
|
|
42
|
+
Gold.logger.info("[#{@billing.id}] Would have cancelled charge for " \
|
|
43
|
+
"'#{@billing.shop.shopify_domain}', but prevented by setting")
|
|
39
44
|
end
|
|
40
|
-
else
|
|
41
|
-
Gold.logger.info("[#{@billing.id}] Would have cancelled charge for " \
|
|
42
|
-
"'#{@billing.shop.shopify_domain}', but prevented by setting")
|
|
43
45
|
end
|
|
46
|
+
|
|
47
|
+
@billing.transition_to!(billing_state)
|
|
44
48
|
end
|
|
45
49
|
|
|
46
|
-
@billing.transition_to!(billing_state)
|
|
47
50
|
Gold.configuration.on_apply_tier&.call(@billing, tier.id)
|
|
48
51
|
TierApplied.new
|
|
49
52
|
end
|
|
@@ -34,18 +34,18 @@ module Gold
|
|
|
34
34
|
|
|
35
35
|
# Mark the beginning of the trial if it hasn't been set already
|
|
36
36
|
@billing.update(trial_starts_at: Time.current) unless @billing.trial_starts_at
|
|
37
|
+
end
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
# Process the tier selection, creating charges if necessary
|
|
40
|
+
if @billing.shopify_plan.affiliate? ||
|
|
41
|
+
@billing.shopify_plan.staff? ||
|
|
42
|
+
@tier.free?
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
end
|
|
44
|
+
# If the shop doesn't need a charge, apply the tier
|
|
45
|
+
return ApplyTierOp.new(@billing).call
|
|
46
|
+
else
|
|
47
|
+
# A valid charge is necessary before applying the new tier
|
|
48
|
+
return ChargeNeeded.new
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
data/lib/gold/version.rb
CHANGED
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.
|
|
4
|
+
version: 3.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: 2019-09-
|
|
12
|
+
date: 2019-09-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|