effective_orders 6.1.0 → 6.1.2

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: baba1d8301ce1a4cafcd81d4bf87c4c88d99f003e850aae91aff2f23bd17b50e
4
- data.tar.gz: 34f2dd677e1a3a62acc726e6c6210e5645d721bf96df9d9572333bef1039094f
3
+ metadata.gz: 819088f5b5cc1bd4d6965080f951be723aa5f0a10139ba7a724eae767e47b560
4
+ data.tar.gz: a2b5b57a2612d0b810b90e04481ad221c28335b8f0148e71de223180fa36525e
5
5
  SHA512:
6
- metadata.gz: 0bb85d2c07857a4d7c07de089fd85a9b7d6247d0a4bd56aa3f90f88bd3658679f6086bbb7d58acbf2e17850900704d914e299be70f51ae4a5ec5d786ace30ec0
7
- data.tar.gz: e648b6df06efae5b2050fa701130c3a9b00d1ecac7b2c03345a1c04a997d2dc76c2eeb9b48c1046b040b25be3e9c6efe20a72c174426416e184b4144dc7de6dd
6
+ metadata.gz: 31f30605ef8af6b7802264d741c7db94b434bd83ec8d917dbbe3f8e175fc516149806600b3237df2fc533fe486b419075f46a335dc6fdd0a43a993b9625a2ce2
7
+ data.tar.gz: 33652d1539fb9cc7ad2fbf53fa245272ddb6d17e75e3c2830c2292005169656704dbff0845b2cc1a5c14d93fd4492198dd82ec9fa88bf95274465a3ed995a77f
data/README.md CHANGED
@@ -10,13 +10,13 @@ Sends order receipt emails automatically.
10
10
 
11
11
  Has Order History, My Purchases, My Sales and Admin screens.
12
12
 
13
- ## effective_orders 5.0
13
+ ## effective_orders 6.0
14
14
 
15
- This is the 5.0 series of effective_orders.
15
+ This is the 6.0 series of effective_orders.
16
16
 
17
17
  This requires Twitter Bootstrap 4 and Rails 5.1+
18
18
 
19
- Please check out [Effective Orders 3.x](https://github.com/code-and-effect/effective_orders/tree/bootstrap3) for more information using this gem with Bootstrap 3.
19
+ Please check out [Effective Orders 3.x](https://github.com/code-and-effect/effective_orders/tree/bootstrap3) for more information using this gem with Bootstrap 3. Deprecated and not maintained.
20
20
 
21
21
  ## Getting Started
22
22
 
@@ -614,6 +614,8 @@ We are also going to use ngrok to give us a public facing URL
614
614
 
615
615
  Visit https://esqa.moneris.com/mpg/ and login with: demouser / store1 / password
616
616
 
617
+ Or for the prod environment https://www3.moneris.com/mpg
618
+
617
619
  - Select Admin -> Moneris Checkout Config from the menu
618
620
  - Click Create Profile
619
621
 
@@ -665,6 +667,15 @@ config.moneris_checkout = {
665
667
 
666
668
  [Testing a Solution](https://developer.moneris.com/en/More/Testing/Testing%20a%20Solution)
667
669
 
670
+ ### Create a Production Store
671
+
672
+ Visit https://www3.moneris.com/mpg and follow the above instructions
673
+
674
+ The Checkout Id, something like `chktJF76Btore1` is on the configuration page.
675
+
676
+ The Store Id, something like `gwca12345` should match the login information
677
+
678
+ To find the Api Token, click Admin -> Store Settings -> and copy the API key there
668
679
 
669
680
 
670
681
  ## Paying via Moneris (hosted pay page - old)
@@ -50,6 +50,17 @@ module Effective
50
50
  redirect_to declined_url.gsub(':id', @order.to_param.to_s)
51
51
  end
52
52
 
53
+ def order_not_processed(declined_url: nil)
54
+ # No change to the order
55
+
56
+ if flash[:danger].blank?
57
+ flash[:danger] = 'Payment was not processed. Please try again.'
58
+ end
59
+
60
+ declined_url = effective_orders.declined_order_path(':id') if declined_url.blank?
61
+ redirect_to declined_url.gsub(':id', @order.to_param.to_s)
62
+ end
63
+
53
64
  end
54
65
  end
55
66
  end
@@ -11,7 +11,14 @@ module Effective
11
11
 
12
12
  EffectiveResources.authorize!(self, :update, @order)
13
13
 
14
- payment = validate_stripe_payment(stripe_params[:payment_intent_id])
14
+ payment_intent_id = stripe_params[:payment_intent_id]
15
+
16
+ if payment_intent_id.blank?
17
+ flash[:danger] = 'Unable to process stripe order without payment. please try again.'
18
+ return order_not_processed(declined_url: stripe_params[:declined_url])
19
+ end
20
+
21
+ payment = validate_stripe_payment(payment_intent_id)
15
22
 
16
23
  if payment.blank?
17
24
  return order_declined(payment: payment, provider: 'stripe', declined_url: stripe_params[:declined_url])
@@ -37,6 +44,8 @@ module Effective
37
44
  end
38
45
 
39
46
  def validate_stripe_payment(payment_intent_id)
47
+ raise('expected stripe payment intent id to be present') if payment_intent_id.blank?
48
+
40
49
  intent = EffectiveOrders.with_stripe { ::Stripe::PaymentIntent.retrieve(payment_intent_id) }
41
50
  raise('expected stripe intent to be present') if intent.blank?
42
51
  return unless intent.status == 'succeeded'
@@ -59,19 +59,23 @@ module EffectiveStripeHelper
59
59
  def stripe_payment_intent_payload(order, customer)
60
60
  customer.create_stripe_customer! # Only creates if customer not already present
61
61
 
62
+ remember_card = EffectiveOrders.stripe[:remember_card]
63
+ token_required = customer.token_required?
64
+
62
65
  payment = {
63
66
  amount: order.total_with_surcharge,
64
67
  currency: EffectiveOrders.stripe[:currency],
65
68
  customer: customer.stripe_customer_id,
66
- payment_method: customer.payment_method_id.presence,
67
69
  description: stripe_order_description(order),
68
70
  metadata: { order_id: order.id }
69
71
  }
70
72
 
71
- token_required = customer.token_required?
73
+ if remember_card && customer.payment_method_id.present?
74
+ payment[:payment_method] = customer.payment_method_id
75
+ end
72
76
 
73
77
  # Always prompt them for a card unless remember card
74
- token_required = true unless EffectiveOrders.stripe[:remember_card]
78
+ token_required = true unless remember_card
75
79
 
76
80
  intent = begin
77
81
  Rails.logger.info "[STRIPE] create payment intent : #{payment}"
@@ -85,13 +89,18 @@ module EffectiveStripeHelper
85
89
  payload = {
86
90
  key: EffectiveOrders.stripe[:publishable_key],
87
91
  client_secret: intent.client_secret,
88
- payment_method: intent.payment_method,
89
-
90
- active_card: customer.active_card,
91
92
  email: customer.email,
92
93
  token_required: token_required
93
94
  }
94
95
 
96
+ if remember_card && customer.active_card.present? && intent.payment_method.present?
97
+ payload[:active_card] = customer.active_card
98
+ end
99
+
100
+ if intent.payment_method.present?
101
+ payload[:payment_method] = intent.payment_method
102
+ end
103
+
95
104
  payload
96
105
  end
97
106
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.1.0'.freeze
2
+ VERSION = '6.1.2'.freeze
3
3
  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: 6.1.0
4
+ version: 6.1.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-12-07 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails