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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1676b1a7b5f40851c951840a9eb371b1e54e3d99c48510b57fb88b5b75f8d2b5
4
- data.tar.gz: 86b326329275200a2b260cb01cda9e2cbc573f372d6aae56001c1c91d59a3198
3
+ metadata.gz: 34d5d843d5364c956719f1e8a7dcc07425bb70cc04420e73e519dd4445fec4c7
4
+ data.tar.gz: 64e70e869ab4150b7ee68954403b0f028fe6cabf650656f22ecc49f42b3d904e
5
5
  SHA512:
6
- metadata.gz: 36038ed587f95233a7bad620d60f9c007403033283bd6b0092ab3bbddaf162481a99a23c6b5928609582c3f9ae43d7aea351c551ca55636fbe69c44ae315c501
7
- data.tar.gz: ca547aa3098e08492b727a32584b7817402c417375fb454a410e94058bccb7d686ea3239eacb99e018c8fca0eac69b38263e278c87e0b0d5b5db1c936df03f04
6
+ metadata.gz: 591f04007fc784eacc6ed40ed74daf242de37930a9738dda370ce56edf6e21df8670cf5fc04765987970f69c2006841c2f9bcbb16fefb4e9412fb93da6443c75
7
+ data.tar.gz: 017b2cee8f4425ced8d0ba7e375653816bb74bfb24b78e4b26ec8862e8ffa78dab0d04212466a11cee1de10bc1a953782ff95c76a3c53f91d815a7f20534bd10
@@ -46,7 +46,7 @@ form.new_effective_order {
46
46
  }
47
47
 
48
48
  .effective-moneris-checkout {
49
- height: 640px;
49
+ height: 720px;
50
50
  }
51
51
 
52
52
  @media print {
@@ -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(order_params[:user_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
- (order_params[:order_items_attributes] || {}).each do |_, item_attrs|
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 = order_params.except(:order_items_attributes, :user_id)
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 order_params
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.payment_providers }
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 unless payment_provider == 'free'
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
- [card, '-', last4].compact.join(' ')
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.payment_providers, required: true
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
- = f.text_area :payment,
17
- label: 'Additional payment details',
18
- input_html: { value: f.object.payment.kind_of?(Hash) ? f.object.payment[:details] : f.object.payment.presence }
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 'Admin: ' + order_checkout_label(order.refund? ? :refund : :mark_as_paid)
27
+ = f.submit order_checkout_label(order.refund? ? :refund : :mark_as_paid)
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.4.1'.freeze
2
+ VERSION = '5.4.4'.freeze
3
3
  end
@@ -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.1
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-07 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails