activemerchant 1.105.0 → 1.107.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +99 -1
  3. data/README.md +2 -2
  4. data/lib/active_merchant/billing/credit_card_methods.rb +12 -3
  5. data/lib/active_merchant/billing/gateway.rb +22 -22
  6. data/lib/active_merchant/billing/gateways/adyen.rb +18 -7
  7. data/lib/active_merchant/billing/gateways/allied_wallet.rb +2 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +19 -19
  9. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +11 -11
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +35 -35
  11. data/lib/active_merchant/billing/gateways/axcessms.rb +3 -3
  12. data/lib/active_merchant/billing/gateways/bambora_apac.rb +1 -1
  13. data/lib/active_merchant/billing/gateways/bank_frick.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/banwire.rb +2 -2
  15. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
  16. data/lib/active_merchant/billing/gateways/be2bill.rb +4 -4
  17. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +27 -27
  19. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/blue_pay.rb +8 -8
  21. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -2
  22. data/lib/active_merchant/billing/gateways/bogus.rb +20 -20
  23. data/lib/active_merchant/billing/gateways/borgun.rb +17 -6
  24. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  25. data/lib/active_merchant/billing/gateways/braintree_blue.rb +81 -77
  26. data/lib/active_merchant/billing/gateways/bridge_pay.rb +3 -3
  27. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  28. data/lib/active_merchant/billing/gateways/card_stream.rb +19 -19
  29. data/lib/active_merchant/billing/gateways/cc5.rb +7 -7
  30. data/lib/active_merchant/billing/gateways/cecabank.rb +3 -3
  31. data/lib/active_merchant/billing/gateways/cenpos.rb +3 -3
  32. data/lib/active_merchant/billing/gateways/checkout_v2.rb +20 -9
  33. data/lib/active_merchant/billing/gateways/clearhaus.rb +1 -1
  34. data/lib/active_merchant/billing/gateways/commercegate.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/conekta.rb +1 -1
  36. data/lib/active_merchant/billing/gateways/creditcall.rb +4 -4
  37. data/lib/active_merchant/billing/gateways/ct_payment.rb +1 -1
  38. data/lib/active_merchant/billing/gateways/culqi.rb +2 -2
  39. data/lib/active_merchant/billing/gateways/cyber_source.rb +154 -91
  40. data/lib/active_merchant/billing/gateways/d_local.rb +4 -2
  41. data/lib/active_merchant/billing/gateways/data_cash.rb +33 -33
  42. data/lib/active_merchant/billing/gateways/decidir.rb +7 -2
  43. data/lib/active_merchant/billing/gateways/ebanx.rb +14 -2
  44. data/lib/active_merchant/billing/gateways/efsnet.rb +23 -23
  45. data/lib/active_merchant/billing/gateways/elavon.rb +70 -18
  46. data/lib/active_merchant/billing/gateways/element.rb +12 -4
  47. data/lib/active_merchant/billing/gateways/epay.rb +40 -40
  48. data/lib/active_merchant/billing/gateways/evo_ca.rb +11 -11
  49. data/lib/active_merchant/billing/gateways/eway.rb +3 -3
  50. data/lib/active_merchant/billing/gateways/eway_managed.rb +40 -40
  51. data/lib/active_merchant/billing/gateways/eway_rapid.rb +7 -7
  52. data/lib/active_merchant/billing/gateways/exact.rb +11 -11
  53. data/lib/active_merchant/billing/gateways/fat_zebra.rb +3 -2
  54. data/lib/active_merchant/billing/gateways/federated_canada.rb +5 -5
  55. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +21 -21
  56. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +20 -20
  57. data/lib/active_merchant/billing/gateways/flo2cash.rb +4 -4
  58. data/lib/active_merchant/billing/gateways/forte.rb +8 -7
  59. data/lib/active_merchant/billing/gateways/garanti.rb +8 -8
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +30 -24
  61. data/lib/active_merchant/billing/gateways/hdfc.rb +3 -3
  62. data/lib/active_merchant/billing/gateways/hps.rb +5 -3
  63. data/lib/active_merchant/billing/gateways/iats_payments.rb +32 -15
  64. data/lib/active_merchant/billing/gateways/inspire.rb +7 -7
  65. data/lib/active_merchant/billing/gateways/instapay.rb +3 -3
  66. data/lib/active_merchant/billing/gateways/ipp.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/iridium.rb +12 -10
  68. data/lib/active_merchant/billing/gateways/itransact.rb +7 -7
  69. data/lib/active_merchant/billing/gateways/iveri.rb +6 -3
  70. data/lib/active_merchant/billing/gateways/ixopay.rb +22 -0
  71. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -4
  72. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +5 -5
  73. data/lib/active_merchant/billing/gateways/kushki.rb +34 -5
  74. data/lib/active_merchant/billing/gateways/latitude19.rb +2 -2
  75. data/lib/active_merchant/billing/gateways/linkpoint.rb +62 -62
  76. data/lib/active_merchant/billing/gateways/litle.rb +8 -3
  77. data/lib/active_merchant/billing/gateways/mastercard.rb +2 -2
  78. data/lib/active_merchant/billing/gateways/mercado_pago.rb +1 -0
  79. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +5 -5
  80. data/lib/active_merchant/billing/gateways/merchant_one.rb +2 -2
  81. data/lib/active_merchant/billing/gateways/merchant_partners.rb +4 -4
  82. data/lib/active_merchant/billing/gateways/merchant_ware.rb +12 -12
  83. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -11
  84. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +12 -2
  85. data/lib/active_merchant/billing/gateways/mercury.rb +9 -9
  86. data/lib/active_merchant/billing/gateways/metrics_global.rb +15 -15
  87. data/lib/active_merchant/billing/gateways/migs.rb +13 -13
  88. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +7 -7
  89. data/lib/active_merchant/billing/gateways/monei.rb +19 -19
  90. data/lib/active_merchant/billing/gateways/moneris.rb +10 -10
  91. data/lib/active_merchant/billing/gateways/money_movers.rb +5 -5
  92. data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
  93. data/lib/active_merchant/billing/gateways/nab_transact.rb +15 -15
  94. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +1 -1
  95. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -6
  96. data/lib/active_merchant/billing/gateways/netaxept.rb +4 -4
  97. data/lib/active_merchant/billing/gateways/netbanx.rb +14 -14
  98. data/lib/active_merchant/billing/gateways/netbilling.rb +12 -12
  99. data/lib/active_merchant/billing/gateways/netpay.rb +2 -2
  100. data/lib/active_merchant/billing/gateways/network_merchants.rb +5 -5
  101. data/lib/active_merchant/billing/gateways/ogone.rb +7 -7
  102. data/lib/active_merchant/billing/gateways/openpay.rb +2 -2
  103. data/lib/active_merchant/billing/gateways/opp.rb +13 -7
  104. data/lib/active_merchant/billing/gateways/optimal_payment.rb +13 -9
  105. data/lib/active_merchant/billing/gateways/orbital.rb +54 -12
  106. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -7
  107. data/lib/active_merchant/billing/gateways/pay_conex.rb +2 -2
  108. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +16 -16
  109. data/lib/active_merchant/billing/gateways/pay_junction.rb +16 -16
  110. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +18 -2
  111. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -6
  112. data/lib/active_merchant/billing/gateways/paybox_direct.rb +36 -36
  113. data/lib/active_merchant/billing/gateways/payflow.rb +7 -7
  114. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +12 -12
  115. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
  116. data/lib/active_merchant/billing/gateways/payment_express.rb +9 -9
  117. data/lib/active_merchant/billing/gateways/paymill.rb +3 -3
  118. data/lib/active_merchant/billing/gateways/paypal.rb +1 -1
  119. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +5 -5
  120. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  121. data/lib/active_merchant/billing/gateways/payscout.rb +5 -5
  122. data/lib/active_merchant/billing/gateways/paystation.rb +2 -2
  123. data/lib/active_merchant/billing/gateways/payu_latam.rb +3 -3
  124. data/lib/active_merchant/billing/gateways/payway.rb +12 -12
  125. data/lib/active_merchant/billing/gateways/pin.rb +16 -16
  126. data/lib/active_merchant/billing/gateways/plugnpay.rb +10 -10
  127. data/lib/active_merchant/billing/gateways/psigate.rb +26 -26
  128. data/lib/active_merchant/billing/gateways/psl_card.rb +4 -4
  129. data/lib/active_merchant/billing/gateways/qbms.rb +23 -23
  130. data/lib/active_merchant/billing/gateways/quantum.rb +4 -4
  131. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +95 -95
  132. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +9 -9
  133. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +2 -2
  134. data/lib/active_merchant/billing/gateways/qvalent.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/realex.rb +17 -10
  136. data/lib/active_merchant/billing/gateways/redsys.rb +24 -16
  137. data/lib/active_merchant/billing/gateways/safe_charge.rb +1 -1
  138. data/lib/active_merchant/billing/gateways/sage.rb +10 -10
  139. data/lib/active_merchant/billing/gateways/sage_pay.rb +35 -35
  140. data/lib/active_merchant/billing/gateways/sallie_mae.rb +2 -2
  141. data/lib/active_merchant/billing/gateways/secure_net.rb +9 -9
  142. data/lib/active_merchant/billing/gateways/secure_pay.rb +13 -13
  143. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +16 -16
  144. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +2 -2
  145. data/lib/active_merchant/billing/gateways/skip_jack.rb +8 -8
  146. data/lib/active_merchant/billing/gateways/smart_ps.rb +16 -16
  147. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +6 -6
  148. data/lib/active_merchant/billing/gateways/spreedly_core.rb +4 -4
  149. data/lib/active_merchant/billing/gateways/stripe.rb +15 -10
  150. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +50 -9
  151. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +2 -2
  152. data/lib/active_merchant/billing/gateways/trans_first.rb +4 -4
  153. data/lib/active_merchant/billing/gateways/trust_commerce.rb +19 -19
  154. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +110 -110
  155. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +29 -29
  156. data/lib/active_merchant/billing/gateways/verifi.rb +10 -10
  157. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -6
  158. data/lib/active_merchant/billing/gateways/visanet_peru.rb +6 -6
  159. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  160. data/lib/active_merchant/billing/gateways/wirecard.rb +6 -6
  161. data/lib/active_merchant/billing/gateways/worldpay.rb +22 -20
  162. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +32 -32
  163. data/lib/active_merchant/billing/gateways/worldpay_us.rb +2 -2
  164. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  165. data/lib/active_merchant/connection.rb +1 -1
  166. data/lib/active_merchant/network_connection_retries.rb +3 -3
  167. data/lib/active_merchant/post_data.rb +1 -1
  168. data/lib/active_merchant/version.rb +1 -1
  169. data/lib/certs/cacert.pem +75 -0
  170. data/lib/support/ssl_verify.rb +2 -2
  171. data/lib/support/ssl_version.rb +2 -2
  172. metadata +4 -4
  173. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -173,9 +173,9 @@ module ActiveMerchant #:nodoc:
