effective_orders 5.4.1 → 5.4.4
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/helpers/effective_stripe_helper.rb +10 -0
- 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: 34d5d843d5364c956719f1e8a7dcc07425bb70cc04420e73e519dd4445fec4c7
|
4
|
+
data.tar.gz: 64e70e869ab4150b7ee68954403b0f028fe6cabf650656f22ecc49f42b3d904e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 591f04007fc784eacc6ed40ed74daf242de37930a9738dda370ce56edf6e21df8670cf5fc04765987970f69c2006841c2f9bcbb16fefb4e9412fb93da6443c75
|
7
|
+
data.tar.gz: 017b2cee8f4425ced8d0ba7e375653816bb74bfb24b78e4b26ec8862e8ffa78dab0d04212466a11cee1de10bc1a953782ff95c76a3c53f91d815a7f20534bd10
|
@@ -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
|
@@ -47,6 +47,16 @@ module EffectiveStripeHelper
|
|
47
47
|
|
48
48
|
def stripe_payment_intent(order)
|
49
49
|
customer = Effective::Customer.for_user(order.user)
|
50
|
+
|
51
|
+
begin
|
52
|
+
stripe_payment_intent_payload(order, customer)
|
53
|
+
rescue => e
|
54
|
+
raise unless Rails.env.development?
|
55
|
+
stripe_payment_intent_payload(order, Effective::Customer.new(user: order.user))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def stripe_payment_intent_payload(order, customer)
|
50
60
|
customer.create_stripe_customer! # Only creates if customer not already present
|
51
61
|
|
52
62
|
payment = {
|
@@ -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.4
|
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-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|