shopify-gold 5.2.1 → 6.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d15786e3bd37ff9291bf4f000c3f580373a56dcf5bd8662df743ec4a30ec5c36
4
- data.tar.gz: 9f838172385fffd62d0397c92db4acb8a8bda60c7aac144bfdaf90883d6ba452
3
+ metadata.gz: 5af1f02e51816d38e9006351b7f2a34cf7e8e72ba868faab7cf1ab2f14fe8c7d
4
+ data.tar.gz: 817a1c5a99a6099bed127d6eb8af9c7e30363e35f2b219ce66c6d558861c9b95
5
5
  SHA512:
6
- metadata.gz: 9eb7a98aab47e7948e56b3522586ca3023bbf19e9fd3df2c7cac5036bf8986b8abfc963ec9173056999aef245a0879d0cdc7f0f5dc0b62c5145131f97571c556
7
- data.tar.gz: 3c642760a522e4e1c8cac183f6eb2b7f5e36d8bb2d885bb34de7faf83cd0c237ee6d93d6771328efe742a5619cb44178912529a4b9287fd72d383be442f896b7
6
+ metadata.gz: 1d7ef42beab7002310f8ef6cb9c317fd031a8c55d7d0040b4a9b889183fe7b6cf264f458552fc849bc314ea33f02ad7c100c382300706df9f9fbbdd68b1dfbbd
7
+ data.tar.gz: 804b615464d2a7d1b0c5f70d84871ce1a8d56cc9770afe978c495671d0e9e2f9a7e23a56f581a218c6d6bc42afa368b9aa74a38da75fd7cc8721fc8ab047dc89
data/README.md CHANGED
@@ -119,9 +119,6 @@ Gold.configure do |config|
119
119
  # The URL to a plan comparison page for the app
120
120
  config.plan_comparison_url = "https://heliumdev.com/pricing"
121
121
 
122
- # The API version used by Shopify (https://help.shopify.com/en/api/versioning)
123
- config.shopify_api_version = "2019-04"
124
-
125
122
  # If Gold is allowed to cancel charges (paid -> free) automatically
126
123
  config.allow_automated_charge_cancellation = true
127
124
 
@@ -165,7 +165,7 @@ module Gold
165
165
  private
166
166
 
167
167
  def shopify_session
168
- billing.shop.with_shopify_session do
168
+ billing.with_shopify_session do
169
169
  yield
170
170
  end
171
171
  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
@@ -16,7 +16,7 @@ module Gold
16
16
  # cleaned up.
17
17
  billing = Billing.find_or_create_by!(shop: shop)
18
18
 
19
- shop.with_shopify_session do
19
+ billing.with_shopify_session do
20
20
  outcome = InstallOp.new(billing).call
21
21
 
22
22
  case outcome
@@ -5,7 +5,7 @@ module Gold
5
5
 
6
6
  # Inform a merchant about their account becoming suspended.
7
7
  def suspension(billing)
8
- billing.shop.with_shopify_session do
8
+ billing.with_shopify_session do
9
9
  @shop = ShopifyAPI::Shop.current
10
10
  mail(to: @shop.email,
11
11
  subject: "We have suspended your access to #{Gold.configuration.app_name}")
@@ -14,7 +14,7 @@ module Gold
14
14
 
15
15
  # Inform a merchant about their non-payment.
16
16
  def delinquent(billing)
17
- billing.shop.with_shopify_session do
17
+ billing.with_shopify_session do
18
18
  @shop = ShopifyAPI::Shop.current
19
19
  mail(to: @shop.email,
20
20
  subject: "We need you to approve a charge for " \
@@ -23,7 +23,7 @@ module Gold
23
23
  end
24
24
 
25
25
  def affiliate_to_paid(billing, confirmation_url)
26
- billing.shop.with_shopify_session do
26
+ billing.with_shopify_session do
27
27
  @shop = ShopifyAPI::Shop.current
28
28
  @confirmation_url = confirmation_url
29
29
  app_name = Gold.configuration.app_name
@@ -50,6 +50,8 @@ module Gold
50
50
  association_name: :transitions)
51
51
  end
52
52
 
53
+ delegate :with_shopify_session, to: :shop
54
+
53
55
  delegate :can_transition_to?,
54
56
  :transition_to!,
55
57
  :transition_to,
@@ -112,7 +114,7 @@ module Gold
112
114
 
113
115
  Gold.logger.info("Received shop update from '#{shop.shopify_domain}'")
114
116
 
115
- shop.with_shopify_session do
117
+ billing.with_shopify_session do
116
118
  case current_state
117
119
  when :affiliate
118
120
  if shopify_plan.paying?
