shopify-gold 2.0.1.pre → 2.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +73 -9
- data/app/controllers/gold/billing_controller.rb +4 -0
- data/app/controllers/gold/concerns/merchant_facing.rb +2 -0
- data/app/views/gold/billing/login_error.html.erb +0 -0
- data/app/views/gold/billing/transition_error.html.erb +3 -2
- data/lib/gold/exceptions/billing_not_found.rb +5 -0
- data/lib/gold/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a207a2139e8e1ab1be012353b58500a6ab9f0c6799f6158cd131bfe63a0fc7e0
|
4
|
+
data.tar.gz: 16a1d206a15a09286a79ded2239807dcc9c16767fb57ba1f75481515ccac9226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8027b833952d50b72ed0a38d24a8c32307b00e911a67fc2edd24657a64532a50eafa343fa92d8ab7b6d2d9ade2abf5d2f6a4786a810e770afa0caad07a45adb5
|
7
|
+
data.tar.gz: b2dc4970350aa2c6466f9256bcd98b66916c7d0d1664998ca83d6aeb57e3dee10565cff178413b88d170e6f398d720f8728243dc151f97e3a81d6b750315b814
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Gold is comprised of a few pieces:
|
|
25
25
|
Add this line to your application's Gemfile:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem
|
28
|
+
gem "shopify-gold", require: "gold"
|
29
29
|
```
|
30
30
|
|
31
31
|
And then execute:
|
@@ -42,16 +42,54 @@ $ bin/rails gold:install:migrations
|
|
42
42
|
$ bin/rails db:migrate
|
43
43
|
```
|
44
44
|
|
45
|
-
|
45
|
+
Mount the engine in your `config/routes.rb` file:
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
mount Gold::Engine, at: "/"
|
48
|
+
mount Gold::Engine, at: "/billing"
|
49
49
|
```
|
50
50
|
|
51
51
|
Note that by default, the engine's name is `gold_engine`. If you must change this,
|
52
52
|
you'll need to define a new helper method `gold_engine` and reference your custom
|
53
53
|
`as` param.
|
54
54
|
|
55
|
+
Add module to your `Shop` class:
|
56
|
+
`include Gold::Concerns::Gilded`
|
57
|
+
|
58
|
+
Add the following methods to your `Shop` class:
|
59
|
+
`#shopify_domain`, which responds with the *.myshopify.com domain of the shop
|
60
|
+
`#shopify_plan_name`, which responds to the plan name of the Shopify store (e.g. "unlimited", "affilaite")
|
61
|
+
`#qualifies_for_tier?(_tier)`, return a boolean if the shop should qualify to a tier
|
62
|
+
`#with_shopify_session`, provided by the Shopify App gem
|
63
|
+
|
64
|
+
After shop properties have been updated (say, after a shop/update webhook), call:
|
65
|
+
`shop.billing.after_shop_update!`. This tells Gold something has changed about the
|
66
|
+
shop, which will run any operations (example affiliate -> paid) that might be relevant.
|
67
|
+
|
68
|
+
Call the AfterAuthenticateJob inline when a user logs in. This can be setup
|
69
|
+
either directly in `shopify_app.rb` initializer, or in your own job.
|
70
|
+
`Gold::AfterAuthenticateJob.perform_now(shop_domain: shop_domain)`
|
71
|
+
|
72
|
+
## Background tasks
|
73
|
+
Gold runs background jobs to queue events under the `gold` queue. For example, if
|
74
|
+
you're using Sidekiq, run:
|
75
|
+
`bundle exec sidekiq -q gold`
|
76
|
+
|
77
|
+
## Adding tiers
|
78
|
+
To add tiers to your app, add a `config/tiers.yml` file. Here's an example file:
|
79
|
+
```
|
80
|
+
- id: basic
|
81
|
+
name: "Basic"
|
82
|
+
description: "Shops just gettings started with a few number of custom fields."
|
83
|
+
features:
|
84
|
+
feature_1: Yes
|
85
|
+
featured_2: No
|
86
|
+
pricing:
|
87
|
+
trial_days: 14
|
88
|
+
monthly: "10.00"
|
89
|
+
qualifications:
|
90
|
+
max_customers: 1000
|
91
|
+
```
|
92
|
+
|
55
93
|
## Configuration
|
56
94
|
Add `gold.rb` within the `initializers` folder of your project. Below are Gold's
|
57
95
|
configuration options:
|
@@ -85,12 +123,6 @@ Gold.configure do |config|
|
|
85
123
|
# The URL to a plan comparison page for the app
|
86
124
|
config.plan_comparison_url = "https://heliumdev.com/pricing"
|
87
125
|
|
88
|
-
# Login credential's to Gold's backend
|
89
|
-
config.admin_credentials = {
|
90
|
-
user: "admin",
|
91
|
-
password: "password123"
|
92
|
-
}
|
93
|
-
|
94
126
|
# The API version used by Shopify (https://help.shopify.com/en/api/versioning)
|
95
127
|
@shopify_api_version = "2019-04"
|
96
128
|
|
@@ -125,6 +157,34 @@ Gold.configure do |config|
|
|
125
157
|
end
|
126
158
|
```
|
127
159
|
|
160
|
+
## Admin interface
|
161
|
+
Gold can manage billing for each shop through an admin interface. First, you'll
|
162
|
+
want to setup some basic HTTP auth credentials in your Gold config initializer.
|
163
|
+
```
|
164
|
+
Gold.configure do |config|
|
165
|
+
config.admin_credentials = {
|
166
|
+
user: "admin",
|
167
|
+
password: "password123"
|
168
|
+
}
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
Mount the engine in routes:
|
173
|
+
`mount Gold::AdminEngine, at: '/admin', as: 'gold_admin_engine'`
|
174
|
+
|
175
|
+
You can inject a partial anywhere in your own admin interface to include Gold's
|
176
|
+
admin management by providing an instance of `Billing`:
|
177
|
+
`render "gold/admin/billing/overview", billing: @shop.billing`
|
178
|
+
|
179
|
+
## Migration
|
180
|
+
If you have existing charges that you want to migrate to Gold on a specific plan,
|
181
|
+
use the `BillingMigrator.new([Shop], [tier_id], [start_at])` class. Example:
|
182
|
+
`Gold::BillingMigrator.new(@shop, "basic", 5.days.ago)`
|
183
|
+
|
184
|
+
The shop will automatically be pushed through the state machine (new, accepted_terms, etc).
|
185
|
+
Note that the `tier_id` must match a tier setup in Gold. If that shop does not
|
186
|
+
have a charge that matches the tier's price, a new charge will be requested.
|
187
|
+
|
128
188
|
## Contributing
|
129
189
|
|
130
190
|
Run tests with:
|
@@ -142,3 +202,7 @@ $ bundle exec rubocop
|
|
142
202
|
If you want to see a visual representation of `Gold::Machine`, you can run
|
143
203
|
`bin/rails app:gold:diagram`. You will need to have the Graphviz tool installed,
|
144
204
|
which you can do on Mac via Homebrew with `brew install graphviz`
|
205
|
+
|
206
|
+
## Release
|
207
|
+
To release gem, run `gem release`, which depends on having `gem-release` installed
|
208
|
+
on your system.
|
@@ -14,6 +14,10 @@ module Gold
|
|
14
14
|
status: :internal_server_error
|
15
15
|
end
|
16
16
|
|
17
|
+
rescue_from Gold::Exceptions::BillingNotFound do
|
18
|
+
redirect_to shopify_app.login_path
|
19
|
+
end
|
20
|
+
|
17
21
|
# Show the terms of service.
|
18
22
|
def terms
|
19
23
|
@already_accepted = !billing.can_transition_to?(:accepted_terms)
|
@@ -10,6 +10,8 @@ module Gold
|
|
10
10
|
# Returns the Gold::Billing instance for the currently logged-in merchant.
|
11
11
|
def billing
|
12
12
|
@billing ||= Billing.find_by!(shop_id: session[:shopify])
|
13
|
+
rescue ActiveRecord::RecordNotFound
|
14
|
+
raise Gold::Exceptions::BillingNotFound
|
13
15
|
end
|
14
16
|
|
15
17
|
# `before_action` filter that forces a merchant to deal with
|
File without changes
|
@@ -3,7 +3,8 @@
|
|
3
3
|
</p>
|
4
4
|
|
5
5
|
<p>
|
6
|
-
We're sorry, but we couldn't respond to your request. Please
|
7
|
-
|
6
|
+
We're sorry, but we couldn't respond to your request. Please
|
7
|
+
<a href="<%= shopify_app.logout_path %>" class="Polaris-Link">logout</a>
|
8
|
+
and try again in a few minutes. If the problem persists, please reach out to our
|
8
9
|
support and we'll get right on it.
|
9
10
|
</p>
|
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.0.
|
4
|
+
version: 2.0.2.pre
|
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-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -152,19 +152,19 @@ dependencies:
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '1.2'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
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: '0'
|
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: '0'
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: sqlite3
|
170
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,6 +258,7 @@ files:
|
|
258
258
|
- app/views/gold/billing/_inner_head.html.erb
|
259
259
|
- app/views/gold/billing/declined_charge.html.erb
|
260
260
|
- app/views/gold/billing/expired_charge.html.erb
|
261
|
+
- app/views/gold/billing/login_error.html.erb
|
261
262
|
- app/views/gold/billing/missing_charge.html.erb
|
262
263
|
- app/views/gold/billing/outstanding_charge.html.erb
|
263
264
|
- app/views/gold/billing/suspended.html.erb
|
@@ -282,6 +283,7 @@ files:
|
|
282
283
|
- lib/gold/coverage.rb
|
283
284
|
- lib/gold/diagram.rb
|
284
285
|
- lib/gold/engine.rb
|
286
|
+
- lib/gold/exceptions/billing_not_found.rb
|
285
287
|
- lib/gold/exceptions/metadata_missing.rb
|
286
288
|
- lib/gold/outcomes.rb
|
287
289
|
- lib/gold/retries.rb
|