173
173
  response[:success],
174
174
  message_from(response),
175
175
  response,
176
- :test => test?,
177
- :authorization => build_authorization(response),
178
- :error_code => response[:error_code]
176
+ test: test?,
177
+ authorization: build_authorization(response),
178
+ error_code: response[:error_code]
179
179
  )
180
180
  end
181
181
 
@@ -181,13 +181,13 @@ module ActiveMerchant #:nodoc:
181
181
  def headers
182
182
  {
183
183
  'Accept-Encoding' => 'identity',
184
- 'Content-Type' => 'text/xml;charset=UTF-8',
185
- 'SOAPAction' => 'http://tempuri.org/Transactional/ProcessCreditCard'
184
+ 'Content-Type' => 'text/xml;charset=UTF-8',
185
+ 'SOAPAction' => 'http://tempuri.org/Transactional/ProcessCreditCard'
186
186
  }
187
187
  end
188
188
 
189
189
  def build_request(post)
190
- xml = Builder::XmlMarkup.new :indent => 8
190
+ xml = Builder::XmlMarkup.new indent: 8
191
191
  xml.tag!('acr:MerchantId', post.delete(:MerchantId))
192
192
  xml.tag!('acr:Password', post.delete(:Password))
193
193
  xml.tag!('acr:UserId', post.delete(:UserId))
@@ -102,13 +102,21 @@ module ActiveMerchant #:nodoc:
102
102
 
103
103
  def add_payment_method(post, payment_method, options)
104
104
  post[:source] = {}
105
- post[:source][:type] = 'card'
106
- post[:source][:name] = payment_method.name
107
- post[:source][:number] = payment_method.number
108
- post[:source][:cvv] = payment_method.verification_value
105
+ if payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :network_token
106
+ post[:source][:type] = 'network_token'
107
+ post[:source][:token] = payment_method.number
108
+ post[:source][:token_type] = payment_method.brand == 'visa' ? 'vts' : 'mdes'
109
+ post[:source][:cryptogram] = payment_method.payment_cryptogram
110
+ post[:source][:eci] = options[:eci] || '05'
111
+ else
112
+ post[:source][:type] = 'card'
113
+ post[:source][:name] = payment_method.name
114
+ post[:source][:number] = payment_method.number
115
+ post[:source][:cvv] = payment_method.verification_value
116
+ post[:source][:stored] = 'true' if options[:card_on_file] == true
117
+ end
109
118
  post[:source][:expiry_year] = format(payment_method.year, :four_digits)
110
119
  post[:source][:expiry_month] = format(payment_method.month, :two_digits)
111
- post[:source][:stored] = 'true' if options[:card_on_file] == true
112
120
  end
113
121
 
114
122
  def add_customer_data(post, options)
@@ -158,7 +166,7 @@ module ActiveMerchant #:nodoc:
158
166
  rescue ResponseError => e
159
167
  raise unless e.response.code.to_s =~ /4\d\d/
160
168
 
161
- response = parse(e.response.body)
169
+ response = parse(e.response.body, error: e.response)
162
170
  end
163
171
 
164
172
  succeeded = success_from(response)
@@ -216,13 +224,16 @@ module ActiveMerchant #:nodoc:
216
224
  response['source'] && response['source']['cvv_check'] ? CVVResult.new(response['source']['cvv_check']) : nil
217
225
  end
218
226
 
219
- def parse(body)
227
+ def parse(body, error: nil)
220
228
  JSON.parse(body)
221
229
  rescue JSON::ParserError
