activemerchant 1.103.0 → 1.104.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +41 -0
  3. data/lib/active_merchant.rb +1 -1
  4. data/lib/active_merchant/billing/avs_result.rb +8 -8
  5. data/lib/active_merchant/billing/compatibility.rb +2 -1
  6. data/lib/active_merchant/billing/credit_card.rb +3 -1
  7. data/lib/active_merchant/billing/credit_card_methods.rb +12 -0
  8. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  9. data/lib/active_merchant/billing/gateway.rb +3 -0
  10. data/lib/active_merchant/billing/gateways/adyen.rb +32 -9
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +2 -2
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +10 -9
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -0
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -0
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +1 -0
  16. data/lib/active_merchant/billing/gateways/balanced.rb +18 -15
  17. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +4 -0
  18. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -1
  19. data/lib/active_merchant/billing/gateways/blue_pay.rb +6 -5
  20. data/lib/active_merchant/billing/gateways/blue_snap.rb +31 -3
  21. data/lib/active_merchant/billing/gateways/borgun.rb +1 -1
  22. data/lib/active_merchant/billing/gateways/bpoint.rb +0 -2
  23. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +1 -0
  24. data/lib/active_merchant/billing/gateways/braintree_blue.rb +11 -4
  25. data/lib/active_merchant/billing/gateways/bridge_pay.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/card_connect.rb +2 -1
  27. data/lib/active_merchant/billing/gateways/card_save.rb +2 -3
  28. data/lib/active_merchant/billing/gateways/card_stream.rb +6 -6
  29. data/lib/active_merchant/billing/gateways/cardprocess.rb +2 -0
  30. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -0
  31. data/lib/active_merchant/billing/gateways/cc5.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/cecabank.rb +1 -0
  33. data/lib/active_merchant/billing/gateways/cenpos.rb +4 -3
  34. data/lib/active_merchant/billing/gateways/checkout_v2.rb +2 -0
  35. data/lib/active_merchant/billing/gateways/citrus_pay.rb +0 -1
  36. data/lib/active_merchant/billing/gateways/clearhaus.rb +3 -2
  37. data/lib/active_merchant/billing/gateways/conekta.rb +5 -3
  38. data/lib/active_merchant/billing/gateways/creditcall.rb +1 -0
  39. data/lib/active_merchant/billing/gateways/credorax.rb +17 -10
  40. data/lib/active_merchant/billing/gateways/ct_payment.rb +1 -0
  41. data/lib/active_merchant/billing/gateways/cyber_source.rb +38 -0
  42. data/lib/active_merchant/billing/gateways/d_local.rb +6 -0
  43. data/lib/active_merchant/billing/gateways/data_cash.rb +1 -1
  44. data/lib/active_merchant/billing/gateways/decidir.rb +18 -2
  45. data/lib/active_merchant/billing/gateways/digitzs.rb +3 -0
  46. data/lib/active_merchant/billing/gateways/ebanx.rb +13 -2
  47. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -2
  48. data/lib/active_merchant/billing/gateways/elavon.rb +1 -1
  49. data/lib/active_merchant/billing/gateways/eway.rb +2 -1
  50. data/lib/active_merchant/billing/gateways/eway_managed.rb +2 -3
  51. data/lib/active_merchant/billing/gateways/eway_rapid.rb +1 -0
  52. data/lib/active_merchant/billing/gateways/exact.rb +3 -3
  53. data/lib/active_merchant/billing/gateways/fat_zebra.rb +2 -1
  54. data/lib/active_merchant/billing/gateways/first_giving.rb +2 -1
  55. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +2 -2
  56. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +1 -0
  57. data/lib/active_merchant/billing/gateways/flo2cash.rb +2 -2
  58. data/lib/active_merchant/billing/gateways/forte.rb +1 -0
  59. data/lib/active_merchant/billing/gateways/garanti.rb +0 -1
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +29 -0
  61. data/lib/active_merchant/billing/gateways/global_transport.rb +0 -1
  62. data/lib/active_merchant/billing/gateways/hdfc.rb +1 -0
  63. data/lib/active_merchant/billing/gateways/hps.rb +9 -7
  64. data/lib/active_merchant/billing/gateways/iats_payments.rb +4 -4
  65. data/lib/active_merchant/billing/gateways/iridium.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/itransact.rb +3 -2
  67. data/lib/active_merchant/billing/gateways/iveri.rb +1 -0
  68. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -1
  69. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/latitude19.rb +2 -1
  71. data/lib/active_merchant/billing/gateways/litle.rb +3 -0
  72. data/lib/active_merchant/billing/gateways/mastercard.rb +1 -0
  73. data/lib/active_merchant/billing/gateways/mercado_pago.rb +45 -0
  74. data/lib/active_merchant/billing/gateways/merchant_one.rb +0 -1
  75. data/lib/active_merchant/billing/gateways/merchant_partners.rb +3 -3
  76. data/lib/active_merchant/billing/gateways/merchant_ware.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +16 -1
  78. data/lib/active_merchant/billing/gateways/mercury.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -2
  80. data/lib/active_merchant/billing/gateways/micropayment.rb +0 -1
  81. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  82. data/lib/active_merchant/billing/gateways/moneris.rb +36 -8
  83. data/lib/active_merchant/billing/gateways/moneris_us.rb +2 -0
  84. data/lib/active_merchant/billing/gateways/mundipagg.rb +6 -1
  85. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -2
  86. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/netbanx.rb +3 -1
  88. data/lib/active_merchant/billing/gateways/netbilling.rb +3 -3
  89. data/lib/active_merchant/billing/gateways/netpay.rb +1 -0
  90. data/lib/active_merchant/billing/gateways/nmi.rb +5 -6
  91. data/lib/active_merchant/billing/gateways/ogone.rb +4 -2
  92. data/lib/active_merchant/billing/gateways/omise.rb +1 -2
  93. data/lib/active_merchant/billing/gateways/openpay.rb +3 -1
  94. data/lib/active_merchant/billing/gateways/opp.rb +1 -0
  95. data/lib/active_merchant/billing/gateways/optimal_payment.rb +4 -5
  96. data/lib/active_merchant/billing/gateways/orbital.rb +17 -13
  97. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -1
  98. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/pagarme.rb +1 -0
  100. data/lib/active_merchant/billing/gateways/pay_conex.rb +1 -1
  101. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -1
  102. data/lib/active_merchant/billing/gateways/pay_hub.rb +1 -0
  103. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +1 -0
  104. data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
  105. data/lib/active_merchant/billing/gateways/paybox_direct.rb +4 -2
  106. data/lib/active_merchant/billing/gateways/payeezy.rb +2 -0
  107. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
  108. data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
  109. data/lib/active_merchant/billing/gateways/paymentez.rb +4 -0
  110. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
  111. data/lib/active_merchant/billing/gateways/paystation.rb +1 -3
  112. data/lib/active_merchant/billing/gateways/payu_in.rb +1 -1
  113. data/lib/active_merchant/billing/gateways/payu_latam.rb +6 -0
  114. data/lib/active_merchant/billing/gateways/payway.rb +3 -2
  115. data/lib/active_merchant/billing/gateways/pin.rb +1 -0
  116. data/lib/active_merchant/billing/gateways/plugnpay.rb +4 -4
  117. data/lib/active_merchant/billing/gateways/pro_pay.rb +1 -0
  118. data/lib/active_merchant/billing/gateways/psigate.rb +2 -1
  119. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -1
  120. data/lib/active_merchant/billing/gateways/qbms.rb +2 -2
  121. data/lib/active_merchant/billing/gateways/quantum.rb +0 -1
  122. data/lib/active_merchant/billing/gateways/quickbooks.rb +2 -0
  123. data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
  124. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +5 -5
  125. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +1 -0
  126. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -0
  127. data/lib/active_merchant/billing/gateways/qvalent.rb +2 -0
  128. data/lib/active_merchant/billing/gateways/realex.rb +3 -1
  129. data/lib/active_merchant/billing/gateways/redsys.rb +3 -2
  130. data/lib/active_merchant/billing/gateways/s5.rb +1 -0
  131. data/lib/active_merchant/billing/gateways/safe_charge.rb +2 -0
  132. data/lib/active_merchant/billing/gateways/sage.rb +1 -1
  133. data/lib/active_merchant/billing/gateways/sage_pay.rb +8 -6
  134. data/lib/active_merchant/billing/gateways/secure_net.rb +2 -4
  135. data/lib/active_merchant/billing/gateways/secure_pay.rb +2 -2
  136. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +1 -1
  137. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
  138. data/lib/active_merchant/billing/gateways/securion_pay.rb +2 -0
  139. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -5
  140. data/lib/active_merchant/billing/gateways/smart_ps.rb +0 -1
  141. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +0 -1
  142. data/lib/active_merchant/billing/gateways/spreedly_core.rb +1 -0
  143. data/lib/active_merchant/billing/gateways/stripe.rb +7 -0
  144. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +9 -4
  145. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +1 -1
  146. data/lib/active_merchant/billing/gateways/telr.rb +3 -0
  147. data/lib/active_merchant/billing/gateways/tns.rb +0 -1
  148. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -0
  149. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +4 -2
  150. data/lib/active_merchant/billing/gateways/transax.rb +0 -1
  151. data/lib/active_merchant/billing/gateways/trexle.rb +3 -0
  152. data/lib/active_merchant/billing/gateways/usa_epay.rb +0 -1
  153. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +15 -16
  154. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +5 -0
  155. data/lib/active_merchant/billing/gateways/vanco.rb +1 -1
  156. data/lib/active_merchant/billing/gateways/visanet_peru.rb +1 -0
  157. data/lib/active_merchant/billing/gateways/wepay.rb +7 -6
  158. data/lib/active_merchant/billing/gateways/wirecard.rb +6 -3
  159. data/lib/active_merchant/billing/gateways/world_net.rb +1 -0
  160. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -0
  161. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +0 -1
  162. data/lib/active_merchant/billing/gateways/worldpay_us.rb +2 -2
  163. data/lib/active_merchant/billing/response.rb +1 -1
  164. data/lib/active_merchant/connection.rb +2 -0
  165. data/lib/active_merchant/country.rb +1 -0
  166. data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
  167. data/lib/active_merchant/post_data.rb +1 -0
  168. data/lib/active_merchant/version.rb +1 -1
  169. data/lib/support/ssl_verify.rb +0 -2
  170. data/lib/support/ssl_version.rb +0 -1
  171. metadata +2 -2
@@ -89,6 +89,7 @@ module ActiveMerchant #:nodoc:
89
89
 
90
90
  def add_country(post, card, options)
91
91
  return unless address = options[:billing_address] || options[:address]
92
+
92
93
  post[:country] = lookup_country_code(address[:country])
93
94
  end
94
95
 
@@ -111,6 +112,7 @@ module ActiveMerchant #:nodoc:
111
112
 
112
113
  def add_address(post, card, options)
113
114
  return unless address = options[:billing_address] || options[:address]
115
+
114
116
  address_object = {}
115
117
  address_object[:state] = address[:state] if address[:state]
116
118
  address_object[:city] = address[:city] if address[:city]
@@ -129,6 +131,8 @@ module ActiveMerchant #:nodoc:
129
131
  post[:card][:cvv] = card.verification_value
130
132
  post[:card][:descriptor] = options[:dynamic_descriptor] if options[:dynamic_descriptor]
131
133
  post[:card][:capture] = (action == 'purchase')
134
+ post[:card][:installments] = options[:installments] if options[:installments]
135
+ post[:card][:installments_id] = options[:installments_id] if options[:installments_id]
132
136
  end
133
137
 
134
138
  def parse(body)
@@ -163,6 +167,7 @@ module ActiveMerchant #:nodoc:
163
167
  # we count 100 as a success.
