activemerchant 1.123.0 → 1.126.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +206 -0
  3. data/lib/active_merchant/billing/check.rb +5 -8
  4. data/lib/active_merchant/billing/credit_card.rb +10 -0
  5. data/lib/active_merchant/billing/credit_card_methods.rb +18 -3
  6. data/lib/active_merchant/billing/gateway.rb +3 -2
  7. data/lib/active_merchant/billing/gateways/adyen.rb +66 -11
  8. data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
  9. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +2 -1
  10. data/lib/active_merchant/billing/gateways/blue_pay.rb +1 -1
  11. data/lib/active_merchant/billing/gateways/blue_snap.rb +31 -21
  12. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +6 -1
  13. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +87 -15
  15. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +17 -13
  17. data/lib/active_merchant/billing/gateways/cashnet.rb +15 -5
  18. data/lib/active_merchant/billing/gateways/checkout_v2.rb +34 -5
  19. data/lib/active_merchant/billing/gateways/credorax.rb +10 -0
  20. data/lib/active_merchant/billing/gateways/cyber_source.rb +24 -36
  21. data/lib/active_merchant/billing/gateways/d_local.rb +61 -6
  22. data/lib/active_merchant/billing/gateways/decidir.rb +17 -1
  23. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  24. data/lib/active_merchant/billing/gateways/ebanx.rb +19 -3
  25. data/lib/active_merchant/billing/gateways/elavon.rb +6 -3
  26. data/lib/active_merchant/billing/gateways/element.rb +20 -2
  27. data/lib/active_merchant/billing/gateways/global_collect.rb +137 -32
  28. data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
  29. data/lib/active_merchant/billing/gateways/kushki.rb +7 -0
  30. data/lib/active_merchant/billing/gateways/litle.rb +93 -1
  31. data/lib/active_merchant/billing/gateways/mercado_pago.rb +3 -1
  32. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  33. data/lib/active_merchant/billing/gateways/moka.rb +24 -11
  34. data/lib/active_merchant/billing/gateways/moneris.rb +35 -8
  35. data/lib/active_merchant/billing/gateways/mundipagg.rb +8 -6
  36. data/lib/active_merchant/billing/gateways/nmi.rb +27 -8
  37. data/lib/active_merchant/billing/gateways/orbital.rb +357 -319
  38. data/lib/active_merchant/billing/gateways/pay_arc.rb +9 -7
  39. data/lib/active_merchant/billing/gateways/pay_conex.rb +3 -1
  40. data/lib/active_merchant/billing/gateways/pay_trace.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/payflow.rb +76 -6
  42. data/lib/active_merchant/billing/gateways/paymentez.rb +35 -9
  43. data/lib/active_merchant/billing/gateways/paysafe.rb +155 -34
  44. data/lib/active_merchant/billing/gateways/payu_latam.rb +31 -16
  45. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
  46. data/lib/active_merchant/billing/gateways/pin.rb +31 -4
  47. data/lib/active_merchant/billing/gateways/priority.rb +369 -0
  48. data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
  49. data/lib/active_merchant/billing/gateways/realex.rb +18 -0
  50. data/lib/active_merchant/billing/gateways/safe_charge.rb +7 -6
  51. data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
  52. data/lib/active_merchant/billing/gateways/stripe.rb +30 -8
  53. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +175 -72
  54. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +2 -1
  55. data/lib/active_merchant/billing/gateways/trust_commerce.rb +2 -1
  56. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +20 -6
  57. data/lib/active_merchant/billing/gateways/visanet_peru.rb +6 -2
  58. data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
  59. data/lib/active_merchant/billing/gateways/worldpay.rb +196 -64
  60. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  61. data/lib/active_merchant/billing/response.rb +4 -0
  62. data/lib/active_merchant/version.rb +1 -1
  63. metadata +11 -2
@@ -203,39 +203,25 @@ module ActiveMerchant #:nodoc:
203
203
  # ECP for Orbital requires $0 prenotes so ensure
204
204
  # if we are doing a force capture with a check, that
205
205
  # we do a purchase here
206
- if options[:force_capture] && payment_source.is_a?(Check) &&
207
- (options[:action_code].include?('W8') || options[:action_code].include?('W9') || options[:action_code].include?('ND'))
208
- return purchase(money, payment_source, options)
209
- end
206
+ return purchase(money, payment_source, options) if force_capture_with_echeck?(payment_source, options)
207
+
208
+ order = build_new_auth_purchase_order(AUTH_ONLY, money, payment_source, options)
210
209
 
211
- order = build_new_order_xml(AUTH_ONLY, money, payment_source, options) do |xml|
212
- add_payment_source(xml, payment_source, options)
213
- add_address(xml, payment_source, options)
214
- if @options[:customer_profiles]
215
- add_customer_data(xml, payment_source, options)
216
- add_managed_billing(xml, options)
217
- end
218
- end
219
210
  commit(order, :authorize, options[:retry_logic], options[:trace_number])
220
211
  end
221
212
 
222
- def verify(creditcard, options = {})
213
+ def verify(credit_card, options = {})
214
+ amount = options[:verify_amount] ? options[:verify_amount].to_i : default_verify_amount(credit_card)
223
215
  MultiResponse.run(:use_first_response) do |r|
224
- r.process { authorize(100, creditcard, options) }
225
- r.process(:ignore_result) { void(r.authorization) }
216
+ r.process { authorize(amount, credit_card, options) }
217
+ r.process(:ignore_result) { void(r.authorization) } unless amount == 0
226
218
  end
227
219
  end
228
220
 
229
221
  # AC – Authorization and Capture
230
222
  def purchase(money, payment_source, options = {})
231
- order = build_new_order_xml(options[:force_capture] ? FORCE_AUTH_AND_CAPTURE : AUTH_AND_CAPTURE, money, payment_source, options) do |xml|
232
- add_payment_source(xml, payment_source, options)
233
- add_address(xml, payment_source, options)
234
- if @options[:customer_profiles]
235
- add_customer_data(xml, payment_source, options)
236
- add_managed_billing(xml, options)
237
- end
238
- end
223
+ action = options[:force_capture] ? FORCE_AUTH_AND_CAPTURE : AUTH_AND_CAPTURE
224
+ order = build_new_auth_purchase_order(action, money, payment_source, options)
239
225
 
240
226
  commit(order, :purchase, options[:retry_logic], options[:trace_number])
241
227
  end
@@ -252,10 +238,11 @@ module ActiveMerchant #:nodoc:
252
238
  if payment_method.is_a?(Check)
253
239
  add_echeck(xml, payment_method, options)
254
240
  else
255
- add_refund(xml, options[:currency])
241
+ add_refund_payment_source(xml, options[:currency])
256
242
  end
257
243
  xml.tag! :CustomerRefNum, options[:customer_ref_num] if @options[:customer_profiles] && options[:profile_txn]
258
244
  end
245
+
259
246
  commit(order, :refund, options[:retry_logic], options[:trace_number])
260
247
  end
261
248
 
@@ -263,6 +250,7 @@ module ActiveMerchant #:nodoc:
263
250
  order = build_new_order_xml(REFUND, money, payment_method, options) do |xml|
264
251
  add_payment_source(xml, payment_method, options)
265
252
  end
253
+
266
254
  commit(order, :refund, options[:retry_logic], options[:trace_number])
267
255
  end
268
256
 
@@ -273,9 +261,19 @@ module ActiveMerchant #:nodoc:
273
261
  end
274
262
 
275
263
  order = build_void_request_xml(authorization, options)
264
+
276
265
  commit(order, :void, options[:retry_logic], options[:trace_number])
277
266
  end
278
267
 
268
+ def default_verify_amount(credit_card)
269
+ allow_zero_auth?(credit_card) ? 0 : 100
270
+ end
271
+
272
+ def allow_zero_auth?(credit_card)
273
+ # Discover does not support a $0.00 authorization instead use $1.00
274
+ %w(visa master american_express diners_club jcb).include?(credit_card.brand)
275
+ end
276
+
279
277
  # ==== Customer Profiles
280
278
  # :customer_ref_num should be set unless you're happy with Orbital providing one
281
279
  #
@@ -297,15 +295,15 @@ module ActiveMerchant #:nodoc:
297
295
  # 'I' - Inactive
298
296
  # 'MS' - Manual Suspend
299
297
 
300
- def add_customer_profile(creditcard, options = {})
298
+ def add_customer_profile(credit_card, options = {})
301
299
  options[:customer_profile_action] = CREATE
302
- order = build_customer_request_xml(creditcard, options)
300
+ order = build_customer_request_xml(credit_card, options)
303
301
  commit(order, :add_customer_profile)
304
302
  end
305
303
 
306
- def update_customer_profile(creditcard, options = {})
304
+ def update_customer_profile(credit_card, options = {})
307
305
  options[:customer_profile_action] = UPDATE
308
- order = build_customer_request_xml(creditcard, options)
306
+ order = build_customer_request_xml(credit_card, options)
309
307
  commit(order, :update_customer_profile)
310
308
  end
311
309
 
@@ -321,6 +319,10 @@ module ActiveMerchant #:nodoc:
321
319
  commit(order, :delete_customer_profile)
322
320
  end
323
321
 
322
+ def supports_network_tokenization?
323
+ true
324
+ end
325
+
324
326
  def supports_scrubbing?
325
327
  true
326
328
  end
@@ -337,11 +339,48 @@ module ActiveMerchant #:nodoc:
337
339
  gsub(%r((<CustomerMerchantID>).+(</CustomerMerchantID>)), '\1[FILTERED]\2').
338
340
  gsub(%r((<CustomerProfileMessage>).+(</CustomerProfileMessage>)), '\1[FILTERED]\2').
339
341
  gsub(%r((<CheckDDA>).+(</CheckDDA>)), '\1[FILTERED]\2').
340
- gsub(%r((<BCRtNum>).+(</BCRtNum>)), '\1[FILTERED]\2')
342
+ gsub(%r((<BCRtNum>).+(</BCRtNum>)), '\1[FILTERED]\2').
343
+ gsub(%r((<DigitalTokenCryptogram>).+(</DigitalTokenCryptogram>)), '\1[FILTERED]\2')
341
344
  end
342
345
 
343
346
  private
344
347
 
348
+ def force_capture_with_echeck?(payment_source, options)
349
+ return false unless options[:force_capture]
350
+ return false unless payment_source.is_a?(Check)
351
+
352
+ %w(W8 W9 ND).include?(options[:action_code])
353
+ end
354
+
355
+ #=====REFERENCE FIELDS=====
356
+
357
+ def add_customer_data(xml, credit_card, options)
358
+ add_customer_ref_num(xml, options)
359
+
360
+ return if options[:profile_txn]
361
+
362
+ xml.tag! :CustomerProfileFromOrderInd, profile_number(options) if add_profile_number?(options, credit_card)
363
+ xml.tag! :CustomerProfileOrderOverrideInd, options[:customer_profile_order_override_ind] || NO_MAPPING_TO_ORDER_DATA
364
+ end
365
+
366
+ def add_profile_number?(options, credit_card)
367
+ return true unless options[:customer_ref_num] && credit_card.nil?
368
+ end
369
+
370
+ def profile_number(options)
371
+ options[:customer_ref_num] ? USE_CUSTOMER_REF_NUM : AUTO_GENERATE
372
+ end
373
+
374
+ def add_customer_ref_num(xml, options)
375
+ xml.tag! :CustomerRefNum, options[:customer_ref_num] if options[:customer_ref_num]
376
+ end
377
+
378
+ def add_tx_ref_num(xml, authorization)
379
+ return unless authorization
380
+
381
+ xml.tag! :TxRefNum, split_authorization(authorization).first
382
+ end
383
+
345
384
  def authorization_string(*args)
346
385
  args.compact.join(';')
347
386
  end
@@ -350,21 +389,16 @@ module ActiveMerchant #:nodoc:
350
389
  authorization.split(';')
351
390
  end
352
391
 
353
- def add_customer_data(xml, creditcard, options)
354
- if options[:profile_txn]
355
- xml.tag! :CustomerRefNum, options[:customer_ref_num]
356
- else
357
- if options[:customer_ref_num]
358
- xml.tag! :CustomerProfileFromOrderInd, USE_CUSTOMER_REF_NUM if creditcard
359
- xml.tag! :CustomerRefNum, options[:customer_ref_num]
360
- else
361
- xml.tag! :CustomerProfileFromOrderInd, AUTO_GENERATE
362
- end
363
- xml.tag! :CustomerProfileOrderOverrideInd, options[:customer_profile_order_override_ind] || NO_MAPPING_TO_ORDER_DATA
364
- end
392
+ #=====DESCRIPTOR FIELDS=====
393
+
394
+ def add_soft_descriptors(xml, descriptors)
395
+ return unless descriptors
396
+
397
+ add_soft_descriptors_from_specialized_class(xml, descriptors) if descriptors.is_a?(OrbitalSoftDescriptors)
398
+ add_soft_descriptors_from_hash(xml, descriptors) if descriptors.is_a?(Hash)
365
399
  end
366
400
 
367
- def add_soft_descriptors(xml, soft_desc)
401
+ def add_soft_descriptors_from_specialized_class(xml, soft_desc)
368
402
  xml.tag! :SDMerchantName, soft_desc.merchant_name if soft_desc.merchant_name
369
403
  xml.tag! :SDProductDescription, soft_desc.product_description if soft_desc.product_description
370
404
  xml.tag! :SDMerchantCity, soft_desc.merchant_city if soft_desc.merchant_city
@@ -448,31 +482,52 @@ module ActiveMerchant #:nodoc:
448
482
  end
449
483
  end
450
484
 
451
- def add_card_indicators(xml, options)
452
- xml.tag! :CardIndicators, options[:card_indicators] if options[:card_indicators]
453
- end
485
+ #=====ADDRESS FIELDS=====
454
486
 
455
487
  def add_address(xml, payment_source, options)
456
- address = get_address(options)
457
-
458
- unless address.blank?
459
- avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s) || empty?(address[:country])
460
-
461
- if avs_supported
462
- xml.tag! :AVSzip, byte_limit(format_address_field(address[:zip]), 10)
463
- xml.tag! :AVSaddress1, byte_limit(format_address_field(address[:address1]), 30)
464
- xml.tag! :AVSaddress2, byte_limit(format_address_field(address[:address2]), 30)
465
- xml.tag! :AVScity, byte_limit(format_address_field(address[:city]), 20)
466
- xml.tag! :AVSstate, byte_limit(format_address_field(address[:state]), 2)
467
- xml.tag! :AVSphoneNum, (address[:phone] ? address[:phone].scan(/\d/).join.to_s[0..13] : nil)
468
- end
488
+ return unless (address = get_address(options))
489
+
490
+ if avs_supported?(address[:country]) || empty?(address[:country])
491
+ xml.tag! :AVSzip, byte_limit(format_address_field(address[:zip]), 10)
492
+ xml.tag! :AVSaddress1, byte_limit(format_address_field(address[:address1]), 30)
493
+ xml.tag! :AVSaddress2, byte_limit(format_address_field(address[:address2]), 30)
494
+ xml.tag! :AVScity, byte_limit(format_address_field(address[:city]), 20)
495
+ xml.tag! :AVSstate, byte_limit(format_address_field(address[:state]), 2)
496
+ xml.tag! :AVSphoneNum, (address[:phone] ? address[:phone].scan(/\d/).join.to_s[0..13] : nil)
497
+ end
469
498
 
470
- xml.tag! :AVSname, billing_name(payment_source, options)
471
- xml.tag! :AVScountryCode, (avs_supported ? byte_limit(format_address_field(address[:country]), 2) : '')
499
+ xml.tag! :AVSname, billing_name(payment_source, options)
500
+ xml.tag! :AVScountryCode, byte_limit(format_address_field(filter_unsupported_countries(address[:country])), 2)
472
501
 
473
- # Needs to come after AVScountryCode
474
- add_destination_address(xml, address) if avs_supported
475
- end
502
+ # Needs to come after AVScountryCode
503
+ add_destination_address(xml, address) if avs_supported?(address[:country]) || empty?(address[:country])
504
+ end
505
+
506
+ def add_destination_address(xml, address)
507
+ return unless address[:dest_zip]
508
+
509
+ xml.tag! :AVSDestzip, byte_limit(format_address_field(address[:dest_zip]), 10)
510
+ xml.tag! :AVSDestaddress1, byte_limit(format_address_field(address[:dest_address1]), 30)
511
+ xml.tag! :AVSDestaddress2, byte_limit(format_address_field(address[:dest_address2]), 30)
512
+ xml.tag! :AVSDestcity, byte_limit(format_address_field(address[:dest_city]), 20)
513
+ xml.tag! :AVSDeststate, byte_limit(format_address_field(address[:dest_state]), 2)
514
+ xml.tag! :AVSDestphoneNum, (address[:dest_phone] ? address[:dest_phone].scan(/\d/).join.to_s[0..13] : nil)
515
+ xml.tag! :AVSDestname, byte_limit(address[:dest_name], 30)
516
+ xml.tag! :AVSDestcountryCode, filter_unsupported_countries(address[:dest_country])
517
+ end
518
+
519
+ # For Profile requests
520
+ def add_customer_address(xml, options)
521
+ return unless (address = get_address(options))
522
+
523
+ xml.tag! :CustomerAddress1, byte_limit(format_address_field(address[:address1]), 30)
524
+ xml.tag! :CustomerAddress2, byte_limit(format_address_field(address[:address2]), 30)
525
+ xml.tag! :CustomerCity, byte_limit(format_address_field(address[:city]), 20)
526
+ xml.tag! :CustomerState, byte_limit(format_address_field(address[:state]), 2)
527
+ xml.tag! :CustomerZIP, byte_limit(format_address_field(address[:zip]), 10)
528
+ xml.tag! :CustomerEmail, byte_limit(address[:email], 50) if address[:email]
529
+ xml.tag! :CustomerPhone, (address[:phone] ? address[:phone].scan(/\d/).join.to_s : nil)
530
+ xml.tag! :CustomerCountryCode, filter_unsupported_countries(address[:country])
476
531
  end
477
532
 
478
533
  def billing_name(payment_source, options)
@@ -483,80 +538,53 @@ module ActiveMerchant #:nodoc:
483
538
  end
484
539
  end
485
540
 
486
- def add_destination_address(xml, address)
487
- if address[:dest_zip]
488
- avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:dest_country].to_s)
489
-
490
- xml.tag! :AVSDestzip, byte_limit(format_address_field(address[:dest_zip]), 10)
491
- xml.tag! :AVSDestaddress1, byte_limit(format_address_field(address[:dest_address1]), 30)
492
- xml.tag! :AVSDestaddress2, byte_limit(format_address_field(address[:dest_address2]), 30)
493
- xml.tag! :AVSDestcity, byte_limit(format_address_field(address[:dest_city]), 20)
494
- xml.tag! :AVSDeststate, byte_limit(format_address_field(address[:dest_state]), 2)
495
- xml.tag! :AVSDestphoneNum, (address[:dest_phone] ? address[:dest_phone].scan(/\d/).join.to_s[0..13] : nil)
496
-
497
- xml.tag! :AVSDestname, byte_limit(address[:dest_name], 30)
498
- xml.tag! :AVSDestcountryCode, (avs_supported ? address[:dest_country] : '')
499
- end
541
+ def avs_supported?(address)
542
+ AVS_SUPPORTED_COUNTRIES.include?(address.to_s)
500
543
  end
501
544
 