222
- {
230
+ response = {
231
+ 'error_type' => error&.code,
223
232
  'message' => 'Invalid JSON response received from Checkout.com Unified Payments Gateway. Please contact Checkout.com if you continue to receive this message.',
224
233
  'raw_response' => scrub(body)
225
234
  }
235
+ response['error_codes'] = [error&.message] if error&.message
236
+ response
226
237
  end
227
238
 
228
239
  def success_from(response)
@@ -235,7 +246,7 @@ module ActiveMerchant #:nodoc:
235
246
  elsif response['error_type']
236
247
  response['error_type'] + ': ' + response['error_codes'].first
237
248
  else
238
- response['response_summary'] || response['response_code'] || 'Unable to read error message'
249
+ response['response_summary'] || response['response_code'] || response['status'] || response['message'] || 'Unable to read error message'
239
250
  end
240
251
  end
241
252
 
@@ -128,7 +128,7 @@ module ActiveMerchant #:nodoc:
128
128
  def add_payment(post, payment)
129
129
  card = {}
130
130
  card[:pan] = payment.number
131
- card[:expire_month] = '%02d'% payment.month
131
+ card[:expire_month] = '%02d' % payment.month
132
132
  card[:expire_year] = payment.year
133
133
 
134
134
  card[:csc] = payment.verification_value if payment.verification_value?
@@ -74,8 +74,8 @@ module ActiveMerchant #:nodoc:
74
74
  post[:customerIP] = options[:ip] || '127.0.0.1'
75
75
  post[:amount] = amount(money)
76
76
  post[:email] = options[:email] || 'unknown@example.com'
77
- post[:currencyCode]= options[:currency] || currency(money)
78
- post[:merchAcct] = options[:merchant]
77
+ post[:currencyCode] = options[:currency] || currency(money)
78
+ post[:merchAcct] = options[:merchant]
79
79
  end
80
80
 
81
81
  def add_creditcard(params, creditcard)
@@ -180,7 +180,7 @@ module ActiveMerchant #:nodoc:
180
180
  'Accept-Language' => 'es',
181
181
  'Authorization' => 'Basic ' + Base64.encode64("#{@options[:key]}:"),
182
182
  'RaiseHtmlError' => 'false',
183
- 'Conekta-Client-User-Agent' => {'agent'=>"Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json,
183
+ 'Conekta-Client-User-Agent' => {'agent' => "Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json,
184
184
  'X-Conekta-Client-User-Agent' => conekta_client_user_agent(options),
185
185
  'X-Conekta-Client-User-Metadata' => options[:meta].to_json
186
186
  }
@@ -24,19 +24,19 @@ module ActiveMerchant #:nodoc:
24
24
 
25
25
  AVS_CODE = {
26
26
  'matched;matched' => 'D',
27
- 'matched;notchecked' =>'B',
27
+ 'matched;notchecked' => 'B',
28
28
  'matched;notmatched' => 'A',
29
29
  'matched;partialmatch' => 'A',
30
30
  'notchecked;matched' => 'P',
31
- 'notchecked;notchecked' =>'I',
31
+ 'notchecked;notchecked' => 'I',
32
32
  'notchecked;notmatched' => 'I',
33
33
  'notchecked;partialmatch' => 'I',
34
34
  'notmatched;matched' => 'W',
35
- 'notmatched;notchecked' =>'C',
35
+ 'notmatched;notchecked' => 'C',
36
36
  'notmatched;notmatched' => 'C',
37
37
  'notmatched;partialmatch' => 'C',
38
38
  'partialmatched;matched' => 'W',
39
- 'partialmatched;notchecked' =>'C',
39
+ 'partialmatched;notchecked' => 'C',
40
40
  'partialmatched;notmatched' => 'C',
41
41
  'partialmatched;partialmatch' => 'C'
42
42
  }
@@ -227,7 +227,7 @@ module ActiveMerchant #:nodoc:
227
227
  r.process { commit_raw(action, parameters) }
228
228
  r.process {
229
229
  split_auth = split_authorization(r.authorization)
230
- auth = (action.include?('recur')? split_auth[4] : split_auth[0])
230
+ auth = (action.include?('recur') ? split_auth[4] : split_auth[0])
231
231
  action.include?('recur') ? commit_raw('recur/ack', {ID: auth}) : commit_raw('ack', {TransactionNumber: auth})
232
232
  }
233
233
  end
@@ -231,8 +231,8 @@ module ActiveMerchant #:nodoc:
231
231
 
232
232
  def headers
233
233
  {
234
- 'Accept' => 'application/json',
235
- 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
234
+ 'Accept' => 'application/json',
235
+ 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
236
236
  }
237
237
  end
238
238
 
@@ -25,8 +25,16 @@ module ActiveMerchant #:nodoc:
25
25
  self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
26
26
 
27
27
  # Schema files can be found here: https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/
28
- TEST_XSD_VERSION = '1.159'
29
- PRODUCTION_XSD_VERSION = '1.159'
28
+ TEST_XSD_VERSION = '1.164'
29
+ PRODUCTION_XSD_VERSION = '1.164'
30
+ ECI_BRAND_MAPPING = {
31
+ visa: 'vbv',
32
+ master: 'spa',
33
+ american_express: 'aesk',
34
+ jcb: 'js',
35
+ discover: 'pb',
36
+ }.freeze
37
+ DEFAULT_COLLECTION_INDICATOR = 2
30
38
 
31
39
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro, :elo]
32
40
  self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB PK)
@@ -38,56 +46,61 @@ module ActiveMerchant #:nodoc:
38
46
  self.display_name = 'CyberSource'
39
47
 
40
48
  @@credit_card_codes = {
41
- :visa => '001',
42
- :master => '002',
43
- :american_express => '003',
44
- :discover => '004',
45
- :diners_club => '005',
46
- :jcb => '007',
47
- :dankort => '034',
48
- :maestro => '042',
49
- :elo => '054'
49
+ visa: '001',
50
+ master: '002',
51
+ american_express: '003',
52
+ discover: '004',
53
+ diners_club: '005',
54
+ jcb: '007',
55
+ dankort: '034',
56
+ maestro: '042',
57
+ elo: '054'
58
+ }
59
+
60
+ @@decision_codes = {
61
+ accept: 'ACCEPT',
62
+ review: 'REVIEW'
50
63
  }
51
64
 
52
65
  @@response_codes = {
53
- :r100 => 'Successful transaction',
54
- :r101 => 'Request is missing one or more required fields',
55
- :r102 => 'One or more fields contains invalid data',
56
- :r150 => 'General failure',
57
- :r151 => 'The request was received but a server time-out occurred',
58
- :r152 => 'The request was received, but a service timed out',
59
- :r200 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check',
60
- :r201 => 'The issuing bank has questions about the request',
61
- :r202 => 'Expired card',
62
- :r203 => 'General decline of the card',
63
- :r204 => 'Insufficient funds in the account',
64
- :r205 => 'Stolen or lost card',
65
- :r207 => 'Issuing bank unavailable',
66
- :r208 => 'Inactive card or card not authorized for card-not-present transactions',
67
- :r209 => 'American Express Card Identifiction Digits (CID) did not match',
68
- :r210 => 'The card has reached the credit limit',
69
- :r211 => 'Invalid card verification number',
70
- :r221 => "The customer matched an entry on the processor's negative file",
71
- :r230 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check',
72
- :r231 => 'Invalid account number',
73
- :r232 => 'The card type is not accepted by the payment processor',
74
- :r233 => 'General decline by the processor',
75
- :r234 => 'A problem exists with your CyberSource merchant configuration',
76
- :r235 => 'The requested amount exceeds the originally authorized amount',
77
- :r236 => 'Processor failure',
78
- :r237 => 'The authorization has already been reversed',
79
- :r238 => 'The authorization has already been captured',
80
- :r239 => 'The requested transaction amount must match the previous transaction amount',
81
- :r240 => 'The card type sent is invalid or does not correlate with the credit card number',
82
- :r241 => 'The request ID is invalid',
83
- :r242 => 'You requested a capture, but there is no corresponding, unused authorization record.',
84
- :r243 => 'The transaction has already been settled or reversed',
85
- :r244 => 'The bank account number failed the validation check',
86
- :r246 => 'The capture or credit is not voidable because the capture or credit information has already been submitted to your processor',
87
- :r247 => 'You requested a credit for a capture that was previously voided',
88
- :r250 => 'The request was received, but a time-out occurred with the payment processor',
89
- :r254 => 'Your CyberSource account is prohibited from processing stand-alone refunds',
90
- :r255 => 'Your CyberSource account is not configured to process the service in the country you specified'
66
+ r100: 'Successful transaction',
67
+ r101: 'Request is missing one or more required fields',
68
+ r102: 'One or more fields contains invalid data',
69
+ r150: 'General failure',
70
+ r151: 'The request was received but a server time-out occurred',
71
+ r152: 'The request was received, but a service timed out',
72
+ r200: 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check',
73
+ r201: 'The issuing bank has questions about the request',
74
+ r202: 'Expired card',
75
+ r203: 'General decline of the card',
76
+ r204: 'Insufficient funds in the account',
77
+ r205: 'Stolen or lost card',
78
+ r207: 'Issuing bank unavailable',
79
+ r208: 'Inactive card or card not authorized for card-not-present transactions',
80
+ r209: 'American Express Card Identifiction Digits (CID) did not match',
81
+ r210: 'The card has reached the credit limit',
82
+ r211: 'Invalid card verification number',
83
+ r221: "The customer matched an entry on the processor's negative file",
84
+ r230: 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check',
85
+ r231: 'Invalid account number',
86
+ r232: 'The card type is not accepted by the payment processor',
87
+ r233: 'General decline by the processor',
88
+ r234: 'A problem exists with your CyberSource merchant configuration',
89
+ r235: 'The requested amount exceeds the originally authorized amount',
90
+ r236: 'Processor failure',
91
+ r237: 'The authorization has already been reversed',
92
+ r238: 'The authorization has already been captured',
93
+ r239: 'The requested transaction amount must match the previous transaction amount',
94
+ r240: 'The card type sent is invalid or does not correlate with the credit card number',
95
+ r241: 'The request ID is invalid',
96
+ r242: 'You requested a capture, but there is no corresponding, unused authorization record.',
97
+ r243: 'The transaction has already been settled or reversed',
98
+ r244: 'The bank account number failed the validation check',
99
+ r246: 'The capture or credit is not voidable because the capture or credit information has already been submitted to your processor',
100
+ r247: 'You requested a credit for a capture that was previously voided',
101
+ r250: 'The request was received, but a time-out occurred with the payment processor',
102
+ r254: 'Your CyberSource account is prohibited from processing stand-alone refunds',
103
+ r255: 'Your CyberSource account is not configured to process the service in the country you specified'
91
104
  }
92
105
 
93
106
  # These are the options that can be used when creating a new CyberSource
@@ -245,18 +258,18 @@ module ActiveMerchant #:nodoc:
245
258
  # were only provided with one or two of them or even none
246
259
  def setup_address_hash(options)
247
260
  default_address = {
248
- :address1 => 'Unspecified',
249
- :city => 'Unspecified',
250
- :state => 'NC',
251
- :zip => '00000',
252
- :country => 'US'
261
+ address1: 'Unspecified',
262
+ city: 'Unspecified',
263
+ state: 'NC',
264
+ zip: '00000',
265
+ country: 'US'
253
266
  }
254
267
  options[:billing_address] = options[:billing_address] || options[:address] || default_address
255
268
  options[:shipping_address] = options[:shipping_address] || {}
256
269
  end
257
270
 
258
271
  def build_auth_request(money, creditcard_or_reference, options)
259
- xml = Builder::XmlMarkup.new :indent => 2
272
+ xml = Builder::XmlMarkup.new indent: 2
260
273
  add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