164
168
  def success_from(action, response)
165
169
  return false unless response['status_code']
170
+
166
171
  ['100', '200', '400', '600'].include? response['status_code'].to_s
167
172
  end
168
173
 
@@ -176,6 +181,7 @@ module ActiveMerchant #:nodoc:
176
181
 
177
182
  def error_code_from(action, response)
178
183
  return if success_from(action, response)
184
+
179
185
  code = response['status_code'] || response['code']
180
186
  code&.to_s
181
187
  end
@@ -6,7 +6,7 @@ module ActiveMerchant
6
6
  self.default_currency = 'GBP'
7
7
  self.supported_countries = ['GB']
8
8
 
9
- self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro ]
9
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
10
10
 
11
11
  self.homepage_url = 'http://www.datacash.com/'
12
12
  self.display_name = 'DataCash'
@@ -106,7 +106,7 @@ module ActiveMerchant #:nodoc:
106
106
  private
107
107
 
108
108
  def add_auth_purchase_params(post, money, credit_card, options)
109
- post[:payment_method_id] = add_payment_method_id(credit_card)
109
+ post[:payment_method_id] = add_payment_method_id(credit_card, options)
110
110
  post[:site_transaction_id] = options[:order_id]
111
111
  post[:bin] = credit_card.number[0..5]
