effective_orders 6.29.0 → 6.29.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2ed83ebfbf108715d418f71ba4e4328f921e7c25bf1089bf14088273423e10a
|
4
|
+
data.tar.gz: 1d425c694ceb2941600bf6645e78375eb094dd9ca243f20c50f5385c6ead6d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 939643e123d27170b05fa68b00d3e5a90f774bbe4ea46ffc38fa76d080e123f315d36360ad947146d993b9a790c1fd3fcd7e7ed987a31ba5e10e7bf1941144f1
|
7
|
+
data.tar.gz: d0ba5224ba9c2e787df3c1197f5e25082418fbdf1037260c09c724530b3ad32cfc5666b21de515bc99714b846d2311771fc23dcec9a5bcd24b6191a16f634f3d
|
@@ -26,10 +26,14 @@ module Effective
|
|
26
26
|
get('/connection-test')
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def get_card_transaction(id)
|
30
30
|
get("/card-transactions/#{id}")
|
31
31
|
end
|
32
32
|
|
33
|
+
def get_ach_transaction(id)
|
34
|
+
get("/ach/transactions/#{id}").try(:dig, 'transaction')
|
35
|
+
end
|
36
|
+
|
33
37
|
# Make the Preload Request
|
34
38
|
# https://devdocs.helcim.com/reference/checkout-init
|
35
39
|
def initialize_request(order)
|
@@ -110,6 +114,7 @@ module Effective
|
|
110
114
|
end
|
111
115
|
|
112
116
|
# Decode the base64 encoded JSON object that was given from the form into a Hash
|
117
|
+
# For a card transaction
|
113
118
|
# {"transactionId"=>"38142732",
|
114
119
|
# "dateCreated"=>"2025-08-15 10:10:32",
|
115
120
|
# "cardBatchId"=>"4656307",
|
@@ -126,9 +131,24 @@ module Effective
|
|
126
131
|
# "customerCode"=>"CST1022",
|
127
132
|
# "invoiceNumber"=>"#30",
|
128
133
|
# "warning"=>""}
|
134
|
+
#
|
135
|
+
# For an ACH transaction
|
136
|
+
# {"transactionId"=>"12345",
|
137
|
+
# "batchId"=>"168333,
|
138
|
+
# "dateCreated"=>"2025-10-10 11:48:47",
|
139
|
+
# "statusAuth"=>"APPROVED",
|
140
|
+
# "statusClearing"=>"OPENED",
|
141
|
+
# "type"=>"WITHDRAWAL",
|
142
|
+
# "amount"=>"1.05",
|
143
|
+
# "currency"=>"CAD",
|
144
|
+
# "approvalCode"=>"1232435435",
|
145
|
+
# "bankAccountNumber"=>"4333434",
|
146
|
+
# "bankToken"=>"3748uzocio7348",
|
147
|
+
# "invoiceNumber"=>"#26-1760118464",
|
148
|
+
# "customerCode"=>"CST0000"}
|
149
|
+
|
129
150
|
def decode_payment_payload(payload)
|
130
151
|
return if payload.blank?
|
131
|
-
|
132
152
|
raise('expected a string') unless payload.kind_of?(String)
|
133
153
|
|
134
154
|
payment = (JSON.parse(Base64.decode64(payload)) rescue nil)
|
@@ -145,7 +165,7 @@ module Effective
|
|
145
165
|
raise('expected a payment Hash') unless payment.kind_of?(Hash)
|
146
166
|
|
147
167
|
return true if (payment['status'] == 'APPROVED' && payment['type'] == 'purchase') # CC
|
148
|
-
return true if (payment['
|
168
|
+
return true if (payment['bankAccountId'].present? && payment['responseMessage'].to_s.downcase == 'approved') # ACH
|
149
169
|
|
150
170
|
false
|
151
171
|
end
|
@@ -157,11 +177,15 @@ module Effective
|
|
157
177
|
transaction_id = payment_payload['transactionId']
|
158
178
|
raise('expected a payment_payload with a transactionId') unless transaction_id.present?
|
159
179
|
|
160
|
-
payment =
|
161
|
-
|
180
|
+
payment = if payment_payload['cardBatchId'].present? && payment_payload['type'].to_s.downcase == 'purchase'
|
181
|
+
get_card_transaction(transaction_id)
|
182
|
+
elsif payment_payload['batchId'].present? && payment_payload['type'].to_s.downcase == 'withdrawal'
|
183
|
+
get_ach_transaction(transaction_id)
|
184
|
+
end
|
185
|
+
|
186
|
+
raise("expected an existing card-transaction or ach-transaction payment with params #{payment_payload}") unless payment.kind_of?(Hash)
|
162
187
|
|
163
|
-
|
164
|
-
if payment['transactionId'].to_s != payment_payload['transactionId'].to_s
|
188
|
+
unless (payment['transactionId'].to_s == payment_payload['transactionId'].to_s) || (payment['id'].to_s == payment_payload['transactionId'].to_s)
|
165
189
|
raise('expected the payment and payment_payload to have the same transactionId')
|
166
190
|
end
|
167
191
|
|
@@ -190,7 +214,7 @@ module Effective
|
|
190
214
|
|
191
215
|
def verify_payment!(order, payment)
|
192
216
|
# Validate order ids
|
193
|
-
|
217
|
+
if payment['invoiceNumber'].present? && !payment['invoiceNumber'].start_with?('#' + order.to_param)
|
194
218
|
raise("expected card-transaction invoiceNumber to be the same as the order to_param")
|
195
219
|
end
|
196
220
|
|
@@ -205,12 +229,12 @@ module Effective
|
|
205
229
|
# Takes a payment_intent and returns the card info we can store
|
206
230
|
def card_info(payment)
|
207
231
|
# Return the authorization params merged with the card info
|
208
|
-
last4 = payment['cardNumber'].to_s.last(4)
|
209
|
-
card = payment['cardType'].to_s.downcase
|
232
|
+
last4 = (payment['cardNumber'] || payment['bankAccountL4L4']).to_s.last(4)
|
210
233
|
|
211
|
-
card =
|
234
|
+
card = payment['cardType'].to_s.downcase
|
235
|
+
card = 'ACH' if card.blank? && payment['bankAccountId'].present?
|
212
236
|
|
213
|
-
active_card = "**** **** **** #{last4} #{card}" if last4.present?
|
237
|
+
active_card = "**** **** **** #{last4} #{card}".strip if last4.present?
|
214
238
|
|
215
239
|
{ 'active_card' => active_card, 'card' => card }.compact
|
216
240
|
end
|
@@ -1046,7 +1046,7 @@ module Effective
|
|
1046
1046
|
when 'm', 'mc', 'master', 'mastercard' then 'MasterCard'
|
1047
1047
|
when 'a', 'ax', 'american', 'americanexpress' then 'American Express'
|
1048
1048
|
when 'd', 'discover' then 'Discover'
|
1049
|
-
when 'ach' then 'ACH
|
1049
|
+
when 'ach' then 'ACH'
|
1050
1050
|
else payment_card.to_s
|
1051
1051
|
end
|
1052
1052
|
|
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.29.
|
4
|
+
version: 6.29.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: 2025-10-
|
11
|
+
date: 2025-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|