effective_orders 5.4.3 → 5.5.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c85d15408b6f15085acae0e838a73738f06b302c1730a2d5dd63bfc14aeab232
|
4
|
+
data.tar.gz: 3ef013aef146e28669878e441b942bb9f4b0dc19e1871ced2097a2367fad9ab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdbb7867bd6336373a78ee7a601fc5866b90e8dce68f2ca19d8e47c90a88a0b18ada917e4fa485a416cabc75fb0c95fab37bd65c069c0b30e030b6761f1675f6
|
7
|
+
data.tar.gz: e30f27c7a2801feae282487ed6e1d5414c78b94e1f50dbb800f016782299ed02afa329164585af50d7933ae7269f4fb3ebf9eda0eb94ad68a6cfd22b8a13b1b6
|
@@ -11,10 +11,10 @@ module Effective
|
|
11
11
|
EffectiveResources.authorize!(self, :update, @order)
|
12
12
|
EffectiveResources.authorize!(self, :admin, :effective_orders)
|
13
13
|
|
14
|
-
@order.assign_attributes(mark_as_paid_params.except(:
|
14
|
+
@order.assign_attributes(mark_as_paid_params.except(:payment_provider, :payment_card))
|
15
15
|
|
16
16
|
order_purchased(
|
17
|
-
payment:
|
17
|
+
payment: 'mark as paid',
|
18
18
|
provider: mark_as_paid_params[:payment_provider],
|
19
19
|
card: mark_as_paid_params[:payment_card],
|
20
20
|
email: @order.send_mark_as_paid_email_to_buyer?,
|
@@ -25,7 +25,7 @@ module Effective
|
|
25
25
|
|
26
26
|
def mark_as_paid_params
|
27
27
|
params.require(:effective_order).permit(
|
28
|
-
:purchased_at, :
|
28
|
+
:purchased_at, :payment_provider, :payment_card,
|
29
29
|
:note_to_buyer, :note_internal, :send_mark_as_paid_email_to_buyer
|
30
30
|
)
|
31
31
|
end
|
@@ -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 = {
|
@@ -335,6 +335,18 @@ module Effective
|
|
335
335
|
else payment_card.to_s
|
336
336
|
end
|
337
337
|
|
338
|
+
# Try again
|
339
|
+
if card == 'none' && payment['card_type'].present?
|
340
|
+
card = case payment['card_type'].to_s.downcase.gsub(' ', '').strip
|
341
|
+
when '' then nil
|
342
|
+
when 'v', 'visa' then 'Visa'
|
343
|
+
when 'm', 'mc', 'master', 'mastercard' then 'MasterCard'
|
344
|
+
when 'a', 'ax', 'american', 'americanexpress' then 'American Express'
|
345
|
+
when 'd', 'discover' then 'Discover'
|
346
|
+
else payment_card.to_s
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
338
350
|
last4 = if payment[:active_card] && payment[:active_card].include?('**** **** ****')
|
339
351
|
payment[:active_card][15,4]
|
340
352
|
end
|
@@ -486,14 +498,18 @@ module Effective
|
|
486
498
|
|
487
499
|
# Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
|
488
500
|
def purchase!(payment: 'none', provider: 'none', card: 'none', email: true, skip_buyer_validations: false, skip_quickbooks: false)
|
501
|
+
return true if purchased?
|
502
|
+
|
489
503
|
# Assign attributes
|
490
|
-
|
491
|
-
|
504
|
+
assign_attributes(
|
505
|
+
state: EffectiveOrders::PURCHASED,
|
506
|
+
skip_buyer_validations: skip_buyer_validations,
|
492
507
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
508
|
+
payment_provider: provider,
|
509
|
+
payment_card: (card.presence || 'none'),
|
510
|
+
purchased_at: Time.zone.now,
|
511
|
+
payment: payment_to_h(payment)
|
512
|
+
)
|
497
513
|
|
498
514
|
begin
|
499
515
|
Effective::Order.transaction do
|
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.5.1
|
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-
|
11
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|