112
112
  post[:payment_type] = options[:payment_type] || 'single'
@@ -119,9 +119,25 @@ module ActiveMerchant #:nodoc:
119
119
  add_payment(post, credit_card, options)
120
120
  end
121
121
 
122
- def add_payment_method_id(credit_card)
122
+ def add_payment_method_id(credit_card, options)
123
123
  if options[:payment_method_id]
124
124
  options[:payment_method_id].to_i
125
+ elsif options[:debit]
126
+ if CreditCard.brand?(credit_card.number) == 'visa'
127
+ 31
128
+ elsif CreditCard.brand?(credit_card.number) == 'master'
129
+ 105
130
+ elsif CreditCard.brand?(credit_card.number) == 'maestro'
131
+ 106
132
+ elsif CreditCard.brand?(credit_card.number) == 'cabal'
133
+ 108
134
+ end
135
+ elsif CreditCard.brand?(credit_card.number) == 'master'
136
+ 104
137
+ elsif CreditCard.brand?(credit_card.number) == 'american_express'
138
+ 65
139
+ elsif CreditCard.brand?(credit_card.number) == 'diners_club'
140
+ 8
125
141
  elsif CreditCard.brand?(credit_card.number) == 'cabal'
126
142
  63
127
143
  elsif CreditCard.brand?(credit_card.number) == 'naranja'
@@ -188,6 +188,7 @@ module ActiveMerchant #:nodoc:
188
188
  response = parse(ssl_get(url + "/customers/#{options[:customer_id]}", headers(options)))
189
189
 
190
190
  return response.try(:[], 'data').try(:[], 'customerId') if success_from(response)
191
+
191
192
  return nil
192
193
  end
193
194
 
@@ -228,6 +229,7 @@ module ActiveMerchant #:nodoc:
228
229
  def message_from(response)
229
230
  return response['message'] if response['message']
230
231
  return 'Success' if success_from(response)
232
+
231
233
  response['errors'].map { |error_hash| error_hash['detail'] }.join(', ')
232
234
  end
233
235
 
@@ -276,6 +278,7 @@ module ActiveMerchant #:nodoc:
276
278
  return 'cardSplit' if options[:payment_type] == 'card_split'
277
279
  return 'tokenSplit' if options[:payment_type] == 'token_split'
278
280
  return 'token' if payment.is_a? String
281
+
279
282
  'card'
280
283
  end
281
284
 
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
4
4
  self.test_url = 'https://sandbox.ebanxpay.com/ws/'
5
5
  self.live_url = 'https://api.ebanxpay.com/ws/'
6
6
 
7
- self.supported_countries = ['BR', 'MX', 'CO', 'CL', 'AR']
7
+ self.supported_countries = %w(BR MX CO CL AR PE)
8
8
  self.default_currency = 'USD'
9
9
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
10
10
 
@@ -51,6 +51,7 @@ module ActiveMerchant #:nodoc:
51
51
  add_card_or_token(post, payment)
52
52
  add_address(post, options)
53
53
  add_customer_responsible_person(post, payment, options)
54
+ add_additional_data(post, options)
54
55
 
55
56
  commit(:purchase, post)
56
57
  end
@@ -73,7 +74,7 @@ module ActiveMerchant #:nodoc:
73
74
  post = {}
74
75
  add_integration_key(post)
75
76
  post[:hash] = authorization
76
- post[:amount] = amount(money)
77
+ post[:amount] = amount(money) if options[:include_capture_amount].to_s == 'true'
77
78
 
78
79
  commit(:capture, post)
79
80
  end
@@ -198,6 +199,10 @@ module ActiveMerchant #:nodoc:
198
199
  end
