activemerchant 1.118.0 → 1.123.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +185 -0
- data/README.md +4 -2
- data/lib/active_merchant/billing/check.rb +19 -12
- data/lib/active_merchant/billing/credit_card.rb +4 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +44 -17
- data/lib/active_merchant/billing/gateways/adyen.rb +36 -19
- data/lib/active_merchant/billing/gateways/authorize_net.rb +19 -11
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +29 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +2 -2
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +52 -8
- data/lib/active_merchant/billing/gateways/cashnet.rb +7 -2
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +31 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +15 -9
- data/lib/active_merchant/billing/gateways/cyber_source.rb +53 -6
- data/lib/active_merchant/billing/gateways/d_local.rb +1 -1
- data/lib/active_merchant/billing/gateways/decidir.rb +15 -3
- data/lib/active_merchant/billing/gateways/elavon.rb +76 -25
- data/lib/active_merchant/billing/gateways/element.rb +2 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +13 -0
- data/lib/active_merchant/billing/gateways/forte.rb +12 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +25 -16
- data/lib/active_merchant/billing/gateways/hps.rb +64 -1
- data/lib/active_merchant/billing/gateways/kushki.rb +23 -0
- data/lib/active_merchant/billing/gateways/litle.rb +4 -4
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +5 -4
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +2 -0
- data/lib/active_merchant/billing/gateways/moka.rb +277 -0
- data/lib/active_merchant/billing/gateways/monei.rb +228 -144
- data/lib/active_merchant/billing/gateways/mundipagg.rb +14 -5
- data/lib/active_merchant/billing/gateways/netbanx.rb +37 -2
- data/lib/active_merchant/billing/gateways/nmi.rb +14 -9
- data/lib/active_merchant/billing/gateways/orbital.rb +127 -64
- data/lib/active_merchant/billing/gateways/pay_arc.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +34 -6
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +9 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +10 -5
- data/lib/active_merchant/billing/gateways/paymentez.rb +5 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +291 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +3 -3
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +23 -9
- data/lib/active_merchant/billing/gateways/redsys.rb +44 -25
- data/lib/active_merchant/billing/gateways/safe_charge.rb +20 -11
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +13 -4
- data/lib/active_merchant/billing/gateways/stripe.rb +8 -8
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +79 -25
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +1 -1
- data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +64 -19
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +1 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/certs/cacert.pem +1582 -2431
- metadata +10 -3
@@ -208,7 +208,7 @@ module ActiveMerchant #:nodoc:
|
|
208
208
|
buyer[:merchantBuyerId] = buyer_hash[:merchant_buyer_id]
|
209
209
|
buyer[:cnpj] = buyer_hash[:cnpj] if @options[:payment_country] == 'BR'
|
210
210
|
buyer[:emailAddress] = buyer_hash[:email]
|
211
|
-
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:
|
211
|
+
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone_number] if options[:shipping_address]) || ''
|
212
212
|
buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
213
213
|
else
|
214
214
|
buyer[:fullName] = payment_method.name.strip
|
@@ -217,7 +217,7 @@ module ActiveMerchant #:nodoc:
|
|
217
217
|
buyer[:merchantBuyerId] = options[:merchant_buyer_id]
|
218
218
|
buyer[:cnpj] = options[:cnpj] if @options[:payment_country] == 'BR'
|
219
219
|
buyer[:emailAddress] = options[:email]
|
220
|
-
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:
|
220
|
+
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone_number] if options[:shipping_address]) || ''
|
221
221
|
buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
222
222
|
end
|
223
223
|
post[:transaction][:order][:buyer] = buyer
|
@@ -233,7 +233,7 @@ module ActiveMerchant #:nodoc:
|
|
233
233
|
shipping_address[:state] = address[:state]
|
234
234
|
shipping_address[:country] = address[:country]
|
235
235
|
shipping_address[:postalCode] = address[:zip]
|
236
|
-
shipping_address[:phone] = address[:
|
236
|
+
shipping_address[:phone] = address[:phone_number]
|
237
237
|
shipping_address
|
238
238
|
end
|
239
239
|
|
@@ -0,0 +1,253 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PaywayDotComGateway < Gateway
|
4
|
+
self.test_url = 'https://devedgilpayway.net/PaywayWS/Payment/CreditCard'
|
5
|
+
self.live_url = 'https://edgilpayway.com/PaywayWS/Payment/CreditCard'
|
6
|
+
|
7
|
+
self.supported_countries = %w[US CA]
|
8
|
+
self.default_currency = 'USD'
|
9
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
10
|
+
|
11
|
+
self.money_format = :cents
|
12
|
+
|
13
|
+
self.homepage_url = 'http://www.payway.com'
|
14
|
+
self.display_name = 'Payway Gateway'
|
15
|
+
|
16
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
17
|
+
'5012' => STANDARD_ERROR_CODE[:card_declined],
|
18
|
+
'5035' => STANDARD_ERROR_CODE[:invalid_number],
|
19
|
+
'5037' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
20
|
+
'5045' => STANDARD_ERROR_CODE[:incorrect_zip]
|
21
|
+
}
|
22
|
+
|
23
|
+
# Payway to standard AVSResult codes.
|
24
|
+
AVS_MAPPING = {
|
25
|
+
'N1' => 'I', # No address given with order
|
26
|
+
'N2' => 'I', # Bill-to address did not pass
|
27
|
+
'““' => 'R', # AVS not performed (Blanks returned)
|
28
|
+
'IU' => 'G', # AVS not performed by Issuer
|
29
|
+
'ID' => 'S', # Issuer does not participate in AVS
|
30
|
+
'IE' => 'E', # Edit Error - AVS data is invalid
|
31
|
+
'IS' => 'R', # System unavailable or time-out
|
32
|
+
'IB' => 'B', # Street address match. Postal code not verified due to incompatible formats (both were sent).
|
33
|
+
'IC' => 'C', # Street address and postal code not verified due to incompatible format (both were sent).
|
34
|
+
'IP' => 'P', # Postal code match. Street address not verified due to incompatible formats (both were sent).
|
35
|
+
'A1' => 'K', # Accountholder name matches
|
36
|
+
'A3' => 'V', # Accountholder name, billing address and postal code.
|
37
|
+
'A4' => 'L', # Accountholder name and billing postal code match
|
38
|
+
'A7' => 'O', # Accountholder name and billing address match
|
39
|
+
'B3' => 'H', # Accountholder name incorrect, billing address and postal code match
|
40
|
+
'B4' => 'F', # Accountholder name incorrect, billing postal code matches
|
41
|
+
'B7' => 'T', # Accountholder name incorrect, billing address matches
|
42
|
+
'B8' => 'N', # Accountholder name, billing address and postal code are all incorrect
|
43
|
+
'??' => 'R', # A double question mark symbol indicates an unrecognized response from association
|
44
|
+
'I1' => 'X', # Zip code +4 and Address Match
|
45
|
+
'I2' => 'W', # Zip code +4 Match
|
46
|
+
'I3' => 'Y', # Zip code and Address Match
|
47
|
+
'I4' => 'Z', # Zip code Match
|
48
|
+
'I5' => 'M', # +4 and Address Match
|
49
|
+
'I6' => 'W', # +4 Match
|
50
|
+
'I7' => 'A', # Address Match
|
51
|
+
'I8' => 'C', # No Match
|
52
|
+
}
|
53
|
+
|
54
|
+
PAYWAY_WS_SUCCESS = '5000'
|
55
|
+
|
56
|
+
SCRUB_PATTERNS = [
|
57
|
+
%r(("password\\?":\\?")[^\\]+),
|
58
|
+
%r(("fsv\\?":\\?")\d+),
|
59
|
+
%r(("fsv\\?": \\?")\d+),
|
60
|
+
%r(("accountNumber\\?":\\?")\d+),
|
61
|
+
%r(("accountNumber\\?": \\?")[^\\]+),
|
62
|
+
%r(("Invalid account number: )\d+)
|
63
|
+
].freeze
|
64
|
+
|
65
|
+
SCRUB_REPLACEMENT = '\1[FILTERED]'
|
66
|
+
|
67
|
+
def initialize(options = {})
|
68
|
+
requires!(options, :login, :password, :company_id, :source_id)
|
69
|
+
super
|
70
|
+
end
|
71
|
+
|
72
|
+
def purchase(money, payment, options = {})
|
73
|
+
post = {}
|
74
|
+
add_common(post, options)
|
75
|
+
add_card_payment(post, payment, options)
|
76
|
+
add_card_transaction_details(post, money, options)
|
77
|
+
add_address(post, payment, options)
|
78
|
+
|
79
|
+
commit('sale', post)
|
80
|
+
end
|
81
|
+
|
82
|
+
def authorize(money, payment, options = {})
|
83
|
+
post = {}
|
84
|
+
add_common(post, options)
|
85
|
+
add_card_payment(post, payment, options)
|
86
|
+
add_card_transaction_details(post, money, options)
|
87
|
+
add_address(post, payment, options)
|
88
|
+
|
89
|
+
commit('authorize', post)
|
90
|
+
end
|
91
|
+
|
92
|
+
def capture(money, authorization, options = {})
|
93
|
+
post = {}
|
94
|
+
add_common(post, options)
|
95
|
+
add_card_transaction_name(post, authorization, options)
|
96
|
+
|
97
|
+
commit('capture', post)
|
98
|
+
end
|
99
|
+
|
100
|
+
def credit(money, payment, options = {})
|
101
|
+
post = {}
|
102
|
+
add_common(post, options)
|
103
|
+
add_card_payment(post, payment, options)
|
104
|
+
add_card_transaction_details(post, money, options)
|
105
|
+
add_address(post, payment, options)
|
106
|
+
|
107
|
+
commit('credit', post)
|
108
|
+
end
|
109
|
+
|
110
|
+
def void(authorization, options = {})
|
111
|
+
post = {}
|
112
|
+
add_common(post, options)
|
113
|
+
add_card_transaction_name(post, authorization, options)
|
114
|
+
|
115
|
+
commit('void', post)
|
116
|
+
end
|
117
|
+
|
118
|
+
def supports_scrubbing?
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
def scrub(transcript)
|
123
|
+
SCRUB_PATTERNS.inject(transcript) do |text, pattern|
|
124
|
+
text.gsub(pattern, SCRUB_REPLACEMENT)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def add_common(post, options)
|
131
|
+
post[:userName] = @options[:login]
|
132
|
+
post[:password] = @options[:password]
|
133
|
+
post[:companyId] = @options[:company_id]
|
134
|
+
post[:cardTransaction] = {}
|
135
|
+
post[:cardTransaction][:sourceId] = @options[:source_id]
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_address(post, payment, options)
|
139
|
+
post[:cardAccount] ||= {}
|
140
|
+
address = options[:billing_address] || options[:address] || {}
|
141
|
+
first_name, last_name = split_names(address[:name])
|
142
|
+
full_address = "#{address[:address1]} #{address[:address2]}".strip
|
143
|
+
phone = address[:phone] || address[:phone_number]
|
144
|
+
|
145
|
+
post[:cardAccount][:firstName] = first_name if first_name
|
146
|
+
post[:cardAccount][:lastName] = last_name if last_name
|
147
|
+
post[:cardAccount][:address] = full_address if full_address
|
148
|
+
post[:cardAccount][:city] = address[:city] if address[:city]
|
149
|
+
post[:cardAccount][:state] = address[:state] if address[:state]
|
150
|
+
post[:cardAccount][:zip] = address[:zip] if address[:zip]
|
151
|
+
post[:cardAccount][:phone] = phone if phone
|
152
|
+
end
|
153
|
+
|
154
|
+
def add_card_transaction_details(post, money, options)
|
155
|
+
post[:cardTransaction][:amount] = amount(money)
|
156
|
+
eci_type = options[:eci_type].nil? ? '1' : options[:eci_type]
|
157
|
+
post[:cardTransaction][:eciType] = eci_type
|
158
|
+
post[:cardTransaction][:processorSoftDescriptor] = options[:processor_soft_descriptor] if options[:processor_soft_descriptor]
|
159
|
+
post[:cardTransaction][:tax] = options[:tax] if options[:tax]
|
160
|
+
end
|
161
|
+
|
162
|
+
def add_card_transaction_name(post, identifier, options)
|
163
|
+
post[:cardTransaction][:name] = identifier
|
164
|
+
end
|
165
|
+
|
166
|
+
def add_card_payment(post, payment, options)
|
167
|
+
# credit_card
|
168
|
+
post[:accountInputMode] = 'primaryAccountNumber'
|
169
|
+
|
170
|
+
post[:cardAccount] ||= {}
|
171
|
+
post[:cardAccount][:accountNumber] = payment.number
|
172
|
+
post[:cardAccount][:fsv] = payment.verification_value
|
173
|
+
post[:cardAccount][:expirationDate] = expdate(payment)
|
174
|
+
post[:cardAccount][:email] = options[:email] if options[:email]
|
175
|
+
end
|
176
|
+
|
177
|
+
def expdate(credit_card)
|
178
|
+
year = format(credit_card.year, :four_digits)
|
179
|
+
month = format(credit_card.month, :two_digits)
|
180
|
+
|
181
|
+
month + year
|
182
|
+
end
|
183
|
+
|
184
|
+
def parse(body)
|
185
|
+
body.blank? ? {} : JSON.parse(body)
|
186
|
+
end
|
187
|
+
|
188
|
+
def commit(action, parameters)
|
189
|
+
parameters[:request] = action
|
190
|
+
|
191
|
+
url = (test? ? test_url : live_url)
|
192
|
+
payload = parameters.to_json unless parameters.nil?
|
193
|
+
|
194
|
+
response =
|
195
|
+
begin
|
196
|
+
parse(ssl_request(:post, url, payload, headers))
|
197
|
+
rescue ResponseError => e
|
198
|
+
return Response.new(false, 'Invalid Login') if e.response.code == '401'
|
199
|
+
|
200
|
+
parse(e.response.body)
|
201
|
+
end
|
202
|
+
|
203
|
+
success = success_from(response)
|
204
|
+
avs_result_code = response['cardTransaction'].nil? || response['cardTransaction']['addressVerificationResults'].nil? ? '' : response['cardTransaction']['addressVerificationResults']
|
205
|
+
avs_result = AVSResult.new(code: AVS_MAPPING[avs_result_code])
|
206
|
+
cvv_result = CVVResult.new(response['cardTransaction']['fraudSecurityResults']) if response['cardTransaction'] && response['cardTransaction']['fraudSecurityResults']
|
207
|
+
|
208
|
+
Response.new(
|
209
|
+
success,
|
210
|
+
message_from(success, response),
|
211
|
+
response,
|
212
|
+
test: test?,
|
213
|
+
error_code: error_code_from(response),
|
214
|
+
authorization: authorization_from(response),
|
215
|
+
avs_result: avs_result,
|
216
|
+
cvv_result: cvv_result
|
217
|
+
)
|
218
|
+
end
|
219
|
+
|
220
|
+
def success_from(response)
|
221
|
+
response['paywayCode'] == PAYWAY_WS_SUCCESS
|
222
|
+
end
|
223
|
+
|
224
|
+
def error_code_from(response)
|
225
|
+
return '' if success_from(response)
|
226
|
+
|
227
|
+
error = !STANDARD_ERROR_CODE_MAPPING[response['paywayCode']].nil? ? STANDARD_ERROR_CODE_MAPPING[response['paywayCode']] : STANDARD_ERROR_CODE[:processing_error]
|
228
|
+
return error
|
229
|
+
end
|
230
|
+
|
231
|
+
def message_from(success, response)
|
232
|
+
return '' if response['paywayCode'].nil?
|
233
|
+
|
234
|
+
return response['paywayCode'] + '-' + 'success' if success
|
235
|
+
|
236
|
+
response['paywayCode'] + '-' + response['paywayMessage']
|
237
|
+
end
|
238
|
+
|
239
|
+
def authorization_from(response)
|
240
|
+
return '' if !success_from(response) || response['cardTransaction'].nil?
|
241
|
+
|
242
|
+
response['cardTransaction']['name']
|
243
|
+
end
|
244
|
+
|
245
|
+
def headers
|
246
|
+
{
|
247
|
+
'Accept' => 'application/json',
|
248
|
+
'Content-type' => 'application/json'
|
249
|
+
}
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
@@ -17,7 +17,7 @@ module ActiveMerchant #:nodoc:
|
|
17
17
|
}
|
18
18
|
|
19
19
|
def initialize(options = {})
|
20
|
-
requires!(options, :username, :password, :merchant, :pem
|
20
|
+
requires!(options, :username, :password, :merchant, :pem)
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
@@ -30,6 +30,7 @@ module ActiveMerchant #:nodoc:
|
|
30
30
|
add_stored_credential_data(post, payment_method, options)
|
31
31
|
add_customer_data(post, options)
|
32
32
|
add_soft_descriptors(post, options)
|
33
|
+
add_customer_reference(post, options)
|
33
34
|
|
34
35
|
commit('capture', post)
|
35
36
|
end
|
@@ -43,6 +44,7 @@ module ActiveMerchant #:nodoc:
|
|
43
44
|
add_stored_credential_data(post, payment_method, options)
|
44
45
|
add_customer_data(post, options)
|
45
46
|
add_soft_descriptors(post, options)
|
47
|
+
add_customer_reference(post, options)
|
46
48
|
|
47
49
|
commit('preauth', post)
|
48
50
|
end
|
@@ -53,6 +55,7 @@ module ActiveMerchant #:nodoc:
|
|
53
55
|
add_reference(post, authorization, options)
|
54
56
|
add_customer_data(post, options)
|
55
57
|
add_soft_descriptors(post, options)
|
58
|
+
add_customer_reference(post, options)
|
56
59
|
|
57
60
|
commit('captureWithoutAuth', post)
|
58
61
|
end
|
@@ -64,6 +67,7 @@ module ActiveMerchant #:nodoc:
|
|
64
67
|
add_customer_data(post, options)
|
65
68
|
add_soft_descriptors(post, options)
|
66
69
|
post['order.ECI'] = options[:eci] || 'SSL'
|
70
|
+
add_customer_reference(post, options)
|
67
71
|
|
68
72
|
commit('refund', post)
|
69
73
|
end
|
@@ -76,6 +80,7 @@ module ActiveMerchant #:nodoc:
|
|
76
80
|
add_payment_method(post, payment_method)
|
77
81
|
add_customer_data(post, options)
|
78
82
|
add_soft_descriptors(post, options)
|
83
|
+
add_customer_reference(post, options)
|
79
84
|
|
80
85
|
commit('refund', post)
|
81
86
|
end
|
@@ -85,6 +90,7 @@ module ActiveMerchant #:nodoc:
|
|
85
90
|
add_reference(post, authorization, options)
|
86
91
|
add_customer_data(post, options)
|
87
92
|
add_soft_descriptors(post, options)
|
93
|
+
add_customer_reference(post, options)
|
88
94
|
|
89
95
|
commit('reversal', post)
|
90
96
|
end
|
@@ -92,7 +98,7 @@ module ActiveMerchant #:nodoc:
|
|
92
98
|
def store(payment_method, options = {})
|
93
99
|
post = {}
|
94
100
|
add_payment_method(post, payment_method)
|
95
|
-
add_card_reference(post)
|
101
|
+
add_card_reference(post, options)
|
96
102
|
|
97
103
|
commit('registerAccount', post)
|
98
104
|
end
|
@@ -149,12 +155,16 @@ module ActiveMerchant #:nodoc:
|
|
149
155
|
return unless payment_method.brand == 'visa'
|
150
156
|
|
151
157
|
stored_credential = options[:stored_credential]
|
152
|
-
if stored_credential[:
|
153
|
-
|
154
|
-
|
158
|
+
if stored_credential[:reason_type] == 'unscheduled'
|
159
|
+
if stored_credential[:initiator] == 'merchant'
|
160
|
+
post['card.storedCredentialUsage'] = 'UNSCHEDULED_MIT'
|
161
|
+
elsif stored_credential[:initiator] == 'customer'
|
162
|
+
post['card.storedCredentialUsage'] = 'UNSCHEDULED_CIT'
|
163
|
+
end
|
164
|
+
elsif stored_credential[:reason_type] == 'recurring'
|
155
165
|
post['card.storedCredentialUsage'] = 'RECURRING'
|
156
|
-
elsif stored_credential[:reason_type] == '
|
157
|
-
post['card.storedCredentialUsage'] = '
|
166
|
+
elsif stored_credential[:reason_type] == 'installment'
|
167
|
+
post['card.storedCredentialUsage'] = 'INSTALLMENT'
|
158
168
|
end
|
159
169
|
end
|
160
170
|
|
@@ -181,8 +191,12 @@ module ActiveMerchant #:nodoc:
|
|
181
191
|
post['card.CVN'] = payment_method.verification_value
|
182
192
|
end
|
183
193
|
|
184
|
-
def add_card_reference(post)
|
185
|
-
post['customer.customerReferenceNumber'] = options[:order_id]
|
194
|
+
def add_card_reference(post, options)
|
195
|
+
post['customer.customerReferenceNumber'] = options[:customer_reference_number] || options[:order_id]
|
196
|
+
end
|
197
|
+
|
198
|
+
def add_customer_reference(post, options)
|
199
|
+
post['customer.customerReferenceNumber'] = options[:customer_reference_number] if options[:customer_reference_number]
|
186
200
|
end
|
187
201
|
|
188
202
|
def add_reference(post, authorization, options)
|
@@ -126,6 +126,7 @@ module ActiveMerchant #:nodoc:
|
|
126
126
|
184 => 'Authentication error',
|
127
127
|
190 => 'Refusal with no specific reason',
|
128
128
|
191 => 'Expiry date incorrect',
|
129
|
+
195 => 'Requires SCA authentication',
|
129
130
|
|
130
131
|
201 => 'Card expired',
|
131
132
|
202 => 'Card blocked temporarily or under suspicion of fraud',
|
@@ -202,11 +203,12 @@ module ActiveMerchant #:nodoc:
|
|
202
203
|
add_order(data, options[:order_id])
|
203
204
|
add_payment(data, payment)
|
204
205
|
add_external_mpi_fields(data, options)
|
205
|
-
|
206
|
+
add_three_ds_data(data, options) if options[:execute_threed]
|
206
207
|
add_stored_credential_options(data, options)
|
207
208
|
data[:description] = options[:description]
|
208
209
|
data[:store_in_vault] = options[:store]
|
209
210
|
data[:sca_exemption] = options[:sca_exemption]
|
211
|
+
data[:sca_exemption_direct_payment_enabled] = options[:sca_exemption_direct_payment_enabled]
|
210
212
|
|
211
213
|
commit data, options
|
212
214
|
end
|
@@ -220,11 +222,12 @@ module ActiveMerchant #:nodoc:
|
|
220
222
|
add_order(data, options[:order_id])
|
221
223
|
add_payment(data, payment)
|
222
224
|
add_external_mpi_fields(data, options)
|
223
|
-
|
225
|
+
add_three_ds_data(data, options) if options[:execute_threed]
|
224
226
|
add_stored_credential_options(data, options)
|
225
227
|
data[:description] = options[:description]
|
226
228
|
data[:store_in_vault] = options[:store]
|
227
229
|
data[:sca_exemption] = options[:sca_exemption]
|
230
|
+
data[:sca_exemption_direct_payment_enabled] = options[:sca_exemption_direct_payment_enabled]
|
228
231
|
|
229
232
|
commit data, options
|
230
233
|
end
|
@@ -309,7 +312,7 @@ module ActiveMerchant #:nodoc:
|
|
309
312
|
test? ? test_url : live_url
|
310
313
|
end
|
311
314
|
|
312
|
-
def
|
315
|
+
def webservice_url
|
313
316
|
test? ? 'https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2' : 'https://sis.redsys.es/sis/services/SerClsWSEntradaV2'
|
314
317
|
end
|
315
318
|
|
@@ -369,42 +372,51 @@ module ActiveMerchant #:nodoc:
|
|
369
372
|
end
|
370
373
|
end
|
371
374
|
|
372
|
-
def
|
373
|
-
data[:
|
375
|
+
def add_three_ds_data(data, options)
|
376
|
+
data[:three_ds_data] = { threeDSInfo: 'CardData' } if options[:execute_threed] == true
|
374
377
|
end
|
375
378
|
|
376
|
-
def
|
377
|
-
|
378
|
-
return '
|
379
|
-
|
379
|
+
def determine_peticion_type(data)
|
380
|
+
three_ds_info = data.dig(:three_ds_data, :threeDSInfo)
|
381
|
+
return 'iniciaPeticion' if three_ds_info == 'CardData'
|
382
|
+
return 'trataPeticion' if three_ds_info == 'AuthenticationData' ||
|
383
|
+
three_ds_info == 'ChallengeResponse' ||
|
384
|
+
data[:sca_exemption] == 'MIT'
|
385
|
+
end
|
386
|
+
|
387
|
+
def use_webservice_endpoint?(data, options)
|
388
|
+
options[:use_webservice_endpoint].to_s == 'true' || data[:three_ds_data] || data[:sca_exemption] == 'MIT'
|
380
389
|
end
|
381
390
|
|
382
391
|
def commit(data, options = {})
|
383
|
-
|
384
|
-
|
392
|
+
xmlreq = xml_request_from(data, options)
|
393
|
+
|
394
|
+
if use_webservice_endpoint?(data, options)
|
395
|
+
peticion_type = determine_peticion_type(data)
|
396
|
+
|
385
397
|
request = <<-REQUEST
|
386
398
|
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.sis.sermepa.es" xmlns:intf="http://webservice.sis.sermepa.es" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
|
387
399
|
<soapenv:Header/>
|
388
400
|
<soapenv:Body>
|
389
|
-
<intf:#{
|
401
|
+
<intf:#{peticion_type} xmlns:intf="http://webservice.sis.sermepa.es">
|
390
402
|
<intf:datoEntrada>
|
391
|
-
<![CDATA[#{
|
403
|
+
<![CDATA[#{xmlreq}]]>
|
392
404
|
</intf:datoEntrada>
|
393
|
-
</intf:#{
|
405
|
+
</intf:#{peticion_type}>
|
394
406
|
</soapenv:Body>
|
395
407
|
</soapenv:Envelope>
|
396
408
|
REQUEST
|
397
|
-
parse(ssl_post(
|
409
|
+
parse(ssl_post(webservice_url, request, headers(peticion_type)), peticion_type)
|
398
410
|
else
|
399
|
-
parse(ssl_post(url, "entrada=#{CGI.escape(
|
411
|
+
parse(ssl_post(url, "entrada=#{CGI.escape(xmlreq)}", headers), peticion_type)
|
400
412
|
end
|
401
413
|
end
|
402
414
|
|
403
|
-
def headers(
|
404
|
-
if
|
415
|
+
def headers(peticion_type = nil)
|
416
|
+
if peticion_type
|
405
417
|
{
|
406
418
|
'Content-Type' => 'text/xml',
|
407
|
-
'SOAPAction' =>
|
419
|
+
'SOAPAction' => peticion_type
|
408
420
|
}
|
409
421
|
else
|
410
422
|
{
|
@@ -468,7 +480,7 @@ module ActiveMerchant #:nodoc:
|
|
468
480
|
|
469
481
|
def build_merchant_data(xml, data, options = {})
|
470
482
|
# See https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2/wsdl/SerClsWSEntradaV2.wsdl
|
471
|
-
# (which results from calling #
|
483
|
+
# (which results from calling #webservice_url + '?WSDL', https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2?WSDL)
|
472
484
|
xml.DATOSENTRADA do
|
473
485
|
# Basic elements
|
474
486
|
xml.DS_Version 0.1
|
@@ -476,7 +488,7 @@ module ActiveMerchant #:nodoc:
|
|
476
488
|
xml.DS_MERCHANT_AMOUNT data[:amount]
|
477
489
|
xml.DS_MERCHANT_ORDER data[:order_id]
|
478
490
|
xml.DS_MERCHANT_TRANSACTIONTYPE data[:action]
|
479
|
-
if data[:description] && data
|
491
|
+
if data[:description] && use_webservice_endpoint?(data, options)
|
480
492
|
xml.DS_MERCHANT_PRODUCTDESCRIPTION CGI.escape(data[:description])
|
481
493
|
else
|
482
494
|
xml.DS_MERCHANT_PRODUCTDESCRIPTION data[:description]
|
@@ -484,11 +496,18 @@ module ActiveMerchant #:nodoc:
|
|
484
496
|
xml.DS_MERCHANT_TERMINAL options[:terminal] || @options[:terminal]
|
485
497
|
xml.DS_MERCHANT_MERCHANTCODE @options[:login]
|
486
498
|
xml.DS_MERCHANT_MERCHANTSIGNATURE build_signature(data) unless sha256_authentication?
|
487
|
-
|
499
|
+
|
500
|
+
peticion_type = determine_peticion_type(data) if data[:three_ds_data]
|
501
|
+
if peticion_type == 'iniciaPeticion' && data[:sca_exemption]
|
502
|
+
xml.DS_MERCHANT_EXCEP_SCA 'Y'
|
503
|
+
else
|
504
|
+
xml.DS_MERCHANT_EXCEP_SCA data[:sca_exemption] if data[:sca_exemption]
|
505
|
+
xml.DS_MERCHANT_DIRECTPAYMENT data[:sca_exemption_direct_payment_enabled] || 'true' if data[:sca_exemption] == 'MIT'
|
506
|
+
end
|
488
507
|
|
489
508
|
# Only when card is present
|
490
509
|
if data[:card]
|
491
|
-
if data[:card][:name] && data
|
510
|
+
if data[:card][:name] && use_webservice_endpoint?(data, options)
|
492
511
|
xml.DS_MERCHANT_TITULAR CGI.escape(data[:card][:name])
|
493
512
|
else
|
494
513
|
xml.DS_MERCHANT_TITULAR data[:card][:name]
|
@@ -509,7 +528,7 @@ module ActiveMerchant #:nodoc:
|
|
509
528
|
# Requires account configuration to be able to use
|
510
529
|
xml.DS_MERCHANT_DIRECTPAYMENT 'moto' if options.dig(:moto) && options.dig(:metadata, :manual_entry)
|
511
530
|
|
512
|
-
xml.DS_MERCHANT_EMV3DS data[:
|
531
|
+
xml.DS_MERCHANT_EMV3DS data[:three_ds_data].to_json if data[:three_ds_data]
|
513
532
|
|
514
533
|
if options[:stored_credential]
|
515
534
|
xml.DS_MERCHANT_COF_INI data[:DS_MERCHANT_COF_INI]
|
@@ -622,7 +641,7 @@ module ActiveMerchant #:nodoc:
|
|
622
641
|
def response_text(code)
|
623
642
|
code = code.to_i
|
624
643
|
code = 0 if code < 100
|
625
|
-
RESPONSE_TEXTS[code] || '
|
644
|
+
RESPONSE_TEXTS[code] || 'Unknown code, please check in manual'
|
626
645
|
end
|
627
646
|
|
628
647
|
def response_text_3ds(xml, params)
|