502
- # For Profile requests
503
- def add_customer_address(xml, options)
504
- address = get_address(options)
505
-
506
- unless address.blank?
507
- avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s)
508
-
509
- xml.tag! :CustomerAddress1, byte_limit(format_address_field(address[:address1]), 30)
510
- xml.tag! :CustomerAddress2, byte_limit(format_address_field(address[:address2]), 30)
511
- xml.tag! :CustomerCity, byte_limit(format_address_field(address[:city]), 20)
512
- xml.tag! :CustomerState, byte_limit(format_address_field(address[:state]), 2)
513
- xml.tag! :CustomerZIP, byte_limit(format_address_field(address[:zip]), 10)
514
- xml.tag! :CustomerEmail, byte_limit(address[:email], 50) if address[:email]
515
- xml.tag! :CustomerPhone, (address[:phone] ? address[:phone].scan(/\d/).join.to_s : nil)
516
- xml.tag! :CustomerCountryCode, (avs_supported ? address[:country] : '')
517
- end
545
+ def filter_unsupported_countries(address)
546
+ avs_supported?(address) ? address.to_s : ''
547
+ end
548
+
549
+ def get_address(options)
550
+ options[:billing_address] || options[:address]
518
551
  end
519
552
 
553
+ #=====PAYMENT SOURCE FIELDS=====
554
+
520
555
  # Payment can be done through either Credit Card or Electronic Check
521
556
  def add_payment_source(xml, payment_source, options = {})
522
- if payment_source.is_a?(Check)
523
- add_echeck(xml, payment_source, options)
524
- else
525
- add_creditcard(xml, payment_source, options[:currency])
526
- end
557
+ payment_source.is_a?(Check) ? add_echeck(xml, payment_source, options) : add_credit_card(xml, payment_source, options)
527
558
  end
528
559
 
529
- # Adds Electronic Check attributes
530
560
  def add_echeck(xml, check, options = {})
561
+ return unless check
562
+
531
563
  xml.tag! :CardBrand, 'EC'
532
- xml.tag! :CurrencyCode, currency_code(options[:currency])
533
- xml.tag! :CurrencyExponent, currency_exponents(options[:currency])
534
- unless check.nil?
564
+ add_currency_fields(xml, options[:currency])
565
+ xml.tag! :BCRtNum, check.routing_number
566
+ xml.tag! :CheckDDA, check.account_number if check.account_number
567
+ xml.tag! :BankAccountType, ACCOUNT_TYPE[check.account_type] if ACCOUNT_TYPE[check.account_type]
568
+ xml.tag! :ECPAuthMethod, options[:auth_method] if options[:auth_method]
569
+ xml.tag! :BankPmtDelv, options[:payment_delivery] || 'B'
570
+ xml.tag! :AVSname, (check&.name ? check.name[0..29] : nil) if get_address(options).blank?
571
+ end
535
572
 
536
- xml.tag! :BCRtNum, check.routing_number
537
- xml.tag! :CheckDDA, check.account_number if check.account_number
538
- xml.tag! :BankAccountType, ACCOUNT_TYPE[check.account_type] if ACCOUNT_TYPE[check.account_type]
539
- xml.tag! :ECPAuthMethod, options[:auth_method] if options[:auth_method]
573
+ def add_credit_card(xml, credit_card, options)
574
+ xml.tag! :AccountNum, credit_card.number if credit_card
575
+ xml.tag! :Exp, expiry_date(credit_card) if credit_card
576
+ add_currency_fields(xml, options[:currency])
577
+ add_verification_value(xml, credit_card) if credit_card
578
+ end
540
579
 
541
- if options[:payment_delivery]
542
- xml.tag! :BankPmtDelv, options[:payment_delivery]
543
- else
544
- xml.tag! :BankPmtDelv, 'B'
545
- end
580
+ def add_refund_payment_source(xml, currency = nil)
581
+ xml.tag! :AccountNum, nil
546
582
 
547
- xml.tag! :AVSname, (check&.name ? check.name[0..29] : nil) if get_address(options).blank?
548
- end
583
+ add_currency_fields(xml, currency)
549
584
  end
550
585
 
551
- # Adds Credit Card attributes
552
- def add_creditcard(xml, creditcard, currency = nil)
553
- unless creditcard.nil?
554
- xml.tag! :AccountNum, creditcard.number
555
- xml.tag! :Exp, expiry_date(creditcard)
556
- end
557
-
558
- xml.tag! :CurrencyCode, currency_code(currency)
559
- xml.tag! :CurrencyExponent, currency_exponents(currency)
586
+ def add_verification_value(xml, credit_card)
587
+ return unless credit_card&.verification_value?
560
588
 
561
589
  # If you are trying to collect a Card Verification Number
562
590
  # (CardSecVal) for a Visa or Discover transaction, pass one of these values:
@@ -567,123 +595,209 @@ module ActiveMerchant #:nodoc:
567
595
  # Null-fill this attribute OR
568
596
  # Do not submit the attribute at all.
569
597
  # - http://download.chasepaymentech.com/docs/orbital/orbital_gateway_xml_specification.pdf
570
- unless creditcard.nil?
571
- if creditcard.verification_value?
572
- xml.tag! :CardSecValInd, '1' if %w(visa discover).include?(creditcard.brand)
573
- xml.tag! :CardSecVal, creditcard.verification_value
574
- end
575
- end
598
+ xml.tag! :CardSecValInd, '1' if %w(visa master discover).include?(credit_card.brand)
599
+ xml.tag! :CardSecVal, credit_card.verification_value
576
600
  end
577
601
 
578
- def add_eci(xml, creditcard, three_d_secure)
579
- eci = if three_d_secure
580
- three_d_secure[:eci]
581
- elsif creditcard.is_a?(NetworkTokenizationCreditCard)
582
- creditcard.eci
583
- end
602
+ def add_currency_fields(xml, currency)
603
+ xml.tag! :CurrencyCode, currency_code(currency)
604
+ xml.tag! :CurrencyExponent, currency_exponents(currency)
605
+ end
584
606
 
585
- xml.tag!(:AuthenticationECIInd, eci) if eci
607
+ def add_card_indicators(xml, options)
608
+ xml.tag! :CardIndicators, options[:card_indicators] if options[:card_indicators]
586
609
  end
587
610
 
588
- def add_xid(xml, creditcard, three_d_secure)
589
- return unless three_d_secure && creditcard.brand == 'visa'
611
+ def currency_code(currency)
612
+ CURRENCY_CODES[(currency || self.default_currency)].to_s
613
+ end
590
614
 
591
- xml.tag!(:XID, three_d_secure[:xid]) if three_d_secure[:xid]
615
+ def currency_exponents(currency)
616
+ CURRENCY_EXPONENTS[(currency || self.default_currency)].to_s
617
+ end
618
+
619
+ def expiry_date(credit_card)
620
+ "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
621
+ end
622
+
623
+ def bin
624
+ @options[:bin] || (salem_mid? ? '000001' : '000002')
592
625
  end
593
626
 
594
- def add_cavv(xml, creditcard, three_d_secure)
595
- return unless three_d_secure && creditcard.brand == 'visa'
627
+ def salem_mid?
628
+ @options[:merchant_id].length == 6
629
+ end
630
+
631
+ #=====BRAND-SPECIFIC FIELDS=====
632
+
633
+ def add_cavv(xml, credit_card, three_d_secure)
634
+ return unless three_d_secure && credit_card.brand == 'visa'
596
635
 
597
636
  xml.tag!(:CAVV, three_d_secure[:cavv])
598
637
  end
599
638
 
600
- def add_aav(xml, creditcard, three_d_secure)
601
- return unless three_d_secure && creditcard.brand == 'master'
639
+ def add_aav(xml, credit_card, three_d_secure)
640
+ return unless three_d_secure && credit_card.brand == 'master'
602
641
 
603
642
  xml.tag!(:AAV, three_d_secure[:cavv])
604
643
  end
605
644
 
606
- def add_mc_program_protocol(xml, creditcard, three_d_secure)
607
- return unless three_d_secure && creditcard.brand == 'master'
608
- return unless three_d_secure[:version]
645
+ def add_aevv(xml, credit_card, three_d_secure)
646
+ return unless three_d_secure && credit_card.brand == 'american_express'
609
647
 
610
- truncated_version = three_d_secure[:version].to_s[0]
611
- xml.tag!(:MCProgramProtocol, truncated_version)
648
+ xml.tag!(:AEVV, three_d_secure[:cavv])
649
+ end
650
+
651
+ def add_xid(xml, credit_card, three_d_secure)
652
+ return unless three_d_secure && credit_card.brand == 'visa'
653
+
654
+ xml.tag!(:XID, three_d_secure[:xid]) if three_d_secure[:xid]
612
655
  end
613
656
 
614
- def add_mc_directory_trans_id(xml, creditcard, three_d_secure)
615
- return unless three_d_secure && creditcard.brand == 'master'
657
+ def add_pymt_brand_program_code(xml, credit_card, three_d_secure)
658
+ return unless three_d_secure && credit_card.brand == 'american_express'
659
+
660
+ xml.tag!(:PymtBrandProgramCode, 'ASK')
661
+ end
662
+
663
+ def mastercard?(payment_source)
664
+ payment_source.is_a?(CreditCard) && payment_source.brand == 'master'
665
+ end
666
+
667
+ def add_mastercard_fields(xml, credit_card, parameters, three_d_secure)
668
+ add_mc_sca_merchant_initiated(xml, credit_card, parameters, three_d_secure)
669
+ add_mc_sca_recurring(xml, credit_card, parameters, three_d_secure)
670
+ add_mc_program_protocol(xml, credit_card, three_d_secure)
671
+ add_mc_directory_trans_id(xml, credit_card, three_d_secure)
672
+ add_mc_ucafind(xml, credit_card, three_d_secure)
673
+ end
674
+
675
+ def add_mc_sca_merchant_initiated(xml, credit_card, parameters, three_d_secure)
676
+ return unless parameters.try(:[], :sca_merchant_initiated)
677
+ return unless three_d_secure.try(:[], :eci) == '7'
678
+
679
+ xml.tag!(:SCAMerchantInitiatedTransaction, parameters[:sca_merchant_initiated])
680
+ end
681
+
682
+ def add_mc_sca_recurring(xml, credit_card, parameters, three_d_secure)
683
+ return unless parameters.try(:[], :sca_recurring)
684
+ return unless three_d_secure.try(:[], :eci) == '7'
685
+
686
+ xml.tag!(:SCARecurringPayment, parameters[:sca_recurring])
687
+ end
688
+
689
+ def add_mc_program_protocol(xml, credit_card, three_d_secure)
690
+ return unless version = three_d_secure.try(:[], :version)
691
+
692
+ xml.tag!(:MCProgramProtocol, version.to_s[0])
693
+ end
694
+
695
+ def add_mc_directory_trans_id(xml, credit_card, three_d_secure)
696
+ return unless three_d_secure
616
697
 
617
698
  xml.tag!(:MCDirectoryTransID, three_d_secure[:ds_transaction_id]) if three_d_secure[:ds_transaction_id]
618
699
  end
619
700
 
620
- def add_mc_ucafind(xml, creditcard, three_d_secure)
621
- return unless three_d_secure && creditcard.brand == 'master'
701
+ def add_mc_ucafind(xml, credit_card, three_d_secure)
702
+ return unless three_d_secure
622
703
 
623
704
  xml.tag! :UCAFInd, '4'
624
705
  end
625
706
 
626
- def add_mc_scarecurring(xml, creditcard, parameters, three_d_secure)
627
- return unless parameters && parameters[:sca_recurring] && creditcard.brand == 'master'
707
+ #=====SCA (STORED CREDENTIAL) FIELDS=====
628
708
 
629
- valid_eci = three_d_secure && three_d_secure[:eci] && three_d_secure[:eci] == '7'
709
+ def add_stored_credentials(xml, parameters)
710
+ return unless parameters[:mit_stored_credential_ind] == 'Y' || parameters[:stored_credential] && !parameters[:stored_credential].values.all?(&:nil?)
630
711
 
631
- xml.tag!(:SCARecurringPayment, parameters[:sca_recurring]) if valid_eci
712
+ if msg_type = get_msg_type(parameters)
713
+ xml.tag! :MITMsgType, msg_type
714
+ end
715
+ xml.tag! :MITStoredCredentialInd, 'Y'
716
+ if parameters[:mit_submitted_transaction_id]
717
+ xml.tag! :MITSubmittedTransactionID, parameters[:mit_submitted_transaction_id]
718
+ elsif parameters.dig(:stored_credential, :network_transaction_id) && parameters.dig(:stored_credential, :initiator) == 'merchant'
719
+ xml.tag! :MITSubmittedTransactionID, parameters[:stored_credential][:network_transaction_id]
720
+ end
632
721
  end
633
722
 
634
- def add_dpanind(xml, creditcard)
635
- return unless creditcard.is_a?(NetworkTokenizationCreditCard)
723
+ def get_msg_type(parameters)
724
+ return parameters[:mit_msg_type] if parameters[:mit_msg_type]
725
+ return 'CSTO' if parameters[:stored_credential][:initial_transaction]
726
+ return unless parameters[:stored_credential][:initiator] && parameters[:stored_credential][:reason_type]
636
727
 
637
- xml.tag! :DPANInd, 'Y'
728
+ initiator =
729
+ case parameters[:stored_credential][:initiator]
730
+ when 'cardholder', 'customer' then 'C'
731
+ when 'merchant' then 'M'
732
+ end
733
+ reason =
734
+ case parameters[:stored_credential][:reason_type]
735
+ when 'recurring' then 'REC'
736
+ when 'installment' then 'INS'
737
+ when 'unscheduled' then 'USE'
738
+ end
739
+
740
+ "#{initiator}#{reason}"
638
741
  end
639
742
 
640
- def add_digital_token_cryptogram(xml, creditcard)
641
- return unless creditcard.is_a?(NetworkTokenizationCreditCard)
743
+ #=====NETWORK TOKENIZATION FIELDS=====
642
744
 
643
- xml.tag! :DigitalTokenCryptogram, creditcard.payment_cryptogram
745
+ def add_eci(xml, credit_card, three_d_secure)
746
+ eci = if three_d_secure
747
+ three_d_secure[:eci]
748
+ elsif credit_card.is_a?(NetworkTokenizationCreditCard)
749
+ credit_card.eci
750
+ end
751
+
752
+ xml.tag!(:AuthenticationECIInd, eci) if eci
644
753
  end
645
754
 
646
- def add_aevv(xml, creditcard, three_d_secure)
647
- return unless three_d_secure && creditcard.brand == 'american_express'
755
+ def add_dpanind(xml, credit_card)
756
+ return unless credit_card.is_a?(NetworkTokenizationCreditCard)
648
757
 
649
- xml.tag!(:AEVV, three_d_secure[:cavv])
758
+ xml.tag! :DPANInd, 'Y'
650
759
  end
651
760
 
652
- def add_pymt_brand_program_code(xml, creditcard, three_d_secure)
653
- return unless three_d_secure && creditcard.brand == 'american_express'
761
+ def add_digital_token_cryptogram(xml, credit_card)
762
+ return unless credit_card.is_a?(NetworkTokenizationCreditCard)
654
763
 
655
- xml.tag!(:PymtBrandProgramCode, 'ASK')
764
+ xml.tag! :DigitalTokenCryptogram, credit_card.payment_cryptogram
656
765
  end
657
766
 
658
- def add_refund(xml, currency = nil)
659
- xml.tag! :AccountNum, nil
767
+ #=====OTHER FIELDS=====
660
768
 
661
- xml.tag! :CurrencyCode, currency_code(currency)
662
- xml.tag! :CurrencyExponent, currency_exponents(currency)
769
+ # For Canadian transactions on PNS Tampa on New Order
770
+ # RF - First Recurring Transaction
771
+ # RS - Subsequent Recurring Transactions
772
+ def set_recurring_ind(xml, parameters)
773
+ return unless parameters[:recurring_ind]
774
+ raise 'RecurringInd must be set to either "RF" or "RS"' unless %w(RF RS).include?(parameters[:recurring_ind])
775
+
776
+ xml.tag! :RecurringInd, parameters[:recurring_ind]
663
777
  end
664
778
 
665
779
  def add_managed_billing(xml, options)
666
- if mb = options[:managed_billing]
667
- ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
668
-
669
- # default to recurring (R). Other option is deferred (D).
670
- xml.tag! :MBType, mb[:type] || RECURRING
671
- # default to Customer Reference Number
672
- xml.tag! :MBOrderIdGenerationMethod, mb[:order_id_generation_method] || 'IO'
673
- # By default use MBRecurringEndDate, set to N.
674
- # MMDDYYYY
675
- xml.tag! :MBRecurringStartDate, mb[:start_date].scan(/\d/).join.to_s if mb[:start_date]
676
- # MMDDYYYY
677
- xml.tag! :MBRecurringEndDate, mb[:end_date].scan(/\d/).join.to_s if mb[:end_date]
678
- # By default listen to any value set in MBRecurringEndDate.
679
- xml.tag! :MBRecurringNoEndDateFlag, mb[:no_end_date_flag] || 'N' # 'Y' || 'N' (Yes or No).
680
- xml.tag! :MBRecurringMaxBillings, mb[:max_billings] if mb[:max_billings]
681
- xml.tag! :MBRecurringFrequency, mb[:frequency] if mb[:frequency]
682
- xml.tag! :MBDeferredBillDate, mb[:deferred_bill_date] if mb[:deferred_bill_date]
683
- xml.tag! :MBMicroPaymentMaxDollarValue, mb[:max_dollar_value] if mb[:max_dollar_value]
684
- xml.tag! :MBMicroPaymentMaxBillingDays, mb[:max_billing_days] if mb[:max_billing_days]
685
- xml.tag! :MBMicroPaymentMaxTransactions, mb[:max_transactions] if mb[:max_transactions]
686
- end
780
+ return unless mb = options[:managed_billing]
781
+
782
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
783
+
784
+ # default to recurring (R). Other option is deferred (D).
785
+ xml.tag! :MBType, mb[:type] || RECURRING
786
+ # default to Customer Reference Number
787
+ xml.tag! :MBOrderIdGenerationMethod, mb[:order_id_generation_method] || 'IO'
788
+ # By default use MBRecurringEndDate, set to N.
789
+ # MMDDYYYY
790
+ xml.tag! :MBRecurringStartDate, mb[:start_date].scan(/\d/).join.to_s if mb[:start_date]
791
+ # MMDDYYYY
792
+ xml.tag! :MBRecurringEndDate, mb[:end_date].scan(/\d/).join.to_s if mb[:end_date]
793
+ # By default listen to any value set in MBRecurringEndDate.
794
+ xml.tag! :MBRecurringNoEndDateFlag, mb[:no_end_date_flag] || 'N' # 'Y' || 'N' (Yes or No).
795
+ xml.tag! :MBRecurringMaxBillings, mb[:max_billings] if mb[:max_billings]
796
+ xml.tag! :MBRecurringFrequency, mb[:frequency] if mb[:frequency]
797
+ xml.tag! :MBDeferredBillDate, mb[:deferred_bill_date] if mb[:deferred_bill_date]
798
+ xml.tag! :MBMicroPaymentMaxDollarValue, mb[:max_dollar_value] if mb[:max_dollar_value]
799
+ xml.tag! :MBMicroPaymentMaxBillingDays, mb[:max_billing_days] if mb[:max_billing_days]
800
+ xml.tag! :MBMicroPaymentMaxTransactions, mb[:max_transactions] if mb[:max_transactions]
687
801
  end