199
200
  end
200
201
 
202
+ def add_additional_data(post, options)
203
+ post[:device_id] = options[:device_id] if options[:device_id]
204
+ end
205
+
201
206
  def parse(body)
202
207
  JSON.parse(body)
203
208
  end
@@ -234,6 +239,7 @@ module ActiveMerchant #:nodoc:
234
239
 
235
240
  def message_from(response)
236
241
  return response['status_message'] if response['status'] == 'ERROR'
242
+
237
243
  response.try(:[], 'payment').try(:[], 'transaction_status').try(:[], 'description')
238
244
  end
239
245
 
@@ -248,22 +254,26 @@ module ActiveMerchant #:nodoc:
248
254
  def post_data(action, parameters = {})
249
255
  return nil if requires_http_get(action)
250
256
  return convert_to_url_form_encoded(parameters) if action == :refund
257
+
251
258
  "request_body=#{parameters.to_json}"
252
259
  end
253
260
 
254
261
  def url_for(hostname, action, parameters)
255
262
  return "#{hostname}#{URL_MAP[action]}?#{convert_to_url_form_encoded(parameters)}" if requires_http_get(action)
263
+
256
264
  "#{hostname}#{URL_MAP[action]}"
257
265
  end
258
266
 
259
267
  def requires_http_get(action)
260
268
  return true if [:capture, :void].include?(action)
269
+
261
270
  false
262
271
  end
263
272
 
264
273
  def convert_to_url_form_encoded(parameters)
265
274
  parameters.map do |key, value|
266
275
  next if value != false && value.blank?
276
+
267
277
  "#{key}=#{value}"
268
278
  end.compact.join('&')
269
279
  end
@@ -271,6 +281,7 @@ module ActiveMerchant #:nodoc:
271
281
  def error_code_from(response, success)
272
282
  unless success
273
283
  return response['status_code'] if response['status'] == 'ERROR'
284
+
274
285
  response.try(:[], 'payment').try(:[], 'transaction_status').try(:[], 'code')
275
286
  end
276
287
  end
@@ -158,7 +158,7 @@ module ActiveMerchant #:nodoc:
158
158
  end
159
159
 
160
160
  def authorization_from(response, params)
161
- [ response[:transaction_id], params[:transaction_amount] ].compact.join(';')
161
+ [response[:transaction_id], params[:transaction_amount]].compact.join(';')
162
162
  end
163
163
 
164
164
  def parse(xml)
@@ -190,6 +190,7 @@ module ActiveMerchant #:nodoc:
190
190
 
191
191
  def message_from(message)
192
192
  return 'Unspecified error' if message.blank?
193
+
193
194
  message.gsub(/[^\w]/, ' ').split.join(' ').capitalize
194
195
  end
195
196
 
@@ -197,7 +198,7 @@ module ActiveMerchant #:nodoc:
197
198
  ACTIONS
198
199
  end
199
200
 
200
- CREDIT_CARD_FIELDS = %w(AuthorizationNumber ClientIpAddress BillingAddress BillingCity BillingState BillingPostalCode BillingCountry BillingName CardVerificationValue ExpirationMonth ExpirationYear ReferenceNumber TransactionAmount AccountNumber )
201
+ CREDIT_CARD_FIELDS = %w(AuthorizationNumber ClientIpAddress BillingAddress BillingCity BillingState BillingPostalCode BillingCountry BillingName CardVerificationValue ExpirationMonth ExpirationYear ReferenceNumber TransactionAmount AccountNumber)
201
202
 
202
203
  ACTIONS = {
203
204
  :credit_card_authorize => CREDIT_CARD_FIELDS,
@@ -287,6 +287,7 @@ module ActiveMerchant #:nodoc:
287
287
 
288
288
  def custom_field?(field_name, options)
289
289
  return true if options[:custom_fields]&.include?(field_name.to_sym)
290
+
290
291
  field_name == :customer_number
291
292
  end
292
293
 
@@ -310,7 +311,6 @@ module ActiveMerchant #:nodoc:
310
311
  }
311
312
  resp
312
313
  end
313
-
314
314
  end
315
315
  end
316
316
  end
@@ -82,7 +82,7 @@ module ActiveMerchant #:nodoc:
82
82
 