261
274
  add_threeds_2_ucaf_data(xml, creditcard_or_reference, options)
262
275
  add_decision_manager_fields(xml, options)
@@ -267,12 +280,14 @@ module ActiveMerchant #:nodoc:
267
280
  add_business_rules_data(xml, creditcard_or_reference, options)
268
281
  add_stored_credential_options(xml, options)
269
282
  add_issuer_additional_data(xml, options)
283
+ add_merchant_description(xml, options)
284
+ add_partner_solution_id(xml)
270
285
 
271
286
  xml.target!
272
287
  end
273
288
 
274
289
  def build_tax_calculation_request(creditcard, options)
275
- xml = Builder::XmlMarkup.new :indent => 2
290
+ xml = Builder::XmlMarkup.new indent: 2
276
291
  add_address(xml, creditcard, options[:billing_address], options, false)
277
292
  add_address(xml, creditcard, options[:shipping_address], options, true)
278
293
  add_line_item_data(xml, options)
@@ -286,18 +301,21 @@ module ActiveMerchant #:nodoc:
286
301
  order_id, request_id, request_token = authorization.split(';')
287
302
  options[:order_id] = order_id
288
303
 
289
- xml = Builder::XmlMarkup.new :indent => 2
304
+ xml = Builder::XmlMarkup.new indent: 2
290
305
  add_purchase_data(xml, money, true, options)
291
306
  add_other_tax(xml, options)
292
307
  add_mdd_fields(xml, options)
293
308
  add_capture_service(xml, request_id, request_token)
294
309
  add_business_rules_data(xml, authorization, options)
295
310
  add_issuer_additional_data(xml, options)
311
+ add_merchant_description(xml, options)
312
+ add_partner_solution_id(xml)
313
+
296
314
  xml.target!
297
315
  end
298
316
 
299
317
  def build_purchase_request(money, payment_method_or_reference, options)
300
- xml = Builder::XmlMarkup.new :indent => 2
318
+ xml = Builder::XmlMarkup.new indent: 2
301
319
  add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
302
320
  add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
303
321
  add_decision_manager_fields(xml, options)
@@ -309,8 +327,12 @@ module ActiveMerchant #:nodoc:
309
327
  add_threeds_services(xml, options)
310
328
  add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
311
329
  add_business_rules_data(xml, payment_method_or_reference, options) unless options[:pinless_debit_card]
330
+ add_stored_credential_options(xml, options)
312
331
  end
332
+
313
333
  add_issuer_additional_data(xml, options)
334
+ add_merchant_description(xml, options)
335
+ add_partner_solution_id(xml)
314
336
 
315
337
  xml.target!
316
338
  end
@@ -319,16 +341,19 @@ module ActiveMerchant #:nodoc:
319
341
  order_id, request_id, request_token, action, money, currency = identification.split(';')
320
342
  options[:order_id] = order_id
321
343
 
322
- xml = Builder::XmlMarkup.new :indent => 2
323
- if action == 'capture'
344
+ xml = Builder::XmlMarkup.new indent: 2
345
+ case action
346
+ when 'capture', 'purchase'
324
347
  add_mdd_fields(xml, options)
325
348
  add_void_service(xml, request_id, request_token)
326
349
  else
327
- add_purchase_data(xml, money, true, options.merge(:currency => currency || default_currency))
350
+ add_purchase_data(xml, money, true, options.merge(currency: currency || default_currency))
328
351
  add_mdd_fields(xml, options)
329
352
  add_auth_reversal_service(xml, request_id, request_token)
330
353
  end
331
354
  add_issuer_additional_data(xml, options)
355
+ add_partner_solution_id(xml)
356
+
332
357
  xml.target!
333
358
  end
334
359
 
@@ -336,31 +361,33 @@ module ActiveMerchant #:nodoc:
336
361
  order_id, request_id, request_token = identification.split(';')
337
362
  options[:order_id] = order_id
338
363
 
339
- xml = Builder::XmlMarkup.new :indent => 2
364
+ xml = Builder::XmlMarkup.new indent: 2
340
365
  add_purchase_data(xml, money, true, options)
341
366
  add_credit_service(xml, request_id, request_token)
367
+ add_partner_solution_id(xml)
342
368
 
343
369
  xml.target!
344
370
  end
345
371
 
346
372
  def build_credit_request(money, creditcard_or_reference, options)
347
- xml = Builder::XmlMarkup.new :indent => 2
373
+ xml = Builder::XmlMarkup.new indent: 2
348
374
 
349
375
  add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
350
376
  add_mdd_fields(xml, options)
351
377
  add_credit_service(xml)
352
378
  add_issuer_additional_data(xml, options)
379
+ add_merchant_description(xml, options)
353
380
 
354
381
  xml.target!
355
382
  end
356
383
 
357
384
  def build_create_subscription_request(payment_method, options)
358
- default_subscription_params = {:frequency => 'on-demand', :amount => 0, :automatic_renew => false}
385
+ default_subscription_params = {frequency: 'on-demand', amount: 0, automatic_renew: false}
359
386
  options[:subscription] = default_subscription_params.update(
360
387
  options[:subscription] || {}
361
388
  )
362
389
 
363
- xml = Builder::XmlMarkup.new :indent => 2
390
+ xml = Builder::XmlMarkup.new indent: 2
364
391
  add_address(xml, payment_method, options[:billing_address], options)
