shopify-gold 2.1.7.pre → 2.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/operations/gold/accept_or_decline_charge_op.rb +1 -0
- data/app/operations/gold/check_charge_op.rb +15 -12
- data/lib/gold.rb +2 -78
- data/lib/gold/billing_migrator.rb +3 -1
- data/lib/gold/configuration.rb +80 -0
- data/lib/gold/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99f0de847ec187bfbbd0dc8d7bde7a2b23320851b61d637f3bd028c16f6f16e6
|
4
|
+
data.tar.gz: dc0efcde47cdf3355c17d47e700c3e36e6b94dd581ad26aa1dea3bbc30efdf3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6a1c4ec0719da7869e3612e8c017082a0c320cca04788f48457e436d2128d50d9f494207c1ecd3fb5f61501e10186f427099d5642dc8f6766e2f30031c92053
|
7
|
+
data.tar.gz: 230f2b0972feaf7a0a748fbd4baf76c50d3dbd80a3c4c8bf1f2523556c54c20b3a91444d488258cc9b0dff0cd36ba99fb5d659e18ce89118e9791c32be9e3026
|
data/README.md
CHANGED
@@ -147,6 +147,10 @@ Gold.configure do |config|
|
|
147
147
|
puts "Applied tier..."
|
148
148
|
}
|
149
149
|
|
150
|
+
config.on_activate_charge = proc { |billing, charge|
|
151
|
+
puts "Activated charge..."
|
152
|
+
}
|
153
|
+
|
150
154
|
config.on_uninstall = proc {
|
151
155
|
puts "Uninstalling Gold..."
|
152
156
|
}
|
@@ -154,6 +158,10 @@ Gold.configure do |config|
|
|
154
158
|
config.on_cleanup = proc { |billing|
|
155
159
|
puts "Cleaning up shop"
|
156
160
|
}
|
161
|
+
|
162
|
+
config.on_check_charge = proc { |billing, active_charge|
|
163
|
+
puts "Check charge for shop"
|
164
|
+
}
|
157
165
|
end
|
158
166
|
```
|
159
167
|
|
@@ -23,18 +23,21 @@ module Gold
|
|
23
23
|
active_charge = charges.find { |charge| charge.status == "active" }
|
24
24
|
frozen_charge = charges.find { |charge| charge.status == "frozen" }
|
25
25
|
|
26
|
-
if active_charge && billing_matches_charge?(active_charge)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
outcome = if active_charge && billing_matches_charge?(active_charge)
|
27
|
+
@billing.transition_to!(:billing)
|
28
|
+
ActiveCharge.new(active_charge.id)
|
29
|
+
elsif frozen_charge && @billing.transition_to(:frozen)
|
30
|
+
FrozenCharge.new
|
31
|
+
elsif active_charge
|
32
|
+
@billing.transition_to!(:charge_missing)
|
33
|
+
MismatchCharge.new
|
34
|
+
else
|
35
|
+
@billing.transition_to!(:charge_missing)
|
36
|
+
MissingCharge.new
|
37
|
+
end
|
38
|
+
|
39
|
+
Gold.configuration.on_check_charge&.call(@billing, active_charge)
|
40
|
+
outcome
|
38
41
|
end
|
39
42
|
|
40
43
|
private
|
data/lib/gold.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require "gold/engine"
|
2
1
|
require "gold/billing_migrator"
|
2
|
+
require "gold/configuration"
|
3
|
+
require "gold/engine"
|
3
4
|
require "gold/outcomes"
|
4
5
|
require "statesman"
|
5
6
|
|
@@ -23,81 +24,4 @@ module Gold
|
|
23
24
|
self.configuration ||= Configuration.new
|
24
25
|
yield(configuration)
|
25
26
|
end
|
26
|
-
|
27
|
-
# Config for Gold
|
28
|
-
class Configuration
|
29
|
-
attr_accessor :test_charge,
|
30
|
-
:app_name,
|
31
|
-
:contact_email,
|
32
|
-
:plan_comparison_url,
|
33
|
-
:logger,
|
34
|
-
:admin_credentials,
|
35
|
-
:shopify_api_version,
|
36
|
-
:allow_automated_charge_cancellation,
|
37
|
-
:days_until_delinquent,
|
38
|
-
:days_until_cleanup,
|
39
|
-
:shop_domain_attribute
|
40
|
-
|
41
|
-
# Callbacks
|
42
|
-
attr_accessor :on_terms,
|
43
|
-
:on_install,
|
44
|
-
:on_uninstall,
|
45
|
-
:on_cleanup,
|
46
|
-
:on_apply_tier
|
47
|
-
|
48
|
-
attr_writer :shop_class
|
49
|
-
|
50
|
-
def initialize
|
51
|
-
# The class name (string) of the the app's Active Record Shop model
|
52
|
-
@shop_class = nil
|
53
|
-
|
54
|
-
# The attribute of the *.myshopify.com domain on the Shop model
|
55
|
-
@shop_domain_attribute = nil
|
56
|
-
|
57
|
-
# Should Gold create test charges? Helpful in a development environment
|
58
|
-
@test_charge = false
|
59
|
-
|
60
|
-
# The logger Gold will use
|
61
|
-
@logger = Logger.new(STDOUT)
|
62
|
-
|
63
|
-
# How many days we'll wait before cleaning up an uninstalled shop
|
64
|
-
@days_until_cleanup = 30
|
65
|
-
|
66
|
-
# How many days we'll wait before we uninstall a shop without payment
|
67
|
-
@days_until_delinquent = 7
|
68
|
-
|
69
|
-
# The name of the app using gold (used in the charge name)
|
70
|
-
@app_name = "My App"
|
71
|
-
|
72
|
-
# The email Gold uses to send emails from
|
73
|
-
@contact_email = nil
|
74
|
-
|
75
|
-
# The URL to a plan comparison page for the app
|
76
|
-
@plan_comparison_url = nil
|
77
|
-
|
78
|
-
# Login credential's to Gold's backend
|
79
|
-
@admin_credentials = {
|
80
|
-
user: "admin",
|
81
|
-
password: "password123"
|
82
|
-
}
|
83
|
-
|
84
|
-
# The API version used by Shopify (https://help.shopify.com/en/api/versioning)
|
85
|
-
@shopify_api_version = "2019-04"
|
86
|
-
|
87
|
-
# If Gold is allowed to cancel charges (paid -> free) automatically
|
88
|
-
@allow_automated_charge_cancellation = true
|
89
|
-
end
|
90
|
-
|
91
|
-
def shop_class
|
92
|
-
@shop_constant ||= @shop_class.to_s.constantize
|
93
|
-
rescue NameError
|
94
|
-
raise "'#{@shop_class}' is not a valid class name for shop class. " \
|
95
|
-
"You must specify one in your Gold config file with " \
|
96
|
-
"'config.shop'"
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_charge?
|
100
|
-
@test_charge
|
101
|
-
end
|
102
|
-
end
|
103
27
|
end
|
@@ -56,7 +56,9 @@ module Gold
|
|
56
56
|
rescue ActiveResource::UnauthorizedAccess,
|
57
57
|
ActiveResource::ForbiddenAccess,
|
58
58
|
ActiveResource::ResourceNotFound
|
59
|
-
Gold.logger.info("Shop '#{@shop.shopify_domain}' is uninstalled
|
59
|
+
Gold.logger.info("Shop '#{@shop.shopify_domain}' is uninstalled")
|
60
|
+
UninstallOp.new(@billing).call
|
61
|
+
true
|
60
62
|
end
|
61
63
|
|
62
64
|
private
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Gold
|
2
|
+
# Config for Gold
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :test_charge,
|
5
|
+
:app_name,
|
6
|
+
:contact_email,
|
7
|
+
:plan_comparison_url,
|
8
|
+
:logger,
|
9
|
+
:admin_credentials,
|
10
|
+
:shopify_api_version,
|
11
|
+
:allow_automated_charge_cancellation,
|
12
|
+
:days_until_delinquent,
|
13
|
+
:days_until_cleanup,
|
14
|
+
:shop_domain_attribute
|
15
|
+
|
16
|
+
# Callbacks
|
17
|
+
attr_accessor :on_terms,
|
18
|
+
:on_install,
|
19
|
+
:on_activate_charge,
|
20
|
+
:on_apply_tier,
|
21
|
+
:on_uninstall,
|
22
|
+
:on_cleanup,
|
23
|
+
:on_check_charge
|
24
|
+
|
25
|
+
attr_writer :shop_class
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
# The class name (string) of the the app's Active Record Shop model
|
29
|
+
@shop_class = nil
|
30
|
+
|
31
|
+
# The attribute of the *.myshopify.com domain on the Shop model
|
32
|
+
@shop_domain_attribute = nil
|
33
|
+
|
34
|
+
# Should Gold create test charges? Helpful in a development environment
|
35
|
+
@test_charge = false
|
36
|
+
|
37
|
+
# The logger Gold will use
|
38
|
+
@logger = Logger.new(STDOUT)
|
39
|
+
|
40
|
+
# How many days we'll wait before cleaning up an uninstalled shop
|
41
|
+
@days_until_cleanup = 30
|
42
|
+
|
43
|
+
# How many days we'll wait before we uninstall a shop without payment
|
44
|
+
@days_until_delinquent = 7
|
45
|
+
|
46
|
+
# The name of the app using gold (used in the charge name)
|
47
|
+
@app_name = "My App"
|
48
|
+
|
49
|
+
# The email Gold uses to send emails from
|
50
|
+
@contact_email = nil
|
51
|
+
|
52
|
+
# The URL to a plan comparison page for the app
|
53
|
+
@plan_comparison_url = nil
|
54
|
+
|
55
|
+
# Login credential's to Gold's backend
|
56
|
+
@admin_credentials = {
|
57
|
+
user: "admin",
|
58
|
+
password: "password123"
|
59
|
+
}
|
60
|
+
|
61
|
+
# The API version used by Shopify (https://help.shopify.com/en/api/versioning)
|
62
|
+
@shopify_api_version = "2019-04"
|
63
|
+
|
64
|
+
# If Gold is allowed to cancel charges (paid -> free) automatically
|
65
|
+
@allow_automated_charge_cancellation = true
|
66
|
+
end
|
67
|
+
|
68
|
+
def shop_class
|
69
|
+
@shop_constant ||= @shop_class.to_s.constantize
|
70
|
+
rescue NameError
|
71
|
+
raise "'#{@shop_class}' is not a valid class name for shop class. " \
|
72
|
+
"You must specify one in your Gold config file with " \
|
73
|
+
"'config.shop'"
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_charge?
|
77
|
+
@test_charge
|
78
|
+
end
|
79
|
+
end
|
80
|
+
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: 2.1.
|
4
|
+
version: 2.1.8
|
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-08-
|
12
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- lib/gold.rb
|
280
280
|
- lib/gold/admin_engine.rb
|
281
281
|
- lib/gold/billing_migrator.rb
|
282
|
+
- lib/gold/configuration.rb
|
282
283
|
- lib/gold/coverage.rb
|
283
284
|
- lib/gold/diagram.rb
|
284
285
|
- lib/gold/engine.rb
|
@@ -302,9 +303,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
302
303
|
version: '2.5'
|
303
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
305
|
requirements:
|
305
|
-
- - "
|
306
|
+
- - ">="
|
306
307
|
- !ruby/object:Gem::Version
|
307
|
-
version:
|
308
|
+
version: '0'
|
308
309
|
requirements: []
|
309
310
|
rubygems_version: 3.0.1
|
310
311
|
signing_key:
|