83
83
  def add_address(post, options)
84
84
  if address = options[:billing_address] || options[:address]
85
- post[:CustomerAddress] = [ address[:address1], address[:address2], address[:city], address[:state], address[:country] ].compact.join(', ')
85
+ post[:CustomerAddress] = [address[:address1], address[:address2], address[:city], address[:state], address[:country]].compact.join(', ')
86
86
  post[:CustomerPostcode] = address[:zip]
87
87
  end
88
88
  end
@@ -145,6 +145,7 @@ module ActiveMerchant #:nodoc:
145
145
 
146
146
  def message_from(message)
147
147
  return '' if message.blank?
148
+
148
149
  MESSAGES[message[0, 2]] || message
149
150
  end
150
151
 
@@ -265,7 +265,7 @@ module ActiveMerchant #:nodoc:
265
265
 
266
266
  def default_customer_fields
267
267
  hash={}
268
- %w( CustomerRef Title FirstName LastName Company JobDesc Email Address Suburb State PostCode Country Phone Mobile Fax URL Comments CCNumber CCNameOnCard CCExpiryMonth CCExpiryYear ).each do |field|
268
+ %w(CustomerRef Title FirstName LastName Company JobDesc Email Address Suburb State PostCode Country Phone Mobile Fax URL Comments CCNumber CCNameOnCard CCExpiryMonth CCExpiryYear).each do |field|
269
269
  hash[field.to_sym]=''
270
270
  end
271
271
  return hash
@@ -273,7 +273,7 @@ module ActiveMerchant #:nodoc:
273
273
 
274
274
  def default_payment_fields
275
275
  hash={}
276
- %w( managedCustomerID amount invoiceReference invoiceDescription ).each do |field|
276
+ %w(managedCustomerID amount invoiceReference invoiceDescription).each do |field|
277
277
  hash[field.to_sym]=''
278
278
  end
279
279
  return hash
@@ -285,7 +285,6 @@ module ActiveMerchant #:nodoc:
285
285
  @params['CreateCustomerResult']
286
286
  end
287
287
  end
288
-
289
288
  end
290
289
  end
291
290
  end
@@ -268,6 +268,7 @@ module ActiveMerchant #:nodoc:
268
268
 
269
269
  def add_credit_card(params, credit_card, options)
270
270
  return unless credit_card
271
+
271
272
  params['Customer'] ||= {}
272
273
  if credit_card.respond_to? :number
273
274
  card_details = params['Customer']['CardDetails'] = {}
@@ -5,8 +5,8 @@ module ActiveMerchant #:nodoc:
5
5
 
6
6
  API_VERSION = '8.5'
7
7
 
8
- TEST_LOGINS = [ {:login => 'A00049-01', :password => 'test1'},
9
- {:login => 'A00427-01', :password => 'testus'} ]
8
+ TEST_LOGINS = [{:login => 'A00049-01', :password => 'test1'},
9
+ {:login => 'A00427-01', :password => 'testus'}]
10
10
 
11
11
  TRANSACTIONS = { :sale => '00',
12
12
  :authorization => '01',
@@ -28,7 +28,7 @@ module ActiveMerchant #:nodoc:
28
28
 
29
29
  SUCCESS = 'true'
30
30
 
31
- SENSITIVE_FIELDS = [ :verification_str2, :expiry_date, :card_number ]
31
+ SENSITIVE_FIELDS = [:verification_str2, :expiry_date, :card_number]
32
32
 
33
33
  self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover]
34
34
  self.supported_countries = ['CA', 'US']
@@ -149,7 +149,8 @@ module ActiveMerchant #:nodoc:
149
149
  begin
150
150
  parse(ssl_request(method, get_url(uri), parameters.to_json, headers))
151
151
  rescue ResponseError => e
152
- return Response.new(false, 'Invalid Login') if(e.response.code == '401')
152
+ return Response.new(false, 'Invalid Login') if e.response.code == '401'
153
+
153
154
  parse(e.response.body)
154
155
  end
155
156
 
@@ -49,7 +49,7 @@ module ActiveMerchant #:nodoc:
49
49
  end
50
50
 
51
51
  def add_address(post, options)
