shopify-gold 4.2.0 → 5.2.1
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 +1 -1
- data/app/models/gold/concerns/gilded.rb +1 -1
- data/app/models/gold/machine.rb +12 -6
- data/app/models/gold/shopify_plan.rb +4 -2
- data/app/models/gold/tier.rb +2 -2
- data/lib/gold/configuration.rb +6 -1
- data/lib/gold/version.rb +1 -1
- data/lib/tasks/gold_tasks.rake +14 -2
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d15786e3bd37ff9291bf4f000c3f580373a56dcf5bd8662df743ec4a30ec5c36
|
4
|
+
data.tar.gz: 9f838172385fffd62d0397c92db4acb8a8bda60c7aac144bfdaf90883d6ba452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eb7a98aab47e7948e56b3522586ca3023bbf19e9fd3df2c7cac5036bf8986b8abfc963ec9173056999aef245a0879d0cdc7f0f5dc0b62c5145131f97571c556
|
7
|
+
data.tar.gz: 3c642760a522e4e1c8cac183f6eb2b7f5e36d8bb2d885bb34de7faf83cd0c237ee6d93d6771328efe742a5619cb44178912529a4b9287fd72d383be442f896b7
|
@@ -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
|
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
|
@@ -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:
|
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:
|
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
|
-
|
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
|
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,9 @@ 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,
|
70
|
+
Statesman::TransitionFailedError => e
|
71
|
+
puts "Cannot transition: #{e.message}"
|
69
72
|
end
|
70
73
|
end
|
71
74
|
end
|
@@ -90,8 +93,17 @@ namespace :gold do
|
|
90
93
|
end
|
91
94
|
|
92
95
|
billing.shop.with_shopify_session do
|
93
|
-
|
94
|
-
|
96
|
+
domain = billing.shop.shopify_domain
|
97
|
+
|
98
|
+
begin
|
99
|
+
Gold::MarkAsDelinquentOp.new(billing).call
|
100
|
+
puts "Shop '#{domain}' is delinquent"
|
101
|
+
rescue ActiveResource::UnauthorizedAccess
|
102
|
+
puts "It looks like '#{domain}' uninstalled, running op..."
|
103
|
+
Gold::UninstallOp.new(billing).call
|
104
|
+
rescue ActiveResource::ClientError => e
|
105
|
+
puts "Error for '#{domain}', #{e}"
|
106
|
+
end
|
95
107
|
end
|
96
108
|
end
|
97
109
|
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.2.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-
|
12
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,42 +17,42 @@ dependencies:
|
|
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
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
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: '13'
|
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: '13'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: statesman
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -113,16 +113,16 @@ dependencies:
|
|
113
113
|
name: rubocop
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - "
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.74
|
118
|
+
version: '0.74'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.74
|
125
|
+
version: '0.74'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rubocop-rails
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,14 +157,14 @@ dependencies:
|
|
157
157
|
requirements:
|
158
158
|
- - "~>"
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
160
|
+
version: '13'
|
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: '13'
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: sqlite3
|
170
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,14 +185,14 @@ dependencies:
|
|
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.
|
@@ -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.
|
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
|