688
802
 
689
803
  def add_ews_details(xml, payment_source, parameters = {})
@@ -722,61 +836,20 @@ module ActiveMerchant #:nodoc:
722
836
  end
723
837
  end
724
838
 
725
- def add_stored_credentials(xml, parameters)
726
- return unless parameters[:mit_stored_credential_ind] == 'Y' || parameters[:stored_credential] && !parameters[:stored_credential].values.all?(&:nil?)
727
-
728
- if msg_type = get_msg_type(parameters)
729
- xml.tag! :MITMsgType, msg_type
730
- end
731
- xml.tag! :MITStoredCredentialInd, 'Y'
732
- if parameters[:mit_submitted_transaction_id]
733
- xml.tag! :MITSubmittedTransactionID, parameters[:mit_submitted_transaction_id]
734
- elsif parameters.dig(:stored_credential, :network_transaction_id) && parameters.dig(:stored_credential, :initiator) == 'merchant'
735
- xml.tag! :MITSubmittedTransactionID, parameters[:stored_credential][:network_transaction_id]
839
+ def add_xml_credentials(xml)
840
+ unless ip_authentication?
841
+ xml.tag! :OrbitalConnectionUsername, @options[:login]
842
+ xml.tag! :OrbitalConnectionPassword, @options[:password]
736
843
  end
737
844
  end
738
845
 
739
- def get_msg_type(parameters)
740
- return parameters[:mit_msg_type] if parameters[:mit_msg_type]
741
- return 'CSTO' if parameters[:stored_credential][:initial_transaction]
742
- return unless parameters[:stored_credential][:initiator] && parameters[:stored_credential][:reason_type]
743
-
744
- initiator =
745
- case parameters[:stored_credential][:initiator]
746
- when 'cardholder', 'customer' then 'C'
747
- when 'merchant' then 'M'
748
- end
749
- reason =
750
- case parameters[:stored_credential][:reason_type]
751
- when 'recurring' then 'REC'
752
- when 'installment' then 'INS'
753
- when 'unscheduled' then 'USE'
754
- end
755
-
756
- "#{initiator}#{reason}"
757
- end
758
-
759
- def parse(body)
760
- response = {}
761
- xml = REXML::Document.new(strip_invalid_xml_chars(body))
762
- root = REXML::XPath.first(xml, '//Response') ||
763
- REXML::XPath.first(xml, '//ErrorResponse')
764
- if root
765
- root.elements.to_a.each do |node|
766
- recurring_parse_element(response, node)
767
- end
768
- end
769
-
770
- response.delete_if { |k, _| SENSITIVE_FIELDS.include?(k) }
846
+ def add_bin_merchant_and_terminal(xml, parameters)
847
+ xml.tag! :BIN, bin
848
+ xml.tag! :MerchantID, @options[:merchant_id]
849
+ xml.tag! :TerminalID, parameters[:terminal_id] || '001'
771
850
  end
772
851
 
773
- def recurring_parse_element(response, node)
774
- if node.has_elements?
775
- node.elements.each { |e| recurring_parse_element(response, e) }
776
- else
777
- response[node.name.underscore.to_sym] = node.text
778
- end
779
- end
852
+ #=====REQUEST/RESPONSE METHODS=====
780
853
 
781
854
  def commit(order, message_type, retry_logic = nil, trace_number = nil)
782
855
  headers = POST_HEADERS.merge('Content-length' => order.size.to_s)
@@ -811,6 +884,28 @@ module ActiveMerchant #:nodoc:
811
884
  end
812
885
  end
813
886
 
887
+ def parse(body)
888
+ response = {}
889
+ xml = REXML::Document.new(strip_invalid_xml_chars(body))
890
+ root = REXML::XPath.first(xml, '//Response') ||
891
+ REXML::XPath.first(xml, '//ErrorResponse')
892
+ if root
893
+ root.elements.to_a.each do |node|
894
+ recurring_parse_element(response, node)
895
+ end
896
+ end
897
+
898
+ response.delete_if { |k, _| SENSITIVE_FIELDS.include?(k) }
899
+ end
900
+
901
+ def recurring_parse_element(response, node)
902
+ if node.has_elements?
903
+ node.elements.each { |e| recurring_parse_element(response, e) }
904
+ else
905
+ response[node.name.underscore.to_sym] = node.text
906
+ end
907
+ end
908
+
814
909
  def success?(response, message_type)
815
910
  if %i[void].include?(message_type)
816
911
  response[:proc_status] == SUCCESS
@@ -832,24 +927,26 @@ module ActiveMerchant #:nodoc:
832
927
  @options[:ip_authentication] == true
833
928
  end
834
929
 
930
+ #=====BUILDER METHODS=====
931
+
932
+ def build_new_auth_purchase_order(action, money, payment_source, options)
933
+ build_new_order_xml(action, money, payment_source, options) do |xml|
934
+ add_payment_source(xml, payment_source, options)
935
+ add_address(xml, payment_source, options)
936
+ if @options[:customer_profiles]
937
+ add_customer_data(xml, payment_source, options)
938
+ add_managed_billing(xml, options)
939
+ end
940
+ end
941
+ end
942
+
835
943
  def build_new_order_xml(action, money, payment_source, parameters = {})
836
944
  requires!(parameters, :order_id)
837
945
  xml = xml_envelope
838
946
  xml.tag! :Request do
839
947
  xml.tag! :NewOrder do
840
948
  add_xml_credentials(xml)
841
- # EC - Ecommerce transaction
842
- # RC - Recurring Payment transaction
843
- # MO - Mail Order Telephone Order transaction
844
- # IV - Interactive Voice Response
845
- # IN - Interactive Voice Response
846
949
  xml.tag! :IndustryType, parameters[:industry_type] || ECOMMERCE_TRANSACTION
847
- # A - Auth Only No Capture
848
- # AC - Auth and Capture
849
- # F - Force Auth No Capture and no online authorization
850
- # FR - Force Auth No Capture and no online authorization
851
- # FC - Force Auth and Capture no online authorization
852
- # R - Refund and Capture no online authorization
853
950
  xml.tag! :MessageType, action
854
951
  add_bin_merchant_and_terminal(xml, parameters)
855
952
 
@@ -871,12 +968,7 @@ module ActiveMerchant #:nodoc:
871
968
  add_aav(xml, payment_source, three_d_secure)
872
969
  # CustomerAni, AVSPhoneType and AVSDestPhoneType could be added here.
873
970
 