52
- if(billing_address = (options[:billing_address] || options[:address]))
52
+ if (billing_address = (options[:billing_address] || options[:address]))
53
53
  post[:billToAddressLine1] = billing_address[:address1]
54
54
  post[:billToCity] = billing_address[:city]
55
55
  post[:billToState] = billing_address[:state]
@@ -83,6 +83,7 @@ module ActiveMerchant #:nodoc:
83
83
  end
84
84
  element.children.each do |child|
85
85
  next if child.text?
86
+
86
87
  response[child.name] = child.text
87
88
  end
88
89
 
@@ -407,9 +407,9 @@ module ActiveMerchant #:nodoc:
407
407
  end
408
408
 
409
409
  def message_from(response)
410
- if(response[:faultcode] && response[:faultstring])
410
+ if response[:faultcode] && response[:faultstring]
411
411
  response[:faultstring]
412
- elsif(response[:error_number] && response[:error_number] != '0')
412
+ elsif response[:error_number] && response[:error_number] != '0'
413
413
  response[:error_description]
414
414
  else
415
415
  result = (response[:exact_message] || '')
@@ -315,6 +315,7 @@ module ActiveMerchant #:nodoc:
315
315
 
316
316
  def add_stored_credentials(xml, card, options)
317
317
  return unless options[:stored_credential]
318
+
318
319
  xml.tag! 'StoredCredentials' do
319
320
  xml.tag! 'Indicator', stored_credential_indicator(xml, card, options)
320
321
  if initiator = options.dig(:stored_credential, :initiator)
@@ -89,7 +89,7 @@ module ActiveMerchant #:nodoc:
89
89
  end
90
90
 
91
91
  def add_customer_data(post, options)
92
- if(billing_address = (options[:billing_address] || options[:address]))
92
+ if (billing_address = (options[:billing_address] || options[:address]))
93
93
  post[:Email] = billing_address[:email]
94
94
  end
95
95
  end
@@ -107,7 +107,7 @@ module ActiveMerchant #:nodoc:
107
107
  begin
108
108
  raw = parse(ssl_post(url, data, headers(action)), action)
109
109
  rescue ActiveMerchant::ResponseError => e
110
- if(e.response.code == '500' && e.response.body.start_with?('<?xml'))
110
+ if e.response.code == '500' && e.response.body.start_with?('<?xml')
111
111
  raw = parse(e.response.body, action)
112
112
  else
113
113
  raise
@@ -137,6 +137,7 @@ module ActiveMerchant #:nodoc:
137
137
 
138
138
  def add_shipping_address(post, options)
139
139
  return unless options[:shipping_address]
140
+
140
141
  address = options[:shipping_address]
141
142
 
142
143
  post[:shipping_address] = {}
@@ -251,7 +251,6 @@ module ActiveMerchant #:nodoc:
251
251
  def strip_invalid_xml_chars(xml)
