effective_orders 5.4.0 → 5.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/effective_orders/_order.scss +1 -1
- data/app/controllers/admin/orders_controller.rb +4 -4
- data/app/controllers/effective/providers/mark_as_paid.rb +1 -1
- data/app/datatables/admin/effective_orders_datatable.rb +1 -1
- data/app/mailers/effective/orders_mailer.rb +1 -1
- data/app/models/effective/order.rb +5 -3
- data/app/views/effective/orders/mark_as_paid/_form.html.haml +7 -6
- data/lib/effective_orders/version.rb +1 -1
- data/lib/effective_orders.rb +18 -0
- 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: 93201b2a28d118f01d4404c0a1b1e7ce9cfccfa17e5449923d827f804297146f
|
4
|
+
data.tar.gz: 33c7e7c0b13f149bbea2c46d4f3aa70dbf3d4157c73be9dfe0b84f965e17bd13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e7b680b06ac025f6b4b8bad7845f95f92f04ab952479ee8cc66025b55da853a4c8871c910f322fdb4062860c66695fb8f9c3b52b3e56bc041bc243078d076b
|
7
|
+
data.tar.gz: 4750b01b2d298736a05e6f9290146695816f9c0a15dcd80701c2c0a04c1516cf4ebedd790ec334674aaf335abc77a7f58241274b1812897bc6b5b408650dff80
|
@@ -15,7 +15,7 @@ module Admin
|
|
15
15
|
submit :save, 'Checkout', redirect: -> { effective_orders.checkout_admin_order_path(resource) }
|
16
16
|
|
17
17
|
def create
|
18
|
-
@user = current_user.class.find_by_id(
|
18
|
+
@user = current_user.class.find_by_id(permitted_params[:user_id])
|
19
19
|
@order = Effective::Order.new(user: @user)
|
20
20
|
|
21
21
|
authorize_effective_order!
|
@@ -23,12 +23,12 @@ module Admin
|
|
23
23
|
|
24
24
|
Effective::Order.transaction do
|
25
25
|
begin
|
26
|
-
(
|
26
|
+
(permitted_params[:order_items_attributes] || {}).each do |_, item_attrs|
|
27
27
|
purchasable = Effective::Product.new(item_attrs[:purchasable_attributes])
|
28
28
|
@order.add(purchasable, quantity: item_attrs[:quantity])
|
29
29
|
end
|
30
30
|
|
31
|
-
@order.attributes =
|
31
|
+
@order.attributes = permitted_params.except(:order_items_attributes, :user_id)
|
32
32
|
@order.pending!
|
33
33
|
|
34
34
|
message = 'Successfully created order'
|
@@ -123,7 +123,7 @@ module Admin
|
|
123
123
|
|
124
124
|
private
|
125
125
|
|
126
|
-
def
|
126
|
+
def permitted_params
|
127
127
|
params.require(:effective_order).permit(:user_id, :user_type, :cc,
|
128
128
|
:send_payment_request_to_buyer, :note_internal, :note_to_buyer,
|
129
129
|
:payment_provider, :payment_card, :payment, :send_mark_as_paid_email_to_buyer,
|
@@ -26,7 +26,7 @@ module Effective
|
|
26
26
|
def mark_as_paid_params
|
27
27
|
params.require(:effective_order).permit(
|
28
28
|
:purchased_at, :payment, :payment_provider, :payment_card,
|
29
|
-
:note_to_buyer, :send_mark_as_paid_email_to_buyer
|
29
|
+
:note_to_buyer, :note_internal, :send_mark_as_paid_email_to_buyer
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
@@ -72,7 +72,7 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
72
72
|
|
73
73
|
col :total, as: :price
|
74
74
|
|
75
|
-
col :payment_provider, label: 'Provider', visible: false, search: { collection: EffectiveOrders.
|
75
|
+
col :payment_provider, label: 'Provider', visible: false, search: { collection: EffectiveOrders.admin_payment_providers }
|
76
76
|
col :payment_card, label: 'Card', visible: false
|
77
77
|
|
78
78
|
if EffectiveOrders.collect_note
|
@@ -49,7 +49,7 @@ module Effective
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# This is sent to admin when someone Accepts Refund
|
52
|
-
def refund_notification_to_admin(
|
52
|
+
def refund_notification_to_admin(resource, opts = {})
|
53
53
|
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
54
54
|
|
55
55
|
@order = resource
|
@@ -120,7 +120,7 @@ module Effective
|
|
120
120
|
validates :payment_provider, presence: true
|
121
121
|
|
122
122
|
validate do
|
123
|
-
self.errors.add(:payment_provider, "unknown payment provider") unless EffectiveOrders.payment_providers.include?(payment_provider)
|
123
|
+
self.errors.add(:payment_provider, "unknown payment provider") unless (EffectiveOrders.payment_providers + EffectiveOrders.admin_payment_providers).include?(payment_provider)
|
124
124
|
end
|
125
125
|
|
126
126
|
validates :payment_card, presence: true
|
@@ -323,6 +323,8 @@ module Effective
|
|
323
323
|
def payment_method
|
324
324
|
return nil unless purchased?
|
325
325
|
|
326
|
+
provider = payment_provider if ['cheque', 'phone'].include?(payment_provider)
|
327
|
+
|
326
328
|
# Normalize payment card
|
327
329
|
card = case payment_card.to_s.downcase.gsub(' ', '').strip
|
328
330
|
when '' then nil
|
@@ -331,7 +333,7 @@ module Effective
|
|
331
333
|
when 'a', 'ax', 'american', 'americanexpress' then 'American Express'
|
332
334
|
when 'd', 'discover' then 'Discover'
|
333
335
|
else payment_card.to_s
|
334
|
-
end
|
336
|
+
end
|
335
337
|
|
336
338
|
last4 = if payment[:active_card] && payment[:active_card].include?('**** **** ****')
|
337
339
|
payment[:active_card][15,4]
|
@@ -340,7 +342,7 @@ module Effective
|
|
340
342
|
# stripe, moneris, moneris_checkout
|
341
343
|
last4 ||= (payment['f4l4'] || payment['first6last4']).to_s.last(4)
|
342
344
|
|
343
|
-
[
|
345
|
+
[provider.presence, card.presence, last4.presence].compact.join(' - ')
|
344
346
|
end
|
345
347
|
|
346
348
|
def duplicate
|
@@ -7,20 +7,21 @@
|
|
7
7
|
= effective_form_with(model: order, url: effective_orders.mark_as_paid_order_path(order), method: :post) do |f|
|
8
8
|
= f.hidden_field :purchased_at, value: Time.zone.now
|
9
9
|
|
10
|
-
= f.select :payment_provider, EffectiveOrders.
|
10
|
+
= f.select :payment_provider, EffectiveOrders.admin_payment_providers, required: true
|
11
11
|
|
12
12
|
= f.text_field :payment_card,
|
13
13
|
label: 'Payment card type, cheque or transaction number',
|
14
14
|
hint: 'Do not enter credit card numbers here, or anywhere.'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
.row
|
17
|
+
.col
|
18
|
+
= f.text_area :note_to_buyer, hint: 'This message will be displayed to the buyer on the receipt.'
|
19
|
+
.col
|
20
|
+
= f.text_area :note_internal, hint: 'For or internal admin use only. This note will never be displayed to the buyer.'
|
19
21
|
|
20
22
|
= f.check_box :send_mark_as_paid_email_to_buyer,
|
21
23
|
label: 'Yes, send a receipt email to the buyer.',
|
22
24
|
input_html: { checked: (f.object.send_mark_as_paid_email_to_buyer.nil? ? EffectiveOrders.send_order_receipts_when_mark_as_paid : f.object.send_mark_as_paid_email_to_buyer?) }
|
23
25
|
|
24
|
-
= f.text_area :note_to_buyer, hint: 'This message will be displayed on the receipt.'
|
25
26
|
|
26
|
-
= f.submit
|
27
|
+
= f.submit order_checkout_label(order.refund? ? :refund : :mark_as_paid)
|
data/lib/effective_orders.rb
CHANGED
@@ -142,6 +142,24 @@ module EffectiveOrders
|
|
142
142
|
].compact
|
143
143
|
end
|
144
144
|
|
145
|
+
# For the Admin Mark as Paid screen
|
146
|
+
def self.admin_payment_providers
|
147
|
+
[
|
148
|
+
('cheque' if mark_as_paid?),
|
149
|
+
('credit card' if mark_as_paid?),
|
150
|
+
#('free' if free?),
|
151
|
+
('moneris' if moneris?),
|
152
|
+
('moneris_checkout' if moneris_checkout?),
|
153
|
+
('paypal' if paypal?),
|
154
|
+
('phone' if mark_as_paid?),
|
155
|
+
#('pretend' if pretend?),
|
156
|
+
#('refund' if refund?),
|
157
|
+
('stripe' if stripe?),
|
158
|
+
('other' if mark_as_paid?),
|
159
|
+
'none'
|
160
|
+
].compact
|
161
|
+
end
|
162
|
+
|
145
163
|
def self.deferred_providers
|
146
164
|
[('cheque' if cheque?), ('phone' if phone?)].compact
|
147
165
|
end
|
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.
|
4
|
+
version: 5.4.3
|
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: 2022-03-
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|