@@ -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[accepted_terms marked_as_uninstalled]
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)
@@ -10,11 +10,13 @@ module Gold
10
10
  end
11
11
 
12
12
  def call
13
- # If possible, transition to reinstalled
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
@@ -3,7 +3,7 @@
3
3
  <strong>Active charge</strong>
4
4
  </div>
5
5
  <div class="card-body">
6
- <% billing.shop.with_shopify_session do %>
6
+ <% billing.with_shopify_session do %>
7
7
  <% charge = @active_charge %>
8
8
  <% if charge %>
9
9
  <% if charge.test %>
@@ -1,4 +1,4 @@
1
- <% billing.shop.with_shopify_session do %>
1
+ <% billing.with_shopify_session do %>
2
2
  <div class="card mb-3">
3
3
  <div class="card-header">
4
4
  <strong>Credit</strong>
@@ -45,6 +45,8 @@ module Gold
45
45
  trial_starts_at: @trial_starts_at
46
46
  )
47
47
 
48
+ @billing.transition_to! :install
49
+
48
50
  lookup_tier!
49
51
  accept_terms
50
52
  select_tier
@@ -7,7 +7,6 @@ module Gold
7
7
  :plan_comparison_url,
8
8
  :logger,
9
9
  :admin_credentials,
10
- :shopify_api_version,
11
10
  :allow_automated_charge_cancellation,
12
11
  :days_until_delinquent,
13
12
  :days_until_cleanup,
@@ -64,9 +63,6 @@ module Gold
64
63
  password: "password123"
65
64
  }
66
65
 
67
- # The API version used by Shopify (https://help.shopify.com/en/api/versioning)
68
- @shopify_api_version = "2019-04"
69
-
70
66
  # If Gold is allowed to cancel charges (paid -> free) automatically
71
67
  @allow_automated_charge_cancellation = true
72
68
 
data/lib/gold/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gold
2
- VERSION = "5.2.1".freeze
2
+ VERSION = "6.0.0".freeze
3
3
  end
@@ -51,7 +51,7 @@ namespace :gold do
51
51
  Gold::Billing.all.each do |billing|
52
52
  next unless billing.state_machine.can_transition_to?(:check_charge)
53
53
 
54
- billing.shop.with_shopify_session do
54
+ billing.with_shopify_session do
55
55
  outcome = Gold::CheckChargeOp.new(billing).call
56
56
 
57
57
  if outcome.ok?
@@ -66,8 +66,7 @@ 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
69
+ rescue Statesman::GuardFailedError => e
71
70
  puts "Cannot transition: #{e.message}"
72
71
  end
73
72
  end
@@ -78,7 +77,7 @@ namespace :gold do
78
77
  Gold::Billing.all.each do |billing|
79
78
  next unless billing.state_machine.can_transition_to?(:cleanup)
80
79
 
81
- billing.shop.with_shopify_session do
80
+ billing.with_shopify_session do
82
81
  outcome = Gold::CleanupOp.new(billing).call
83
82
  puts "Cleanup for shop '#{billing.shop.shopify_domain}': #{outcome}"
84
83
  end
@@ -92,7 +91,7 @@ namespace :gold do
92
91
  next unless billing.state_machine.can_transition_to?(:marked_as_delinquent)
93
92
  end
94
93
 
95
- billing.shop.with_shopify_session do
94
+ billing.with_shopify_session do
96
95
  domain = billing.shop.shopify_domain
97
96
 
98
97
  begin
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-gold
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith
8
8
  - Nick Mealey
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-15 00:00:00.000000000 Z
12
+ date: 2021-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -43,16 +43,16 @@ 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: '13'
48
+ version: '16'
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: '13'
55
+ version: '16'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: statesman
58
58
  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: '13'
160
+ version: '16'
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: '13'
167
+ version: '16'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: sqlite3
170
170
  requirement: !ruby/object:Gem::Requirement
@@ -302,7 +302,7 @@ files:
302
302
  homepage: https://gitlab.com/helium-development/infrastructure/gold
303
303
  licenses: []
304
304
  metadata: {}
305
- post_install_message:
305
+ post_install_message:
306
306
  rdoc_options: []
307
307
  require_paths:
308
308
  - lib
@@ -317,8 +317,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  - !ruby/object:Gem::Version
318
318
  version: '0'
319
319
  requirements: []
320
- rubygems_version: 3.0.3
321
- signing_key:
320
+ rubyforge_project:
321
+ rubygems_version: 2.7.10
322
+ signing_key:
322
323
  specification_version: 4
323
324
  summary: Helium's approach to billing for Shopify apps
324
325
  test_files: []