365
392
  add_purchase_data(xml, options[:setup_fee] || 0, true, options)
366
393
  if card_brand(payment_method) == 'check'
@@ -385,7 +412,7 @@ module ActiveMerchant #:nodoc:
385
412
  end
386
413
 
387
414
  def build_update_subscription_request(reference, creditcard, options)
388
- xml = Builder::XmlMarkup.new :indent => 2
415
+ xml = Builder::XmlMarkup.new indent: 2
389
416
  add_address(xml, creditcard, options[:billing_address], options) unless options[:billing_address].blank?
390
417
  add_purchase_data(xml, options[:setup_fee], true, options) unless options[:setup_fee].blank?
391
418
  add_creditcard(xml, creditcard) if creditcard
@@ -397,21 +424,21 @@ module ActiveMerchant #:nodoc:
397
424
  end
398
425
 
399
426
  def build_delete_subscription_request(reference, options)
400
- xml = Builder::XmlMarkup.new :indent => 2
427
+ xml = Builder::XmlMarkup.new indent: 2
401
428
  add_subscription(xml, options, reference)
402
429
  add_subscription_delete_service(xml, options)
403
430
  xml.target!
404
431
  end
405
432
 
406
433
  def build_retrieve_subscription_request(reference, options)
407
- xml = Builder::XmlMarkup.new :indent => 2
434
+ xml = Builder::XmlMarkup.new indent: 2
408
435
  add_subscription(xml, options, reference)
409
436
  add_subscription_retrieve_service(xml, options)
410
437
  xml.target!
411
438
  end
412
439
 
413
440
  def build_validate_pinless_debit_request(creditcard, options)
414
- xml = Builder::XmlMarkup.new :indent => 2
441
+ xml = Builder::XmlMarkup.new indent: 2
415
442
  add_creditcard(xml, creditcard)
416
443
  add_validate_pinless_debit_service(xml)
417
444
  xml.target!
@@ -453,6 +480,7 @@ module ActiveMerchant #:nodoc:
453
480
  xml.tag! 'clientLibrary', 'Ruby Active Merchant'
454
481
  xml.tag! 'clientLibraryVersion', VERSION
455
482
  xml.tag! 'clientEnvironment', RUBY_PLATFORM
483
+
456
484
  add_merchant_descriptor(xml, options)
457
485
  end
458
486
 
@@ -464,6 +492,18 @@ module ActiveMerchant #:nodoc:
464
492
  end
465
493
  end
466
494
 
495
+ def add_merchant_description(xml, options)
496
+ return unless options[:merchant_descriptor_name] || options[:merchant_descriptor_address1] || options[:merchant_descriptor_locality]
497
+
498
+ xml.tag! 'merchantInformation' do
499
+ xml.tag! 'merchantDescriptor' do
500
+ xml.tag! 'name', options[:merchant_descriptor_name] if options[:merchant_descriptor_name]
501
+ xml.tag! 'address1', options[:merchant_descriptor_address1] if options[:merchant_descriptor_address1]
502
+ xml.tag! 'locality', options[:merchant_descriptor_locality] if options[:merchant_descriptor_locality]
503
+ end
504
+ end
505
+ end
506
+
467
507
  def add_purchase_data(xml, money = 0, include_grand_total = false, options={})
468
508
  xml.tag! 'purchaseTotals' do
469
509
  xml.tag! 'currency', options[:currency] || currency(money)
@@ -575,7 +615,7 @@ module ActiveMerchant #:nodoc:
575
615
  xml.tag!('cavvAlgorithm', threeds_2_options[:cavv_algorithm]) if threeds_2_options[:cavv_algorithm]
576
616
  xml.tag!('paSpecificationVersion', threeds_2_options[:version]) if threeds_2_options[:version]
577
617
  xml.tag!('directoryServerTransactionID', threeds_2_options[:ds_transaction_id]) if threeds_2_options[:ds_transaction_id]
578
- xml.tag!('commerceIndicator', options[:commerce_indicator]) if options[:commerce_indicator]
618
+ xml.tag!('commerceIndicator', options[:commerce_indicator] || ECI_BRAND_MAPPING[card_brand(payment_method).to_sym])
579
619
  xml.tag!('eciRaw', threeds_2_options[:eci]) if threeds_2_options[:eci]
580
620
  xml.tag!('xid', threeds_2_options[:xid]) if threeds_2_options[:xid]
581
621
  xml.tag!('veresEnrolled', threeds_2_options[:enrolled]) if threeds_2_options[:enrolled]
@@ -587,12 +627,13 @@ module ActiveMerchant #:nodoc:
587
627
 
588
628
  xml.tag! 'ucaf' do
589
629
  xml.tag!('authenticationData', options[:three_d_secure][:cavv])
590
- xml.tag!('collectionIndicator', options[:collection_indicator]) if options[:collection_indicator]
630
+ xml.tag!('collectionIndicator', options[:collection_indicator] || DEFAULT_COLLECTION_INDICATOR)
591
631
  end
592
632
  end
593
633
 
594
634
  def stored_credential_commerce_indicator(options)
595
635
  return unless options[:stored_credential]
636
+
596
637
  return if options[:stored_credential][:initial_transaction]
597
638
 
598
639
  case options[:stored_credential][:reason_type]
