shopify-gold 2.1.0.pre → 2.1.1.pre
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/app/controllers/gold/admin/billing_controller.rb +6 -2
- data/app/models/gold/machine.rb +2 -1
- data/app/operations/gold/apply_discount_op.rb +9 -2
- data/app/views/gold/admin/billing/_credit.erb +2 -3
- data/app/views/gold/admin/billing/_discount.erb +1 -5
- 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: be0da51bb5675160c788669b7ff9b25a27725b473eae16b12c2bd0329328d3cf
|
4
|
+
data.tar.gz: 2a93b3f89cdd593eca1f198fc630607c5531d86460f04e1fa04c986ef45f5351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7113dfe26ca0db2d14b83924c80fc0d33762fa18af524a374d81ff66aec80b6e7fe13c7c19f115c7af1d433499c300e911e56cb37dc12af005ceadf58273cd91
|
7
|
+
data.tar.gz: 85fbd823becc14c31308c38a5ff272f3a8fbe5f6db99fb57aeaf1fbb23dd9cd8210fd9be5617cf3bd965de66ab4c5d4fa86b8482f65929c4ee29bb628e964a8c
|
@@ -32,7 +32,9 @@ module Gold
|
|
32
32
|
|
33
33
|
outcome = SelectTierOp.new(billing, tier).call
|
34
34
|
|
35
|
-
if outcome.
|
35
|
+
if outcome.is_a?(Outcomes::TierApplied)
|
36
|
+
flash[:success] = "Changed billing to '#{tier.name}'"
|
37
|
+
elsif outcome.ok?
|
36
38
|
charge_outcome = ChargeOp.new(billing, process_charge_url).call
|
37
39
|
|
38
40
|
if charge_outcome.is_a?(Outcomes::ActiveCharge)
|
@@ -115,8 +117,10 @@ module Gold
|
|
115
117
|
params[:percentage].to_i,
|
116
118
|
process_charge_url).call
|
117
119
|
|
118
|
-
if outcome.
|
120
|
+
if outcome.is_a?(Outcomes::PendingCharge)
|
119
121
|
flash[:warning] = "Discount applied, merchant must reauthorize the charge"
|
122
|
+
elsif outcome.ok?
|
123
|
+
flash[:success] = "Discount updated, will be used for future charges"
|
120
124
|
else
|
121
125
|
flash[:danger] = "Failed to apply discount because '#{outcome.message}'"
|
122
126
|
end
|
data/app/models/gold/machine.rb
CHANGED
@@ -239,7 +239,8 @@ module Gold
|
|
239
239
|
transition from: :delayed_charge_accepted, to: %i[charge_activated
|
240
240
|
marked_as_uninstalled]
|
241
241
|
|
242
|
-
transition from: :delayed_charge_expired, to:
|
242
|
+
transition from: :delayed_charge_expired, to: %i[delayed_charge
|
243
|
+
marked_as_delinquent]
|
243
244
|
transition from: :delayed_charge_declined, to: %i[marked_as_delinquent
|
244
245
|
delayed_charge]
|
245
246
|
|
@@ -23,10 +23,17 @@ module Gold
|
|
23
23
|
|
24
24
|
return SameDiscount.new if @percentage == @billing.discount_percentage
|
25
25
|
|
26
|
-
@billing.transition_to!(:apply_discount, percentage: @percentage)
|
27
26
|
@billing.update(discount_percentage: @percentage)
|
28
27
|
|
29
|
-
|
28
|
+
# If we can transition to apply discount, let's do that. This means we're
|
29
|
+
# in a billing state and a new charge will be created. Otherwise, it's
|
30
|
+
# OK to just set the `discount_percentage` field for future charges
|
31
|
+
if @billing.can_transition_to?(:apply_discount)
|
32
|
+
@billing.transition_to!(:apply_discount, percentage: @percentage)
|
33
|
+
ChargeOp.new(@billing, @return_url, @test).call
|
34
|
+
else
|
35
|
+
Success.new
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
<% billing.shop.with_shopify_session do %>
|
2
|
-
<% credits = ShopifyAPI::ApplicationCredit.all %>
|
3
2
|
<div class="card mb-3">
|
4
3
|
<div class="card-header">
|
5
4
|
<strong>Credit</strong>
|
6
5
|
</div>
|
7
6
|
<div class="card-body">
|
8
7
|
<h6>Credits</h6>
|
9
|
-
<% if credits.any? %>
|
8
|
+
<% if @credits.any? %>
|
10
9
|
<table class="table celled">
|
11
10
|
<thead>
|
12
11
|
<tr>
|
@@ -15,7 +14,7 @@
|
|
15
14
|
</tr>
|
16
15
|
</thead>
|
17
16
|
<tbody>
|
18
|
-
<% credits.each do |credit| %>
|
17
|
+
<% @credits.each do |credit| %>
|
19
18
|
<tr>
|
20
19
|
<td>
|
21
20
|
<%= credit.description %>
|
@@ -12,11 +12,7 @@
|
|
12
12
|
value="<%= billing.discount_percentage %>">%
|
13
13
|
<div>
|
14
14
|
<hr>
|
15
|
-
|
16
|
-
<%= submit_tag 'Apply discount', class: "btn btn-primary", data: {confirm: "Are you really sure you want to apply this discount?"} %>
|
17
|
-
<% else %>
|
18
|
-
<p>Discount cannot be applied in the current state</p>
|
19
|
-
<% end %>
|
15
|
+
<%= submit_tag 'Apply discount', class: "btn btn-primary", data: {confirm: "Are you really sure you want to apply this discount?"} %>
|
20
16
|
</div>
|
21
17
|
<% end %>
|
22
18
|
</div>
|
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.1.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-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|