874
- if parameters[:soft_descriptors].is_a?(OrbitalSoftDescriptors)
875
- add_soft_descriptors(xml, parameters[:soft_descriptors])
876
- elsif parameters[:soft_descriptors].is_a?(Hash)
877
- add_soft_descriptors_from_hash(xml, parameters[:soft_descriptors])
878
- end
879
-
971
+ add_soft_descriptors(xml, parameters[:soft_descriptors])
880
972
  add_dpanind(xml, payment_source)
881
973
  add_aevv(xml, payment_source, three_d_secure)
882
974
  add_digital_token_cryptogram(xml, payment_source)
@@ -886,10 +978,7 @@ module ActiveMerchant #:nodoc:
886
978
  set_recurring_ind(xml, parameters)
887
979
 
888
980
  # Append Transaction Reference Number at the end for Refund transactions
889
- if action == REFUND && parameters[:authorization]
890
- tx_ref_num, = split_authorization(parameters[:authorization])
891
- xml.tag! :TxRefNum, tx_ref_num
892
- end
981
+ add_tx_ref_num(xml, parameters[:authorization]) if action == REFUND
893
982
 
894
983
  add_level2_purchase(xml, parameters)
895
984
  add_level3_purchase(xml, parameters)
@@ -899,26 +988,12 @@ module ActiveMerchant #:nodoc:
899
988
  add_card_indicators(xml, parameters)
900
989
  add_stored_credentials(xml, parameters)
901
990
  add_pymt_brand_program_code(xml, payment_source, three_d_secure)
902
- add_mc_scarecurring(xml, payment_source, parameters, three_d_secure)
903
- add_mc_program_protocol(xml, payment_source, three_d_secure)
904
- add_mc_directory_trans_id(xml, payment_source, three_d_secure)
905
- add_mc_ucafind(xml, payment_source, three_d_secure)
991
+ add_mastercard_fields(xml, payment_source, parameters, three_d_secure) if mastercard?(payment_source)
906
992
  end
907
993
  end
908
994
  xml.target!
909
995
  end
910
996
 
911
- # For Canadian transactions on PNS Tampa on New Order
912
- # RF - First Recurring Transaction
913
- # RS - Subsequent Recurring Transactions
914
- def set_recurring_ind(xml, parameters)
915
- if parameters[:recurring_ind]
916
- raise 'RecurringInd must be set to either "RF" or "RS"' unless %w(RF RS).include?(parameters[:recurring_ind])
917
-
918
- xml.tag! :RecurringInd, parameters[:recurring_ind]
919
- end
920
- end
921
-
922
997
  def build_mark_for_capture_xml(money, authorization, parameters = {})
923
998
  tx_ref_num, order_id = split_authorization(authorization)
924
999
  xml = xml_envelope
@@ -958,49 +1033,12 @@ module ActiveMerchant #:nodoc:
958
1033
  xml.target!
959
1034
  end
960
1035
 
961
- def currency_code(currency)
962
- CURRENCY_CODES[(currency || self.default_currency)].to_s
963
- end
964
-
965
- def currency_exponents(currency)
966
- CURRENCY_EXPONENTS[(currency || self.default_currency)].to_s
967
- end
968
-
969
- def expiry_date(credit_card)
970
- "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
971
- end
972
-
973
- def bin
974
- @options[:bin] || (salem_mid? ? '000001' : '000002')
975
- end
976
-
977
1036
  def xml_envelope
978
1037
  xml = Builder::XmlMarkup.new(indent: 2)
979
1038
  xml.instruct!(:xml, version: '1.0', encoding: 'UTF-8')
980
1039
  xml
981
1040
  end
982
1041
 
983
- def add_xml_credentials(xml)
984
- unless ip_authentication?
985
- xml.tag! :OrbitalConnectionUsername, @options[:login]
986
- xml.tag! :OrbitalConnectionPassword, @options[:password]
987
- end
988
- end
989
-
990
- def add_bin_merchant_and_terminal(xml, parameters)
991
- xml.tag! :BIN, bin
992
- xml.tag! :MerchantID, @options[:merchant_id]
993
- xml.tag! :TerminalID, parameters[:terminal_id] || '001'
994
- end
995
-
996
- def salem_mid?
997
- @options[:merchant_id].length == 6
998
- end
999
-
1000
- def get_address(options)
1001
- options[:billing_address] || options[:address]
1002
- end
1003
-
1004
1042
  # Null characters are possible in some responses (namely, the respMsg field), causing XML parsing errors
1005
1043
  # Prevent by substituting these with a valid placeholder string
1006
1044
  def strip_invalid_xml_chars(xml)
@@ -1040,7 +1078,7 @@ module ActiveMerchant #:nodoc:
1040
1078
  limited_value
1041
1079
  end
1042
1080
 
1043
- def build_customer_request_xml(creditcard, options = {})
1081
+ def build_customer_request_xml(credit_card, options = {})
1044
1082
  ActiveMerchant.deprecated 'Customer Profile support in Orbital is non-conformant to the ActiveMerchant API and will be removed in its current form in a future version. Please contact the ActiveMerchant maintainers if you have an interest in modifying it to conform to the store/unstore/update API.'
1045
1083
  xml = xml_envelope
1046
1084
  xml.tag! :Request do
@@ -1049,7 +1087,7 @@ module ActiveMerchant #:nodoc:
1049
1087
  xml.tag! :OrbitalConnectionPassword, @options[:password] unless ip_authentication?
1050
1088
  xml.tag! :CustomerBin, bin
1051
1089
  xml.tag! :CustomerMerchantID, @options[:merchant_id]
1052
- xml.tag! :CustomerName, creditcard.name if creditcard
1090
+ xml.tag! :CustomerName, credit_card.name if credit_card
1053
1091
  xml.tag! :CustomerRefNum, options[:customer_ref_num] if options[:customer_ref_num]
1054
1092
 
1055
1093
  add_customer_address(xml, options)
@@ -1077,8 +1115,8 @@ module ActiveMerchant #:nodoc:
1077
1115
  xml.tag! :Status, options[:status] || ACTIVE # Active
1078
1116
  end
1079
1117
 
1080
- xml.tag! :CCAccountNum, creditcard.number if creditcard
1081
- xml.tag! :CCExpireDate, creditcard.expiry_date.expiration.strftime('%m%y') if creditcard
1118
+ xml.tag! :CCAccountNum, credit_card.number if credit_card
1119
+ xml.tag! :CCExpireDate, credit_card.expiry_date.expiration.strftime('%m%y') if credit_card
1082
1120
 
1083
1121
  # This has to come after CCExpireDate.
1084
1122
  add_managed_billing(xml, options)