@@ -608,26 +649,28 @@ module ActiveMerchant #:nodoc:
608
649
  def add_auth_network_tokenization(xml, payment_method, options)
609
650
  return unless network_tokenization?(payment_method)
610
651
 
611
- case card_brand(payment_method).to_sym
652
+ brand = card_brand(payment_method).to_sym
653
+
654
+ case brand
612
655
  when :visa
613
656
  xml.tag! 'ccAuthService', {'run' => 'true'} do
614
657
  xml.tag!('cavv', payment_method.payment_cryptogram)
615
- xml.tag!('commerceIndicator', 'vbv')
658
+ xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
616
659
  xml.tag!('xid', payment_method.payment_cryptogram)
617
660
  end
618
661
  when :master
619
662
  xml.tag! 'ucaf' do
620
663
  xml.tag!('authenticationData', payment_method.payment_cryptogram)
621
- xml.tag!('collectionIndicator', '2')
664
+ xml.tag!('collectionIndicator', DEFAULT_COLLECTION_INDICATOR)
622
665
  end
623
666
  xml.tag! 'ccAuthService', {'run' => 'true'} do
624
- xml.tag!('commerceIndicator', 'spa')
667
+ xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
625
668
  end
626
669
  when :american_express
627
670
  cryptogram = Base64.decode64(payment_method.payment_cryptogram)
628
671
  xml.tag! 'ccAuthService', {'run' => 'true'} do
629
672
  xml.tag!('cavv', Base64.encode64(cryptogram[0...20]))
630
- xml.tag!('commerceIndicator', 'aesk')
673
+ xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
631
674
  xml.tag!('xid', Base64.encode64(cryptogram[20...40]))
632
675
  end
633
676
  end
@@ -777,22 +820,23 @@ module ActiveMerchant #:nodoc:
777
820
 
778
821
  def add_stored_credential_options(xml, options={})
779
822
  return unless options[:stored_credential]
823
+ xml.tag! 'subsequentAuth', 'true' if options[:stored_credential][:initiator] == 'merchant'
824
+ xml.tag! 'subsequentAuthFirst', 'true' if options[:stored_credential][:initial_transaction]
825
+ xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id] if options[:stored_credential][:initiator] == 'merchant'
826
+ xml.tag! 'subsequentAuthStoredCredential', 'true' if options[:stored_credential][:initiator] == 'cardholder' && !options[:stored_credential][:initial_transaction] || options[:stored_credential][:initiator] == 'merchant' && options[:stored_credential][:reason_type] == 'unscheduled'
827
+ end
780
828
 
781
- if options[:stored_credential][:initial_transaction]
782
- xml.tag! 'subsequentAuthFirst', 'true'
783
- elsif options[:stored_credential][:reason_type] == 'unscheduled'
784
- xml.tag! 'subsequentAuth', 'true'
785
- xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id]
786
- else
787
- xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id]
788
- end
829
+ def add_partner_solution_id(xml)
830
+ return unless application_id
831
+
832
+ xml.tag!('partnerSolutionID', application_id)
789
833
  end
790
834
 
791
835
  # Where we actually build the full SOAP request using builder
792
836
  def build_request(body, options)
793
837
  xsd_version = test? ? TEST_XSD_VERSION : PRODUCTION_XSD_VERSION
794
838
 
795
- xml = Builder::XmlMarkup.new :indent => 2
839
+ xml = Builder::XmlMarkup.new indent: 2
796
840
  xml.instruct!
797
841
  xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
798
842
  xml.tag! 's:Header' do
@@ -828,16 +872,17 @@ module ActiveMerchant #:nodoc:
828
872
  response = { message: e.to_s }
829
873
  end
830
874
 
831
- success = response[:decision] == 'ACCEPT'
832
- message = response[:message]
875
+ success = success?(response)
876
+ message = message_from(response)
833
877
 
834
878
  authorization = success ? authorization_from(response, action, amount, options) : nil
835
879
 
836
880
  Response.new(success, message, response,
837
- :test => test?,
838
- :authorization => authorization,
839
- :avs_result => { :code => response[:avsCode] },
840
- :cvv_result => response[:cvCode]
881
+ test: test?,
882
+ authorization: authorization,
883
+ fraud_review: in_fraud_review?(response),
884
+ avs_result: { code: response[:avsCode] },
885
+ cvv_result: response[:cvCode]
841
886
  )
842
887
  end
843
888
 
@@ -887,6 +932,24 @@ module ActiveMerchant #:nodoc:
887
932
  [options[:order_id], response[:requestID], response[:requestToken], action, amount,
888
933
  options[:currency], response[:subscriptionID]].join(';')
889
934
  end
935
+
936
+ def in_fraud_review?(response)
937
+ response[:decision] == @@decision_codes[:review]
938
+ end
939
+
940
+ def success?(response)
941
+ response[:decision] == @@decision_codes[:accept]
942
+ end
943
+
944
+ def message_from(response)
945
+ if response[:reasonCode] == '101' && response[:missingField]
946
+ "#{response[:message]}: #{response[:missingField]}"
947
+ elsif response[:reasonCode] == '102' && response[:invalidField]
948
+ "#{response[:message]}: #{response[:invalidField]}"
949
+ else
950
+ response[:message]
951
+ end
952
+ end
890
953
  end
891
954
  end
892
955
  end