shopify-gold 4.2.1 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/gold/authenticated_controller.rb +1 -1
- data/app/controllers/gold/billing_controller.rb +7 -7
- data/app/controllers/gold/concerns/merchant_facing.rb +2 -2
- data/app/models/gold/concerns/gilded.rb +1 -1
- data/app/models/gold/machine.rb +17 -7
- data/app/models/gold/shopify_plan.rb +4 -2
- data/app/models/gold/tier.rb +2 -2
- data/app/operations/gold/install_op.rb +3 -1
- data/lib/gold/billing_migrator.rb +2 -0
- data/lib/gold/configuration.rb +6 -1
- data/lib/gold/version.rb +1 -1
- data/lib/tasks/gold_tasks.rake +13 -2
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0c1d7836dbfa17bc2904e5b3e28db56c975615067cec4ab0f333db6342b7a56
|
4
|
+
data.tar.gz: 602576cfdf68190454a2ad5e62bd7aa50d87f7e2607b10f01f0204f29f54f089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e91088357efbc98973a9aa90d8095cedb0d5cf51dfaae13cb478dcb4b8a00ec990fcd70994a390d4b2d3598173c26f48e8b104193940d47cf75b4447d07b35a8
|
7
|
+
data.tar.gz: 4f69024f139ccc4d8760e94162c21d53796edc2918786ee65ea4f08fb3aa793e7d57936c317a4f989eab4cd3b10c406c7e8c583f1e600ebc530e3ae9767c89fd
|
@@ -7,7 +7,7 @@ module Gold
|
|
7
7
|
layout "gold/billing"
|
8
8
|
|
9
9
|
rescue_from Statesman::TransitionFailedError do |e|
|
10
|
-
billing = Billing.find_by!(shop_id: session[:
|
10
|
+
billing = Billing.find_by!(shop_id: session[:shop_id])
|
11
11
|
Gold.logger.error("Shop '#{billing.shop.shopify_domain}' failed to " \
|
12
12
|
"transtion '#{e}'")
|
13
13
|
render "gold/billing/transition_error", layout: "gold/billing",
|
@@ -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
|
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
|
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
|
-
|
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
|
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}#{
|
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
|
175
|
+
redirect_to redirect_path
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -9,7 +9,7 @@ module Gold
|
|
9
9
|
|
10
10
|
# Returns the Gold::Billing instance for the currently logged-in merchant.
|
11
11
|
def billing
|
12
|
-
@billing ||= Billing.find_by!(shop_id: session[:
|
12
|
+
@billing ||= Billing.find_by!(shop_id: session[:shop_id])
|
13
13
|
rescue ActiveRecord::RecordNotFound
|
14
14
|
raise Gold::Exceptions::BillingNotFound
|
15
15
|
end
|
@@ -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
|
data/app/models/gold/machine.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require "statesman"
|
2
2
|
|
3
3
|
module Gold
|
4
4
|
# This is the finite state machine specification that governs how shops may
|
@@ -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[
|
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:
|
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:
|
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
|
-
|
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
|
-
|
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.
|
data/app/models/gold/tier.rb
CHANGED
@@ -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
|
-
#
|
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
|
data/lib/gold/configuration.rb
CHANGED
@@ -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
|
data/lib/gold/version.rb
CHANGED
data/lib/tasks/gold_tasks.rake
CHANGED
@@ -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
|
-
|
94
|
-
|
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:
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Smith
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '6'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '6'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: sass-rails
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,28 +43,28 @@ dependencies:
|
|
43
43
|
name: shopify_app
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '15'
|
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: '
|
55
|
+
version: '15'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: statesman
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '3'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3'
|
70
70
|
- !ruby/object:Gem::Dependency
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '2.
|
76
|
+
version: '2.7'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '2.
|
83
|
+
version: '2.7'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: faker
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,16 +155,16 @@ dependencies:
|
|
155
155
|
name: shopify_app
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
|
-
- - "
|
158
|
+
- - "~>"
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version: '
|
160
|
+
version: '15'
|
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: '
|
167
|
+
version: '15'
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: sqlite3
|
170
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,16 +183,16 @@ dependencies:
|
|
183
183
|
name: webmock
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- - "
|
186
|
+
- - "~>"
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version: 3
|
188
|
+
version: '3'
|
189
189
|
type: :development
|
190
190
|
prerelease: false
|
191
191
|
version_requirements: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
|
-
- - "
|
193
|
+
- - "~>"
|
194
194
|
- !ruby/object:Gem::Version
|
195
|
-
version: 3
|
195
|
+
version: '3'
|
196
196
|
description: |
|
197
197
|
Gold is Helium's approach to billing for Shopify apps. It provides a
|
198
198
|
framework to build Rails apps upon.
|