effective_orders 5.1.14 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/app/controllers/effective/providers/free.rb +1 -2
- data/app/models/concerns/acts_as_subscribable.rb +1 -3
- data/app/models/effective/order.rb +33 -26
- data/app/models/effective/subscripter.rb +3 -5
- data/app/models/effective/subscription.rb +4 -1
- data/app/views/effective/orders/_order_shipping.html.haml +1 -1
- data/config/effective_orders.rb +1 -1
- data/lib/effective_orders/version.rb +1 -1
- data/lib/effective_orders.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: 79d6c5b375a23ec257f7b5d357ee38bd63ccc050b9909bff1b8b125e8b7115d5
|
4
|
+
data.tar.gz: bdca1e23836d7fde14bf5de938ce4803327f0396310061188217384605544e76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09bf234893689bd3f569f8d9eb8ba2b627b82eaf1370edbc7b130b23df40d2f588394fb5da52a3dd9e8c0ce8a671e5cc66c2ec074ff6c06672a4c931563092c5'
|
7
|
+
data.tar.gz: f6e1a19c93b81d872c7e6992833f02a59012778a5a7ba4f8510ffbd69e9df7b5c8669c1bec2aba48e39817a1623d2cf1c6aae6c718a02816ec7c226ced406c6e
|
data/README.md
CHANGED
@@ -399,8 +399,6 @@ On the Checkout page (`effective_orders.new_order_path`) a new `Effective::Order
|
|
399
399
|
|
400
400
|
If the configuration options `config.billing_address` and/or `config.shipping_address` options are `true` then the user will be prompted for the appropriate addresses, based on [effective_addresses](https://github.com/code-and-effect/effective_addresses/).
|
401
401
|
|
402
|
-
If `config.use_address_full_name` is set to `true` then appropriate form field will be shown and the user will be prompted for the appropriate address full name during the checkout process, based on [effective_addresses](https://github.com/code-and-effect/effective_addresses/).
|
403
|
-
|
404
402
|
When the user submits the form on this screen, a POST to `effective_orders.order_path` is made, and the `Effective::Order` object is validated and created.
|
405
403
|
|
406
404
|
On this final checkout screen, links to all configured payment providers are displayed, and the user may choose which payment processor should be used to make a payment.
|
@@ -24,9 +24,7 @@ module ActsAsSubscribable
|
|
24
24
|
raise :abort unless (subscripter.destroy! rescue false)
|
25
25
|
end
|
26
26
|
|
27
|
-
if EffectiveOrders.trial?
|
28
|
-
validates :trialing_until, presence: true
|
29
|
-
end
|
27
|
+
validates :trialing_until, presence: true, if: -> { EffectiveOrders.trial? }
|
30
28
|
|
31
29
|
validates :subscription_status, inclusion: { allow_nil: true, in: EffectiveOrders::STATUSES.keys }
|
32
30
|
|
@@ -12,13 +12,11 @@ module Effective
|
|
12
12
|
self.table_name = EffectiveOrders.orders_table_name.to_s
|
13
13
|
|
14
14
|
if EffectiveOrders.obfuscate_order_ids
|
15
|
+
raise('unsupported obfuscation with tenant') if defined?(Tenant)
|
15
16
|
acts_as_obfuscated format: '###-####-###'
|
16
17
|
end
|
17
18
|
|
18
|
-
acts_as_addressable(
|
19
|
-
billing: { singular: true, use_full_name: EffectiveOrders.use_address_full_name },
|
20
|
-
shipping: { singular: true, use_full_name: EffectiveOrders.use_address_full_name }
|
21
|
-
)
|
19
|
+
acts_as_addressable(billing: { singular: true }, shipping: { singular: true })
|
22
20
|
|
23
21
|
attr_accessor :terms_and_conditions # Yes, I agree to the terms and conditions
|
24
22
|
attr_accessor :confirmed_checkout # Set on the Checkout Step 1
|
@@ -68,8 +66,8 @@ module Effective
|
|
68
66
|
before_validation { assign_order_totals }
|
69
67
|
before_validation { assign_billing_name }
|
70
68
|
before_validation { assign_email }
|
71
|
-
before_validation { assign_last_address }
|
72
69
|
before_validation { assign_user_address }
|
70
|
+
before_validation { assign_last_address }
|
73
71
|
|
74
72
|
before_validation(if: -> { confirmed_checkout }) do
|
75
73
|
assign_attributes(state: EffectiveOrders::CONFIRMED) if pending?
|
@@ -88,11 +86,14 @@ module Effective
|
|
88
86
|
validates :state, inclusion: { in: EffectiveOrders::STATES.keys }
|
89
87
|
validates :subtotal, presence: true
|
90
88
|
|
91
|
-
if EffectiveOrders.minimum_charge.to_i > 0
|
92
|
-
validates :total, presence: true
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
with_options(if: -> { EffectiveOrders.minimum_charge.to_i > 0 }) do
|
90
|
+
validates :total, presence: true
|
91
|
+
|
92
|
+
validate(unless: -> { (free? && EffectiveOrders.free?) || (refund? && EffectiveOrders.refund?) }) do
|
93
|
+
if total.present? && total < EffectiveOrders.minimum_charge
|
94
|
+
self.errors.add(:total, "must be $#{'%0.2f' % (EffectiveOrders.minimum_charge.to_i / 100.0)} or more. Please add additional items.")
|
95
|
+
end
|
96
|
+
end
|
96
97
|
end
|
97
98
|
|
98
99
|
validate(if: -> { tax_rate.present? }) do
|
@@ -106,17 +107,9 @@ module Effective
|
|
106
107
|
validates :tax_rate, presence: { message: "can't be determined based on billing address" }
|
107
108
|
validates :tax, presence: true
|
108
109
|
|
109
|
-
if EffectiveOrders.billing_address
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
if EffectiveOrders.shipping_address
|
114
|
-
validates :shipping_address, presence: true
|
115
|
-
end
|
116
|
-
|
117
|
-
if EffectiveOrders.collect_note_required
|
118
|
-
validates :note, presence: true
|
119
|
-
end
|
110
|
+
validates :billing_address, presence: true, if: -> { EffectiveOrders.billing_address }
|
111
|
+
validates :shipping_address, presence: true, if: -> { EffectiveOrders.shipping_address }
|
112
|
+
validates :note, presence: true, if: -> { EffectiveOrders.collect_note_required }
|
120
113
|
end
|
121
114
|
|
122
115
|
# When Purchased
|
@@ -124,12 +117,21 @@ module Effective
|
|
124
117
|
validates :purchased_at, presence: true
|
125
118
|
validates :payment, presence: true
|
126
119
|
|
127
|
-
validates :payment_provider, presence: true
|
120
|
+
validates :payment_provider, presence: true
|
121
|
+
|
122
|
+
validate do
|
123
|
+
self.errors.add(:payment_provider, "unknown payment provider") unless EffectiveOrders.payment_providers.include?(payment_provider)
|
124
|
+
end
|
125
|
+
|
128
126
|
validates :payment_card, presence: true
|
129
127
|
end
|
130
128
|
|
131
129
|
with_options if: -> { deferred? } do
|
132
|
-
validates :payment_provider, presence: true
|
130
|
+
validates :payment_provider, presence: true
|
131
|
+
|
132
|
+
validate do
|
133
|
+
self.errors.add(:payment_provider, "unknown deferred payment provider") unless EffectiveOrders.deferred_providers.include?(payment_provider)
|
134
|
+
end
|
133
135
|
end
|
134
136
|
|
135
137
|
scope :deep, -> { includes(:addresses, :user, order_items: :purchasable) }
|
@@ -388,15 +390,20 @@ module Effective
|
|
388
390
|
end
|
389
391
|
|
390
392
|
def send_order_receipt_to_admin?
|
391
|
-
EffectiveOrders.mailer[:
|
393
|
+
return false if free? && !EffectiveOrders.mailer[:send_order_receipts_when_free]
|
394
|
+
EffectiveOrders.mailer[:send_order_receipt_to_admin]
|
392
395
|
end
|
393
396
|
|
394
397
|
def send_order_receipt_to_buyer?
|
395
|
-
EffectiveOrders.mailer[:
|
398
|
+
return false if free? && !EffectiveOrders.mailer[:send_order_receipts_when_free]
|
399
|
+
EffectiveOrders.mailer[:send_order_receipt_to_buyer]
|
396
400
|
end
|
397
401
|
|
398
402
|
def send_payment_request_to_buyer?
|
399
|
-
|
403
|
+
return false if free? && !EffectiveOrders.mailer[:send_order_receipts_when_free]
|
404
|
+
return false if refund?
|
405
|
+
|
406
|
+
EffectiveResources.truthy?(send_payment_request_to_buyer)
|
400
407
|
end
|
401
408
|
|
402
409
|
def send_mark_as_paid_email_to_buyer?
|
@@ -11,11 +11,9 @@ module Effective
|
|
11
11
|
validates :subscribable, presence: true, if: -> { stripe_plan_id.present? }
|
12
12
|
validates :customer, presence: true
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
message: 'unknown plan'
|
18
|
-
}
|
14
|
+
validate(if: -> { stripe_plan_id.present? }) do
|
15
|
+
self.errors.add(:stripe_plan_id, 'unknown plan') unless EffectiveOrders.stripe_plans.map { |plan| plan[:id] }.include?(stripe_plan_id)
|
16
|
+
end
|
19
17
|
|
20
18
|
validate(if: -> { stripe_plan_id && plan && plan[:amount] > 0 }) do
|
21
19
|
self.errors.add(:stripe_token, 'updated payment card required') if stripe_token.blank? && token_required?
|
@@ -47,7 +47,10 @@ module Effective
|
|
47
47
|
validates :subscribable, presence: true
|
48
48
|
|
49
49
|
validates :stripe_plan_id, presence: true
|
50
|
-
|
50
|
+
|
51
|
+
validate(if: -> { stripe_plan_id.present? }) do
|
52
|
+
self.errors.add(:stripe_plan_id, 'unknown plan') unless EffectiveOrders.stripe_plans.map { |plan| plan[:id] }.include?(stripe_plan_id)
|
53
|
+
end
|
51
54
|
|
52
55
|
validates :stripe_subscription_id, presence: true
|
53
56
|
|
data/config/effective_orders.rb
CHANGED
@@ -19,7 +19,6 @@ EffectiveOrders.setup do |config|
|
|
19
19
|
# Require these addresses when creating a new Order. Works with effective_addresses gem
|
20
20
|
config.billing_address = true
|
21
21
|
config.shipping_address = false
|
22
|
-
config.use_address_full_name = true
|
23
22
|
|
24
23
|
# Use effective_obfuscation gem to change order.id into a seemingly random 10-digit number
|
25
24
|
config.obfuscate_order_ids = false
|
@@ -95,6 +94,7 @@ EffectiveOrders.setup do |config|
|
|
95
94
|
send_payment_request_to_buyer: true,
|
96
95
|
send_pending_order_invoice_to_buyer: true,
|
97
96
|
send_order_receipts_when_mark_as_paid: false,
|
97
|
+
send_order_receipts_when_free: false,
|
98
98
|
|
99
99
|
send_subscription_event_to_admin: true,
|
100
100
|
send_subscription_created: true,
|
data/lib/effective_orders.rb
CHANGED
@@ -36,7 +36,7 @@ module EffectiveOrders
|
|
36
36
|
:layout, :mailer_class_name, :mailer,
|
37
37
|
:orders_collection_scope, :order_tax_rate_method,
|
38
38
|
:obfuscate_order_ids, :use_effective_qb_sync,
|
39
|
-
:billing_address, :shipping_address,
|
39
|
+
:billing_address, :shipping_address,
|
40
40
|
:collect_note, :collect_note_required, :collect_note_message,
|
41
41
|
:terms_and_conditions, :terms_and_conditions_label, :minimum_charge,
|
42
42
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|