effective_orders 5.4.4 → 5.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/effective/providers/mark_as_paid.rb +3 -3
- data/app/helpers/effective_stripe_helper.rb +3 -0
- data/app/models/effective/order.rb +22 -6
- data/app/views/effective/orders/stripe/_form.html.haml +1 -1
- data/config/effective_orders.rb +2 -0
- data/lib/effective_orders/version.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: 496c6b24100359c7121e1903130d345ed5b13fabf41cf1a1e78be20be3d638c8
|
4
|
+
data.tar.gz: a2451ac65694daa46c2386dd13754d6ed43ae2e9b8b34ff16903ec6c9591e888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24a8a97d2bc9c2b45680fc4e9f8c751245d5e83d69ff085a744f1e16709219cafb04c13c55fd88eda8a2b2707eaeea0dea48a2c9f66c682187720ef334aab1b7
|
7
|
+
data.tar.gz: 14af91d8e9a56efe0e65d07348f4de7c2fc83a14df32d06b3e3cb40306b4469b575dfaf9c629a9f67369226da089b464d46c0be0cda1d3a5ca15a68b3693d6a4
|
@@ -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
|
@@ -70,6 +70,9 @@ module EffectiveStripeHelper
|
|
70
70
|
|
71
71
|
token_required = customer.token_required?
|
72
72
|
|
73
|
+
# Always prompt them for a card unless remember card
|
74
|
+
token_required = true unless EffectiveOrders.stripe[:remember_card]
|
75
|
+
|
73
76
|
intent = begin
|
74
77
|
Rails.logger.info "[STRIPE] create payment intent : #{payment}"
|
75
78
|
Stripe::PaymentIntent.create(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
|
@@ -9,7 +9,7 @@
|
|
9
9
|
%em This checkout is powered by stripe.
|
10
10
|
|
11
11
|
.my-4.text-center
|
12
|
-
=
|
12
|
+
= image_tag('effective_orders/stripe.png', alt: 'Stripe.com Logo')
|
13
13
|
|
14
14
|
= effective_form_with(scope: :stripe, url: effective_orders.stripe_order_path(order), data: { 'stripe-form': stripe.to_json }) do |f|
|
15
15
|
= f.hidden_field :purchased_url, value: purchased_url
|
data/config/effective_orders.rb
CHANGED
@@ -210,6 +210,7 @@ EffectiveOrders.setup do |config|
|
|
210
210
|
# secret_key: 'sk_xxx',
|
211
211
|
# publishable_key: 'pk_xxx',
|
212
212
|
# currency: 'usd',
|
213
|
+
# remember_card: true,
|
213
214
|
# site_title: 'My Site',
|
214
215
|
# site_image: 'logo.png' # A relative or absolute URL pointing to a square image of your brand or product. The recommended minimum size is 128x128px.
|
215
216
|
# }
|
@@ -218,6 +219,7 @@ EffectiveOrders.setup do |config|
|
|
218
219
|
# secret_key: 'sk_test_xxx',
|
219
220
|
# publishable_key: 'pk_test_xxx',
|
220
221
|
# currency: 'usd',
|
222
|
+
# remember_card: true,
|
221
223
|
# site_title: 'My Site',
|
222
224
|
# site_image: 'logo.png' # A relative or absolute URL pointing to a square image of your brand or product. The recommended minimum size is 128x128px.
|
223
225
|
# }
|
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.2
|
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-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|