252
252
  xml.gsub(/&(?!(?:[a-z]+|#[0-9]+|x[a-zA-Z0-9]+);)/, '&amp;')
253
253
  end
254
-
255
254
  end
256
255
  end
257
256
  end
@@ -100,6 +100,35 @@ module ActiveMerchant #:nodoc:
100
100
  post['order']['references']['invoiceData'] = {
101
101
  'invoiceNumber' => options[:invoice]
102
102
  }
103
+ add_airline_data(post, options) if options[:airline_data]
104
+ end
105
+
106
+ def add_airline_data(post, options)
107
+ airline_data = {}
108
+
109
+ flight_date = options[:airline_data][:flight_date]
110
+ passenger_name = options[:airline_data][:passenger_name]
111
+ code = options[:airline_data][:code]
112
+ name = options[:airline_data][:name]
113
+
114
+ airline_data['flightDate'] = flight_date if flight_date
115
+ airline_data['passengerName'] = passenger_name if passenger_name
116
+ airline_data['code'] = code if code
117
+ airline_data['name'] = name if name
118
+
119
+ flight_legs = []
120
+ options[:airline_data][:flight_legs]&.each do |fl|
121
+ leg = {}
122
+ leg['arrivalAirport'] = fl[:arrival_airport] if fl[:arrival_airport]
123
+ leg['originAirport'] = fl[:origin_airport] if fl[:origin_airport]
124
+ leg['date'] = fl[:date] if fl[:date]
125
+ leg['number'] = fl[:number] if fl[:number]
126
+ leg['carrierCode'] = fl[:carrier_code] if fl[:carrier_code]
127
+ leg['airlineClass'] = fl[:carrier_code] if fl[:airline_class]
128
+ flight_legs << leg
129
+ end
130
+ airline_data['flightLegs'] = flight_legs
131
+ post['order']['additionalInput']['airlineData'] = airline_data
103
132
  end
104
133
 
105
134
  def add_creator_info(post, options)
@@ -188,7 +188,6 @@ module ActiveMerchant #:nodoc:
188
188
  ExtData: ''
189
189
  }
190
190
  end
191
-
192
191
  end
193
192
  end
194
193
  end
@@ -196,6 +196,7 @@ EOA
196
196
 
197
197
  def escape(string, max_length=250)
198
198
  return '' unless string
199
+
199
200
  string = string[0...max_length] if max_length
200
201
  string.gsub(/[^A-Za-z0-9 \-_@\.\n]/, '')
201
202
  end
@@ -115,7 +115,7 @@ module ActiveMerchant #:nodoc:
115
115
  xml.hps :CardHolderEmail, options[:email] if options[:email]
116
116
  xml.hps :CardHolderPhone, options[:phone] if options[:phone]
117
117
 
118
- if(billing_address = (options[:billing_address] || options[:address]))
118
+ if (billing_address = (options[:billing_address] || options[:address]))
119
119
  xml.hps :CardHolderAddr, billing_address[:address1] if billing_address[:address1]
120
120
  xml.hps :CardHolderCity, billing_address[:city] if billing_address[:city]
121
121
  xml.hps :CardHolderState, billing_address[:state] if billing_address[:state]
@@ -206,6 +206,7 @@ module ActiveMerchant #:nodoc:
206
206
 
207
207
  def strip_leading_zero(value)
208
208
  return value unless value[0] == '0'
209
+
209
210
  value[1, 1]
210
211
  end
211
212
 
@@ -248,7 +249,7 @@ module ActiveMerchant #:nodoc:
248
249
 
249
250
  doc = Nokogiri::XML(raw)
250
251
  doc.remove_namespaces!
251
- if(header = doc.xpath('//Header').first)
252
+ if (header = doc.xpath('//Header').first)
252
253
  header.elements.each do |node|
253
254
  if node.elements.size == 0
254
255
  response[node.name] = node.text
@@ -259,12 +260,12 @@ module ActiveMerchant #:nodoc:
259
260
  end
260
261
  end
261
262
  end
262
- if(transaction = doc.xpath('//Transaction/*[1]').first)
263
+ if (transaction = doc.xpath('//Transaction/*[1]').first)
263
264
  transaction.elements.each do |node|
264
265
  response[node.name] = node.text
265
266
  end
266
267
  end
267
- if(fault = doc.xpath('//Fault/Reason/Text').first)
268
+ if (fault = doc.xpath('//Fault/Reason/Text').first)
268
269
  response['Fault'] = fault.text
269
270
  end
270
271
 
@@ -303,10 +304,10 @@ module ActiveMerchant #:nodoc:
303
304
  end
304
305
 
305
306
  def message_from(response)
306
- if(response['Fault'])
307
+ if response['Fault']
307
308
  response['Fault']
308
- elsif(response['GatewayRspCode'] == '0')
309
- if(response['RspCode'] != '00' && response['RspCode'] != '85')
309
+ elsif response['GatewayRspCode'] == '0'
310
+ if response['RspCode'] != '00' && response['RspCode'] != '85'
310
311
  issuer_message(response['RspCode'])
311
312
  else
312
313
  response['GatewayRspMsg']
@@ -337,6 +338,7 @@ module ActiveMerchant #:nodoc:
337
338
  return 'The card was declined.' if %w(02 03 04 05 41 43 44 51 56 61 62 63 65 78).include?(code)
338
339
  return 'An error occurred while processing the card.' if %w(06 07 12 15 19 12 52 53 57 58 76 77 91 96 EC).include?(code)
339
340
  return "The card's security code is incorrect." if %w(EB N7).include?(code)
341
+
340
342
  ISSUER_MESSAGES[code]
341
343
  end
342
344