shopify-gold 3.0.0 → 3.0.1
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 +4 -4
- data/README.md +64 -24
- data/app/models/gold/machine.rb +1 -1
- data/lib/gold/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c030cdd2491bfaaa608daf0872d00a666c02de89075ebdfc02e2db16c9b4fc1a
|
4
|
+
data.tar.gz: f09f58ef6ed29763f352985b06a4b69d4c178aa98a344be6c3b7d4d18692de88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4ec8a6c8c13d9dc81de919fe16d9da5ec952ed1573f8f437a853499013a1511aa3862e0474f4137f7cd1313cd9a15369a5def927f59e50b3c2fcf8d1b6c70d
|
7
|
+
data.tar.gz: 2790090bddf8bf32067ddc50fbfeecea31b90b8c0aa017111a696153e1825400d50f0e1d00ac2cadc45f2988b34b29b019a74d5d4fe9ff1d20a57b34af9e9365
|
data/README.md
CHANGED
@@ -38,8 +38,8 @@ You will need to apply migrations to your app's `Shop` class and bring in the
|
|
38
38
|
other Gold models to your database:
|
39
39
|
|
40
40
|
```bash
|
41
|
-
$
|
42
|
-
$
|
41
|
+
$ rake gold_engine:install:migrations
|
42
|
+
$ rake db:migrate
|
43
43
|
```
|
44
44
|
|
45
45
|
Mount the engine in your `config/routes.rb` file:
|
@@ -53,7 +53,9 @@ you'll need to define a new helper method `gold_engine` and reference your custo
|
|
53
53
|
`as` param.
|
54
54
|
|
55
55
|
Add module to your `Shop` class:
|
56
|
-
|
56
|
+
```ruby
|
57
|
+
include Gold::Concerns::Gilded
|
58
|
+
```
|
57
59
|
|
58
60
|
Add the following methods to your `Shop` class:
|
59
61
|
`#shopify_domain`, which responds with the *.myshopify.com domain of the shop
|
@@ -65,29 +67,22 @@ After shop properties have been updated (say, after a shop/update webhook), call
|
|
65
67
|
`shop.billing.after_shop_update!`. This tells Gold something has changed about the
|
66
68
|
shop, which will run any operations (example affiliate -> paid) that might be relevant.
|
67
69
|
|
68
|
-
Call the AfterAuthenticateJob inline when a user logs in.
|
69
|
-
|
70
|
-
|
70
|
+
Call the AfterAuthenticateJob inline when a user logs in.
|
71
|
+
In `shopify_app.rb` initializer:
|
72
|
+
```ruby
|
73
|
+
config.after_authenticate_job = { job: Gold::AfterAuthenticateJob, inline: true }
|
74
|
+
```
|
75
|
+
Or in your own job:
|
76
|
+
```ruby
|
77
|
+
Gold::AfterAuthenticateJob.perform_now(shop_domain: shop_domain)
|
78
|
+
```
|
79
|
+
|
71
80
|
|
72
81
|
## Background tasks
|
73
82
|
Gold runs background jobs to queue events under the `gold` queue. For example, if
|
74
83
|
you're using Sidekiq, run:
|
75
|
-
|
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
|
84
|
+
```bash
|
85
|
+
$ bundle exec sidekiq -q gold
|
91
86
|
```
|
92
87
|
|
93
88
|
## Configuration
|
@@ -124,10 +119,16 @@ Gold.configure do |config|
|
|
124
119
|
config.plan_comparison_url = "https://heliumdev.com/pricing"
|
125
120
|
|
126
121
|
# The API version used by Shopify (https://help.shopify.com/en/api/versioning)
|
127
|
-
|
122
|
+
config.shopify_api_version = "2019-04"
|
128
123
|
|
129
124
|
# If Gold is allowed to cancel charges (paid -> free) automatically
|
130
|
-
|
125
|
+
config.allow_automated_charge_cancellation = true
|
126
|
+
|
127
|
+
config.admin_credentials = {
|
128
|
+
user: "admin",
|
129
|
+
password: "password123"
|
130
|
+
}
|
131
|
+
|
131
132
|
end
|
132
133
|
```
|
133
134
|
|
@@ -165,6 +166,38 @@ Gold.configure do |config|
|
|
165
166
|
end
|
166
167
|
```
|
167
168
|
|
169
|
+
## Adding tiers
|
170
|
+
To add tiers to your app, add a `config/tiers.yml` file. Here's an example file:
|
171
|
+
```
|
172
|
+
- id: basic
|
173
|
+
name: "Basic"
|
174
|
+
description: "Shops just gettings started with a few number of custom fields."
|
175
|
+
features:
|
176
|
+
feature_1: Yes
|
177
|
+
featured_2: No
|
178
|
+
pricing:
|
179
|
+
trial_days: 14
|
180
|
+
monthly: "10.00"
|
181
|
+
qualifications:
|
182
|
+
max_customers: 1000
|
183
|
+
```
|
184
|
+
|
185
|
+
## Controller and views
|
186
|
+
Ok, so it's time to get paid. Let's add our module to show merchants tier choices.
|
187
|
+
|
188
|
+
Include the following in your `ApplicationController`:
|
189
|
+
```ruby
|
190
|
+
include Gold::Concerns::MerchantFacing
|
191
|
+
```
|
192
|
+
|
193
|
+
When you want to put an action or controller behind a paywall, add:
|
194
|
+
```ruby
|
195
|
+
before_action :confront_mandatory_billing_action
|
196
|
+
```
|
197
|
+
|
198
|
+
You can override any view file by matching Gold's path pattern under `views`. The
|
199
|
+
most notable are likely
|
200
|
+
|
168
201
|
## Admin interface
|
169
202
|
Gold can manage billing for each shop through an admin interface. First, you'll
|
170
203
|
want to setup some basic HTTP auth credentials in your Gold config initializer.
|
@@ -184,6 +217,13 @@ You can inject a partial anywhere in your own admin interface to include Gold's
|
|
184
217
|
admin management by providing an instance of `Billing`:
|
185
218
|
`render "gold/admin/billing/overview", billing: @shop.billing`
|
186
219
|
|
220
|
+
This partial expects the following instance variables to be defined from your
|
221
|
+
controller:
|
222
|
+
```
|
223
|
+
@active_charge = ShopifyAPI::RecurringApplicationCharge.current
|
224
|
+
@credits = ShopifyAPI::ApplicationCredit.all || []
|
225
|
+
```
|
226
|
+
|
187
227
|
## Migration
|
188
228
|
If you have existing charges that you want to migrate to Gold on a specific plan,
|
189
229
|
use the `BillingMigrator.new([Shop], [tier_id], [start_at])` class. Example:
|
data/app/models/gold/machine.rb
CHANGED
@@ -180,7 +180,7 @@ module Gold
|
|
180
180
|
before_transition to: :apply_tier, &require_metadata(:tier_id)
|
181
181
|
transition from: :apply_tier, to: :billing
|
182
182
|
before_transition to: :apply_free_tier, &require_metadata(:tier_id)
|
183
|
-
transition from: :apply_free_tier, to:
|
183
|
+
transition from: :apply_free_tier, to: %i[billing staff affiliate]
|
184
184
|
|
185
185
|
transition from: :billing, to: %i[apply_discount
|
186
186
|
calculate_usage
|
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: 3.0.
|
4
|
+
version: 3.0.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: 2019-09-
|
12
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|