effective_orders 6.14.6 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/effective/concerns/purchase.rb +7 -8
- data/app/controllers/effective/providers/cheque.rb +1 -0
- data/app/controllers/effective/providers/deluxe.rb +8 -3
- data/app/controllers/effective/providers/deluxe_delayed.rb +14 -2
- data/app/controllers/effective/providers/deluxe_delayed_purchase.rb +9 -3
- data/app/controllers/effective/providers/etransfer.rb +1 -0
- data/app/controllers/effective/providers/free.rb +2 -2
- data/app/controllers/effective/providers/mark_as_paid.rb +2 -2
- data/app/controllers/effective/providers/moneris.rb +17 -2
- data/app/controllers/effective/providers/moneris_checkout.rb +2 -2
- data/app/controllers/effective/providers/paypal.rb +6 -1
- data/app/controllers/effective/providers/phone.rb +1 -0
- data/app/controllers/effective/providers/pretend.rb +2 -2
- data/app/controllers/effective/providers/refund.rb +1 -0
- data/app/controllers/effective/providers/stripe.rb +8 -3
- data/app/models/effective/order.rb +5 -3
- data/app/views/admin/orders/_form_order.html.haml +2 -2
- data/app/views/effective/orders/_checkout_step2.html.haml +1 -1
- 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: 0c33107747aca735bb6baa8b845f15c0a1ccb438ca7c25ca58b31e9ab230f1de
|
4
|
+
data.tar.gz: 24a3f7e86c1d95ddfe3bb20d794e495b29c4cf83ffa4b3a3c0c63a333a7166e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c350776105133c3382b9b51c4bc139895df6acbec242bf351fe379cdbd5cf8b9d1fffe13f662123aaa29d075f385b4675aced7af5ce81bd8996ab67c120ceb0a
|
7
|
+
data.tar.gz: 13e0b330ed878ad9d6daeadcac913fbc51fac9dff3019bdfe96d604913afa6964402dc3c5c62092602d0de03a697107395a12579e73c37741bcbed0126ba87db
|
@@ -6,20 +6,19 @@ module Effective
|
|
6
6
|
protected
|
7
7
|
|
8
8
|
def admin_checkout?(payment_params)
|
9
|
-
payment_params[:purchased_url].to_s.include?('/admin/')
|
9
|
+
(payment_params[:purchased_url] || payment_params[:deferred_url]).to_s.include?('/admin/')
|
10
10
|
end
|
11
11
|
|
12
|
-
def order_purchased(payment:, provider:, card: 'none', email: true, skip_buyer_validations: false, purchased_url: nil
|
12
|
+
def order_purchased(payment:, provider:, card: 'none', email: true, skip_buyer_validations: false, purchased_url: nil)
|
13
13
|
@order.purchase!(
|
14
14
|
payment: payment,
|
15
15
|
provider: provider,
|
16
16
|
card: card,
|
17
17
|
email: email,
|
18
|
-
skip_buyer_validations: skip_buyer_validations
|
19
|
-
current_user: current_user
|
18
|
+
skip_buyer_validations: skip_buyer_validations
|
20
19
|
)
|
21
20
|
|
22
|
-
Effective::Cart.where(user: current_user).destroy_all if current_user.present?
|
21
|
+
Effective::Cart.where(user: @order.current_user).destroy_all if @order.current_user.present?
|
23
22
|
|
24
23
|
if flash[:success].blank?
|
25
24
|
if email && @order.send_order_receipt_to_buyer?
|
@@ -36,7 +35,7 @@ module Effective
|
|
36
35
|
def order_deferred(provider:, email: true, deferred_url: nil)
|
37
36
|
@order.defer!(provider: provider, email: email)
|
38
37
|
|
39
|
-
Effective::Cart.where(user: current_user).destroy_all if current_user.present?
|
38
|
+
Effective::Cart.where(user: @order.current_user).destroy_all if @order.current_user.present?
|
40
39
|
|
41
40
|
if flash[:success].blank?
|
42
41
|
if email
|
@@ -50,10 +49,10 @@ module Effective
|
|
50
49
|
redirect_to deferred_url.gsub(':id', @order.to_param.to_s)
|
51
50
|
end
|
52
51
|
|
53
|
-
def order_delayed(payment:, payment_intent:, provider:, card: 'none',
|
52
|
+
def order_delayed(payment:, payment_intent:, provider:, card: 'none', email: false, deferred_url: nil)
|
54
53
|
@order.delay!(payment: payment, payment_intent: payment_intent, provider: provider, card: card, email: email)
|
55
54
|
|
56
|
-
Effective::Cart.where(user: current_user).destroy_all if current_user.present?
|
55
|
+
Effective::Cart.where(user: @order.current_user).destroy_all if @order.current_user.present?
|
57
56
|
|
58
57
|
if flash[:success].blank?
|
59
58
|
if email
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('cheque provider is not available') unless EffectiveOrders.cheque?
|
8
8
|
|
9
9
|
@order ||= Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(cheque_params)
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('deluxe provider is not available') unless EffectiveOrders.deluxe?
|
8
8
|
|
9
9
|
@order = Effective::Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(deluxe_params)
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
|
@@ -39,7 +40,12 @@ module Effective
|
|
39
40
|
|
40
41
|
if purchased == false
|
41
42
|
flash[:danger] = "Payment was unsuccessful. The credit card payment failed with message: #{Array(payment['responseMessage']).to_sentence.presence || 'none'}. Please try again."
|
42
|
-
return order_declined(
|
43
|
+
return order_declined(
|
44
|
+
payment: payment,
|
45
|
+
provider: 'deluxe',
|
46
|
+
card: payment['card'],
|
47
|
+
declined_url: deluxe_params[:declined_url]
|
48
|
+
)
|
43
49
|
end
|
44
50
|
|
45
51
|
# Valid Authorized and Completed Payment
|
@@ -47,8 +53,7 @@ module Effective
|
|
47
53
|
payment: payment,
|
48
54
|
provider: 'deluxe',
|
49
55
|
card: payment['card'],
|
50
|
-
purchased_url: deluxe_params[:purchased_url]
|
51
|
-
current_user: (current_user unless admin_checkout?(deluxe_params))
|
56
|
+
purchased_url: deluxe_params[:purchased_url]
|
52
57
|
)
|
53
58
|
end
|
54
59
|
|
@@ -8,6 +8,7 @@ module Effective
|
|
8
8
|
raise('deluxe_delayed provider is not available') unless EffectiveOrders.deluxe_delayed?
|
9
9
|
|
10
10
|
@order = Effective::Order.deep.find(params[:id])
|
11
|
+
@order.current_user = current_user unless admin_checkout?(deluxe_delayed_params)
|
11
12
|
|
12
13
|
EffectiveResources.authorize!(self, :update, @order)
|
13
14
|
|
@@ -30,12 +31,23 @@ module Effective
|
|
30
31
|
valid = payment_intent['status'] == 'success'
|
31
32
|
|
32
33
|
if valid == false
|
33
|
-
return order_declined(
|
34
|
+
return order_declined(
|
35
|
+
payment: card_info,
|
36
|
+
provider: 'deluxe_delayed',
|
37
|
+
card: card_info['card'],
|
38
|
+
declined_url: deluxe_delayed_params[:declined_url]
|
39
|
+
)
|
34
40
|
end
|
35
41
|
|
36
42
|
flash[:success] = EffectiveOrders.deluxe_delayed[:success]
|
37
43
|
|
38
|
-
order_delayed(
|
44
|
+
order_delayed(
|
45
|
+
payment: card_info,
|
46
|
+
payment_intent: payment_intent_payload,
|
47
|
+
provider: 'deluxe_delayed',
|
48
|
+
card: card_info['card'],
|
49
|
+
deferred_url: deluxe_delayed_params[:deferred_url]
|
50
|
+
)
|
39
51
|
end
|
40
52
|
|
41
53
|
private
|
@@ -8,6 +8,7 @@ module Effective
|
|
8
8
|
raise('deluxe_delayed_purchase provider is not available') unless EffectiveOrders.deluxe_delayed?
|
9
9
|
|
10
10
|
@order ||= Order.deep.find(params[:id])
|
11
|
+
@order.current_user = nil # Admin action, we don't want to assign current_user to the order
|
11
12
|
|
12
13
|
EffectiveResources.authorize!(self, :update, @order)
|
13
14
|
EffectiveResources.authorize!(self, :admin, :effective_orders)
|
@@ -22,7 +23,13 @@ module Effective
|
|
22
23
|
|
23
24
|
if purchased == false
|
24
25
|
flash[:danger] = "Payment was unsuccessful. The credit card payment failed with message: #{Array(payment['responseMessage']).to_sentence.presence || 'none'}. Please try again."
|
25
|
-
|
26
|
+
|
27
|
+
return order_declined(
|
28
|
+
payment: payment,
|
29
|
+
provider: 'deluxe_delayed',
|
30
|
+
card: payment['card'],
|
31
|
+
declined_url: deluxe_delayed_purchase_params[:declined_url]
|
32
|
+
)
|
26
33
|
end
|
27
34
|
|
28
35
|
@order.assign_attributes(deluxe_delayed_purchase_params.except(:purchased_url, :declined_url, :id))
|
@@ -33,8 +40,7 @@ module Effective
|
|
33
40
|
card: payment['card'],
|
34
41
|
email: @order.send_mark_as_paid_email_to_buyer?,
|
35
42
|
skip_buyer_validations: true,
|
36
|
-
purchased_url: effective_orders.admin_order_path(@order)
|
37
|
-
current_user: nil # Admin action, we don't want to assign current_user to the order
|
43
|
+
purchased_url: effective_orders.admin_order_path(@order)
|
38
44
|
)
|
39
45
|
end
|
40
46
|
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('etransfer provider is not available') unless EffectiveOrders.etransfer?
|
8
8
|
|
9
9
|
@order ||= Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(etransfer_params)
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('free provider is not available') unless EffectiveOrders.free?
|
8
8
|
|
9
9
|
@order ||= Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(free_params)
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
|
@@ -20,8 +21,7 @@ module Effective
|
|
20
21
|
payment: 'free order. no payment required.',
|
21
22
|
provider: 'free',
|
22
23
|
card: 'none',
|
23
|
-
purchased_url: free_params[:purchased_url]
|
24
|
-
current_user: current_user
|
24
|
+
purchased_url: free_params[:purchased_url]
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('mark_as_paid provider is not available') unless EffectiveOrders.mark_as_paid?
|
8
8
|
|
9
9
|
@order ||= Order.deep.find(params[:id])
|
10
|
+
@order.current_user = nil # Admin action, we don't want to assign current_user to the order
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
EffectiveResources.authorize!(self, :admin, :effective_orders)
|
@@ -19,8 +20,7 @@ module Effective
|
|
19
20
|
card: mark_as_paid_params[:payment_card],
|
20
21
|
email: @order.send_mark_as_paid_email_to_buyer?,
|
21
22
|
skip_buyer_validations: true,
|
22
|
-
purchased_url: effective_orders.admin_order_path(@order)
|
23
|
-
current_user: nil # Admin action, we don't want to assign current_user to the order
|
23
|
+
purchased_url: effective_orders.admin_order_path(@order)
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
@@ -13,6 +13,7 @@ module Effective
|
|
13
13
|
raise('moneris provider is not available') unless EffectiveOrders.moneris?
|
14
14
|
|
15
15
|
@order ||= Effective::Order.deep.find(params[:response_order_id])
|
16
|
+
@order.current_user = current_user unless admin_checkout?(moneris_params)
|
16
17
|
|
17
18
|
# We do this even if we're not authorized
|
18
19
|
EffectiveResources.authorized?(self, :update, @order)
|
@@ -35,14 +36,28 @@ module Effective
|
|
35
36
|
valid = (1..49).include?(payment[:response_code].to_i) # Must be > 0 and < 50 to be valid. Sometimes we get the string 'null'
|
36
37
|
|
37
38
|
if valid == false
|
38
|
-
return order_declined(
|
39
|
+
return order_declined(
|
40
|
+
payment: payment,
|
41
|
+
provider: 'moneris',
|
42
|
+
card: params[:card],
|
43
|
+
declined_url: declined_url
|
44
|
+
)
|
39
45
|
end
|
40
46
|
|
41
|
-
order_purchased(
|
47
|
+
order_purchased(
|
48
|
+
payment: payment,
|
49
|
+
provider: 'moneris',
|
50
|
+
card: params[:card],
|
51
|
+
purchased_url: purchased_url
|
52
|
+
)
|
42
53
|
end
|
43
54
|
|
44
55
|
private
|
45
56
|
|
57
|
+
def moneris_params
|
58
|
+
{ purchased_url: params[:rvar_purchased_url] }
|
59
|
+
end
|
60
|
+
|
46
61
|
def verify_moneris_transaction(transactionKey)
|
47
62
|
# Send a verification POST request
|
48
63
|
uri = URI.parse(EffectiveOrders.moneris[:verify_url])
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('moneris_checkout provider is not available') unless EffectiveOrders.moneris_checkout?
|
8
8
|
|
9
9
|
@order = Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(moneris_checkout_params)
|
10
11
|
|
11
12
|
# We do this even if we're not authorized.
|
12
13
|
EffectiveResources.authorized?(self, :update, @order)
|
@@ -31,8 +32,7 @@ module Effective
|
|
31
32
|
payment: payment,
|
32
33
|
provider: 'moneris_checkout',
|
33
34
|
card: payment['card_type'],
|
34
|
-
purchased_url: moneris_checkout_params[:purchased_url]
|
35
|
-
current_user: current_user
|
35
|
+
purchased_url: moneris_checkout_params[:purchased_url]
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
@@ -13,6 +13,7 @@ module Effective
|
|
13
13
|
raise('paypal provider is not available') unless EffectiveOrders.paypal?
|
14
14
|
|
15
15
|
@order ||= Effective::Order.deep.where(id: (params[:invoice].to_i rescue 0)).first
|
16
|
+
@order.current_user = current_user unless admin_checkout?(paypal_params)
|
16
17
|
|
17
18
|
# We do this even if we're not authorized
|
18
19
|
EffectiveResources.authorized?(self, :update, @order)
|
@@ -21,7 +22,7 @@ module Effective
|
|
21
22
|
if @order.purchased?
|
22
23
|
order_purchased(payment: params, provider: 'paypal', card: params[:payment_type])
|
23
24
|
elsif (params[:payment_status] == 'Completed' && params[:custom] == EffectiveOrders.paypal[:secret])
|
24
|
-
order_purchased(payment: params, provider: 'paypal', card: params[:payment_type]
|
25
|
+
order_purchased(payment: params, provider: 'paypal', card: params[:payment_type])
|
25
26
|
else
|
26
27
|
order_declined(payment: params, provider: 'paypal', card: params[:payment_type])
|
27
28
|
end
|
@@ -30,6 +31,10 @@ module Effective
|
|
30
31
|
head(:ok)
|
31
32
|
end
|
32
33
|
|
34
|
+
def paypal_params
|
35
|
+
{}
|
36
|
+
end
|
37
|
+
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('phone provider is not available') unless EffectiveOrders.phone?
|
8
8
|
|
9
9
|
@order ||= Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(phone_params)
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
raise('pretend provider is not available') unless EffectiveOrders.pretend?
|
8
8
|
|
9
9
|
@order ||= Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(pretend_params)
|
10
11
|
|
11
12
|
EffectiveResources.authorize!(self, :update, @order)
|
12
13
|
|
@@ -22,8 +23,7 @@ module Effective
|
|
22
23
|
payment: 'for pretend',
|
23
24
|
provider: 'pretend',
|
24
25
|
card: 'none',
|
25
|
-
purchased_url: pretend_params[:purchased_url]
|
26
|
-
current_user: (current_user unless admin_checkout?(pretend_params))
|
26
|
+
purchased_url: pretend_params[:purchased_url]
|
27
27
|
)
|
28
28
|
end
|
29
29
|
end
|
@@ -8,6 +8,7 @@ module Effective
|
|
8
8
|
raise('refund provider is not configured for buyer purchase') unless EffectiveOrders.buyer_purchases_refund?
|
9
9
|
|
10
10
|
@order ||= Order.deep.find(params[:id])
|
11
|
+
@order.current_user = current_user unless admin_checkout?(refund_params)
|
11
12
|
|
12
13
|
EffectiveResources.authorize!(self, :update, @order)
|
13
14
|
|
@@ -7,6 +7,8 @@ module Effective
|
|
7
7
|
raise('stripe provider is not available') unless EffectiveOrders.stripe?
|
8
8
|
|
9
9
|
@order = Order.deep.find(params[:id])
|
10
|
+
@order.current_user = current_user unless admin_checkout?(stripe_params)
|
11
|
+
|
10
12
|
@customer = Effective::Customer.for_user(@order.user || current_user)
|
11
13
|
|
12
14
|
EffectiveResources.authorize!(self, :update, @order)
|
@@ -21,7 +23,11 @@ module Effective
|
|
21
23
|
payment = validate_stripe_payment(payment_intent_id)
|
22
24
|
|
23
25
|
if payment.blank?
|
24
|
-
return order_declined(
|
26
|
+
return order_declined(
|
27
|
+
payment: payment,
|
28
|
+
provider: 'stripe',
|
29
|
+
declined_url: stripe_params[:declined_url]
|
30
|
+
)
|
25
31
|
end
|
26
32
|
|
27
33
|
# Update the customer payment fields
|
@@ -33,8 +39,7 @@ module Effective
|
|
33
39
|
payment: payment,
|
34
40
|
provider: 'stripe',
|
35
41
|
card: payment[:card],
|
36
|
-
purchased_url: stripe_params[:purchased_url]
|
37
|
-
current_user: (current_user unless admin_checkout?(stripe_params))
|
42
|
+
purchased_url: stripe_params[:purchased_url]
|
38
43
|
)
|
39
44
|
end
|
40
45
|
|
@@ -37,6 +37,8 @@ module Effective
|
|
37
37
|
# Effective Reports
|
38
38
|
acts_as_reportable if respond_to?(:acts_as_reportable)
|
39
39
|
|
40
|
+
attr_accessor :current_user # Set by the checkout controller for non-admin users
|
41
|
+
|
40
42
|
attr_accessor :terms_and_conditions # Yes, I agree to the terms and conditions
|
41
43
|
attr_accessor :confirmed_checkout # Set on the Checkout Step 1
|
42
44
|
|
@@ -684,12 +686,12 @@ module Effective
|
|
684
686
|
# Call this as a way to skip over non consequential orders
|
685
687
|
# And mark some purchasables purchased
|
686
688
|
# This is different than the Mark as Paid payment processor
|
687
|
-
def mark_as_purchased!
|
688
|
-
purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true
|
689
|
+
def mark_as_purchased!
|
690
|
+
purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true)
|
689
691
|
end
|
690
692
|
|
691
693
|
# Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
|
692
|
-
def purchase!(payment: nil, provider: nil, card: nil, email: true, skip_buyer_validations: false, skip_quickbooks: false
|
694
|
+
def purchase!(payment: nil, provider: nil, card: nil, email: true, skip_buyer_validations: false, skip_quickbooks: false)
|
693
695
|
return true if purchased?
|
694
696
|
|
695
697
|
raise('unable to purchase voided order') if voided?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
= effective_form_with(model: [:admin, order], engine: true) do |f|
|
2
2
|
-# User
|
3
3
|
- klass = (f.object.user || current_user).class
|
4
|
-
- ajax_url = (
|
4
|
+
- ajax_url = (effective_resources.users_effective_ajax_index_path unless Rails.env.test?)
|
5
5
|
|
6
6
|
= f.hidden_field :user_type, value: klass.name
|
7
7
|
= f.select :user_id, klass.all, ajax_url: ajax_url
|
@@ -9,7 +9,7 @@
|
|
9
9
|
-# Organization
|
10
10
|
- if EffectiveOrders.organization_enabled?
|
11
11
|
- klass = (f.object.organization || EffectiveOrders.Organization.new).class
|
12
|
-
- ajax_url = (
|
12
|
+
- ajax_url = (effective_resources.organizations_effective_ajax_index_path unless Rails.env.test?)
|
13
13
|
|
14
14
|
= f.hidden_field :organization_type, value: klass.name
|
15
15
|
= f.select :organization_id, klass.all, ajax_url: ajax_url
|
@@ -37,7 +37,7 @@
|
|
37
37
|
- if EffectiveOrders.stripe?
|
38
38
|
= render partial: '/effective/orders/stripe/form', locals: provider_locals
|
39
39
|
|
40
|
-
- if EffectiveOrders.deferred? &&
|
40
|
+
- if EffectiveOrders.deferred? && !controller_path.include?('admin/') && !local_assigns[:skip_deferred]
|
41
41
|
%p.my-4.text-center - or -
|
42
42
|
= render partial: '/effective/orders/deferred/form', locals: provider_locals
|
43
43
|
|
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: 6.
|
4
|
+
version: 6.16.0
|
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: 2024-
|
11
|
+
date: 2024-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|