activemerchant 1.29.1 → 1.33.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 (92) hide show
  1. data/CHANGELOG +137 -0
  2. data/CONTRIBUTORS +43 -0
  3. data/README.md +59 -51
  4. data/lib/active_merchant/billing/check.rb +15 -14
  5. data/lib/active_merchant/billing/credit_card.rb +9 -5
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +8 -8
  7. data/lib/active_merchant/billing/gateway.rb +2 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +36 -8
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +17 -5
  10. data/lib/active_merchant/billing/gateways/balanced.rb +9 -3
  11. data/lib/active_merchant/billing/gateways/banwire.rb +15 -1
  12. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +8 -1
  13. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -2
  14. data/lib/active_merchant/billing/gateways/beanstream.rb +26 -24
  15. data/lib/active_merchant/billing/gateways/blue_pay.rb +201 -185
  16. data/lib/active_merchant/billing/gateways/bogus.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/braintree_blue.rb +6 -2
  18. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +155 -0
  19. data/lib/active_merchant/billing/gateways/cc5.rb +156 -0
  20. data/lib/active_merchant/billing/gateways/cyber_source.rb +55 -22
  21. data/lib/active_merchant/billing/gateways/data_cash.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  23. data/lib/active_merchant/billing/gateways/eway.rb +114 -171
  24. data/lib/active_merchant/billing/gateways/eway_managed.rb +52 -22
  25. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  26. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +314 -0
  27. data/lib/active_merchant/billing/gateways/garanti.rb +0 -4
  28. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +13 -2
  29. data/lib/active_merchant/billing/gateways/iridium.rb +8 -2
  30. data/lib/active_merchant/billing/gateways/litle.rb +354 -105
  31. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +27 -6
  32. data/lib/active_merchant/billing/gateways/merchant_ware.rb +44 -9
  33. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +190 -0
  34. data/lib/active_merchant/billing/gateways/moneris.rb +3 -5
  35. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -1
  36. data/lib/active_merchant/billing/gateways/nab_transact.rb +20 -3
  37. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  38. data/lib/active_merchant/billing/gateways/netaxept.rb +65 -117
  39. data/lib/active_merchant/billing/gateways/netbilling.rb +1 -0
  40. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  41. data/lib/active_merchant/billing/gateways/ogone.rb +7 -5
  42. data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -18
  43. data/lib/active_merchant/billing/gateways/orbital.rb +190 -53
  44. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +14 -11
  45. data/lib/active_merchant/billing/gateways/payment_express.rb +62 -1
  46. data/lib/active_merchant/billing/gateways/paymill.rb +179 -0
  47. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +12 -7
  48. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +14 -9
  49. data/lib/active_merchant/billing/gateways/paypal_express.rb +42 -18
  50. data/lib/active_merchant/billing/gateways/pin.rb +165 -0
  51. data/lib/active_merchant/billing/gateways/qbms.rb +3 -2
  52. data/lib/active_merchant/billing/gateways/quickpay.rb +66 -28
  53. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +16 -11
  54. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +1 -1
  55. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +21 -16
  56. data/lib/active_merchant/billing/gateways/sage.rb +10 -5
  57. data/lib/active_merchant/billing/gateways/sage_pay.rb +7 -0
  58. data/lib/active_merchant/billing/gateways/smart_ps.rb +1 -1
  59. data/lib/active_merchant/billing/gateways/spreedly_core.rb +233 -0
  60. data/lib/active_merchant/billing/gateways/stripe.rb +25 -11
  61. data/lib/active_merchant/billing/gateways/transnational.rb +239 -0
  62. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -4
  63. data/lib/active_merchant/billing/gateways/webpay.rb +8 -0
  64. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -9
  65. data/lib/active_merchant/billing/gateways/worldpay.rb +60 -24
  66. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +1 -1
  67. data/lib/active_merchant/billing/integrations/direc_pay.rb +1 -1
  68. data/lib/active_merchant/billing/integrations/dwolla/common.rb +21 -0
  69. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +15 -6
  70. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +11 -6
  71. data/lib/active_merchant/billing/integrations/dwolla/return.rb +12 -4
  72. data/lib/active_merchant/billing/integrations/dwolla.rb +5 -12
  73. data/lib/active_merchant/billing/integrations/notification.rb +13 -8
  74. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +19 -3
  75. data/lib/active_merchant/billing/integrations/paypal/notification.rb +39 -31
  76. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +74 -0
  77. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +167 -0
  78. data/lib/active_merchant/billing/integrations/payu_in/return.rb +53 -0
  79. data/lib/active_merchant/billing/integrations/payu_in.rb +43 -0
  80. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +1 -0
  81. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +13 -10
  82. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +78 -15
  83. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +23 -0
  84. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +91 -0
  85. data/lib/active_merchant/billing/integrations/rbkmoney.rb +17 -0
  86. data/lib/active_merchant/billing/integrations/robokassa/common.rb +1 -1
  87. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +7 -3
  88. data/lib/active_merchant/billing/integrations/world_pay.rb +15 -8
  89. data/lib/active_merchant/version.rb +1 -1
  90. data.tar.gz.sig +0 -0
  91. metadata +124 -50
  92. metadata.gz.sig +0 -0
@@ -0,0 +1,155 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CardStreamModernGateway < Gateway
4
+ self.test_url = self.live_url = 'https://gateway.cardstream.com/direct/'
5
+ self.money_format = :cents
6
+ self.default_currency = 'GBP'
7
+ self.supported_countries = ['GB']
8
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch]
9
+ self.homepage_url = 'http://www.cardstream.com/'
10
+ self.display_name = 'CardStream'
11
+
12
+ def initialize(options = {})
13
+ requires!(options, :login)
14
+ if(options[:threeDSRequired])
15
+ @threeDSRequired = options[:threeDSRequired]
16
+ else
17
+ @threeDSRequired = 'N'
18
+ end
19
+ super
20
+ end
21
+
22
+ def authorize(money, creditcard, options = {})
23
+ post = {}
24
+ add_amount(post, money, options)
25
+ add_invoice(post, creditcard, money, options)
26
+ add_creditcard(post, creditcard)
27
+ add_address(post, creditcard, options)
28
+ add_customer_data(post, options)
29
+ commit('PREAUTH', post)
30
+ end
31
+
32
+ def purchase(money, creditcard, options = {})
33
+ post = {}
34
+ add_amount(post, money, options)
35
+ add_invoice(post, creditcard, money, options)
36
+ add_creditcard(post, creditcard)
37
+ add_address(post, creditcard, options)
38
+ add_customer_data(post, options)
39
+ commit('SALE', post)
40
+ end
41
+
42
+ def capture(money, authorization, options = {})
43
+ post = {}
44
+ add_pair(post, :xref, authorization)
45
+ add_amount(post, money, options)
46
+ commit('SALE', post)
47
+ end
48
+
49
+ def refund(money, authorization, options = {})
50
+ post = {}
51
+ add_pair(post, :xref, authorization)
52
+ add_amount(post, money, options)
53
+ commit('REFUND', post)
54
+ end
55
+
56
+ def void(authorization, options = {})
57
+ post = {}
58
+ add_pair(post, :xref, authorization)
59
+ commit('REFUND', post)
60
+ end
61
+
62
+ private
63
+
64
+ def add_amount(post, money, options)
65
+ add_pair(post, :amount, amount(money), :required => true)
66
+ add_pair(post, :currencyCode, options[:currency] || self.default_currency)
67
+ end
68
+
69
+ def add_customer_data(post, options)
70
+ address = options[:billing_address] || options[:address]
71
+ add_pair(post, :customerPostCode, address[:zip])
72
+ add_pair(post, :customerEmail, options[:email])
73
+ add_pair(post, :customerPhone, options[:phone])
74
+ end
75
+
76
+ def add_address(post, creditcard, options)
77
+ address = options[:billing_address] || options[:address]
78
+
79
+ return if address.nil?
80
+
81
+ add_pair(post, :customerAddress, address[:address1] + " " + (address[:address2].nil? ? "" : address[:address2]) )
82
+ add_pair(post, :customerPostCode, address[:zip])
83
+ end
84
+
85
+ def add_invoice(post, credit_card, money, options)
86
+ add_pair(post, :transactionUnique, options[:order_id], :required => true)
87
+ add_pair(post, :orderRef, options[:description] || options[:order_id], :required => true)
88
+ if [ 'american_express', 'diners_club' ].include?(card_brand(credit_card).to_s)
89
+ add_pair(post, :item1Quantity, 1)
90
+ add_pair(post, :item1Description, (options[:description] || options[:order_id]).slice(0, 15))
91
+ add_pair(post, :item1GrossValue, amount(money))
92
+ end
93
+ end
94
+
95
+ def add_creditcard(post, credit_card)
96
+ add_pair(post, :customerName, credit_card.name, :required => true)
97
+ add_pair(post, :cardNumber, credit_card.number, :required => true)
98
+
99
+ add_pair(post, :cardExpiryMonth, format(credit_card.month, :two_digits), :required => true)
100
+ add_pair(post, :cardExpiryYear, format(credit_card.year, :two_digits), :required => true)
101
+
102
+ if requires_start_date_or_issue_number?(credit_card)
103
+ add_pair(post, :cardStartMonth, format(credit_card.start_month, :two_digits))
104
+ add_pair(post, :cardStartYear, format(credit_card.start_year, :two_digits))
105
+
106
+ add_pair(post, :cardIssueNumber, credit_card.issue_number)
107
+ end
108
+
109
+ add_pair(post, :cardCVV, credit_card.verification_value)
110
+ end
111
+
112
+ def parse(body)
113
+ result = {}
114
+ pairs = body.split("&")
115
+ pairs.each do |pair|
116
+ a = pair.split("=")
117
+ result[a[0].to_sym] = CGI.unescape(a[1])
118
+ end
119
+ result
120
+ end
121
+
122
+ def commit(action, parameters)
123
+ response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
124
+
125
+ Response.new(response[:responseCode] == "0",
126
+ response[:responseCode] == "0" ? "APPROVED" : response[:responseMessage],
127
+ response,
128
+ :test => test?,
129
+ :authorization => response[:xref],
130
+ :avs_result => {
131
+ :street_match => response[:addressCheck],
132
+ :postal_match => response[:postcodeCheck],
133
+ },
134
+ :cvv_result => response[:cv2Check]
135
+ )
136
+ end
137
+
138
+ def post_data(action, parameters = {})
139
+ parameters.update(
140
+ :merchantID => @options[:login],
141
+ :action => action,
142
+ :type => '1', #Ecommerce
143
+ :countryCode => self.supported_countries[0],
144
+ :threeDSRequired => @threeDSRequired #Disable 3d secure by default
145
+ )
146
+ parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
147
+ end
148
+
149
+ def add_pair(post, key, value, options = {})
150
+ post[key] = value if !value.blank? || options[:required]
151
+ end
152
+ end
153
+ end
154
+ end
155
+
@@ -0,0 +1,156 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # CC5 API is used by many banks in Turkey. Extend this base class to provide
4
+ # concrete implementations.
5
+ class CC5Gateway < Gateway
6
+ self.default_currency = 'TRY'
7
+
8
+ CURRENCY_CODES = {
9
+ 'TRY' => 949,
10
+ 'YTL' => 949,
11
+ 'TRL' => 949,
12
+ 'TL' => 949,
13
+ 'USD' => 840,
14
+ 'EUR' => 978,
15
+ 'GBP' => 826,
16
+ 'JPY' => 392
17
+ }
18
+
19
+ def initialize(options = {})
20
+ requires!(options, :login, :password, :client_id)
21
+ super
22
+ end
23
+
24
+ def purchase(money, creditcard, options = {})
25
+ commit(build_sale_request('Auth', money, creditcard, options))
26
+ end
27
+
28
+ def authorize(money, creditcard, options = {})
29
+ commit(build_sale_request('PreAuth', money, creditcard, options))
30
+ end
31
+
32
+ def capture(money, authorization, options = {})
33
+ commit(build_capture_request(money, authorization, options))
34
+ end
35
+
36
+ protected
37
+
38
+ def build_sale_request(type, money, creditcard, options = {})
39
+ requires!(options, :order_id)
40
+
41
+ xml = Builder::XmlMarkup.new :indent => 2
42
+
43
+ xml.tag! 'CC5Request' do
44
+ add_login_tags(xml)
45
+ xml.tag! 'OrderId', options[:order_id]
46
+ xml.tag! 'Type', type
47
+ xml.tag! 'Number', creditcard.number
48
+ xml.tag! 'Expires', [format(creditcard.month, :two_digits), format(creditcard.year, :two_digits)].join('/')
49
+ xml.tag! 'Cvv2Val', creditcard.verification_value
50
+ add_amount_tags(money, options, xml)
51
+ xml.tag! 'Email', options[:email] if options[:email]
52
+
53
+ if(address = (options[:billing_address] || options[:address]))
54
+ xml.tag! 'BillTo' do
55
+ add_address(xml, address)
56
+ end
57
+ xml.tag! 'ShipTo' do
58
+ add_address(xml, address)
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ xml.target!
65
+ end
66
+
67
+ def build_capture_request(money, authorization, options = {})
68
+ xml = Builder::XmlMarkup.new :indent => 2
69
+
70
+ xml.tag! 'CC5Request' do
71
+ add_login_tags(xml)
72
+ xml.tag! 'OrderId', authorization
73
+ xml.tag! 'Type', 'PostAuth'
74
+ add_amount_tags(money, options, xml)
75
+ end
76
+ end
77
+
78
+ def add_address(xml, address)
79
+ xml.tag! 'Name', normalize(address[:name])
80
+ xml.tag! 'Street1', normalize(address[:address1])
81
+ xml.tag! 'Street2', normalize(address[:address2]) if address[:address2]
82
+ xml.tag! 'City', normalize(address[:city])
83
+ xml.tag! 'PostalCode', address[:zip]
84
+ xml.tag! 'Country', normalize(address[:country])
85
+ xml.tag! 'Company', normalize(address[:company])
86
+ xml.tag! 'TelVoice', address[:phone].to_s.gsub(/[^0-9]/, '') if address[:phone]
87
+ end
88
+
89
+ def add_login_tags(xml)
90
+ xml.tag! 'Name', @options[:login]
91
+ xml.tag! 'Password', @options[:password]
92
+ xml.tag! 'ClientId', @options[:client_id]
93
+ xml.tag! 'Mode', (test? ? 'T' : 'P')
94
+ end
95
+
96
+ def add_amount_tags(money, options, xml)
97
+ xml.tag! 'Total', amount(money)
98
+ xml.tag! 'Currency', currency_code(options[:currency] || currency(money))
99
+ end
100
+
101
+ def currency_code(currency)
102
+ (CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency])
103
+ end
104
+
105
+ def commit(request)
106
+ raw_response = ssl_post((test? ? self.test_url : self.live_url), "DATA=" + request)
107
+
108
+ response = parse(raw_response)
109
+
110
+ success = success?(response)
111
+
112
+ Response.new(
113
+ success,
114
+ (success ? 'Approved' : "Declined (Reason: #{response[:proc_return_code]} - #{response[:err_msg]})"),
115
+ response,
116
+ :test => test?,
117
+ :authorization => response[:order_id]
118
+ )
119
+ end
120
+
121
+ def parse(body)
122
+ xml = REXML::Document.new(body)
123
+
124
+ response = {}
125
+ xml.root.elements.to_a.each do |node|
126
+ parse_element(response, node)
127
+ end
128
+ response
129
+ end
130
+
131
+ def parse_element(response, node)
132
+ if node.has_elements?
133
+ node.elements.each{|element| parse_element(response, element) }
134
+ else
135
+ response[node.name.underscore.to_sym] = node.text
136
+ end
137
+ end
138
+
139
+ def success?(response)
140
+ (response[:response] == "Approved")
141
+ end
142
+
143
+ def normalize(text)
144
+ return unless text
145
+
146
+ if ActiveSupport::Inflector.method(:transliterate).arity == -2
147
+ ActiveSupport::Inflector.transliterate(text,'')
148
+ elsif RUBY_VERSION >= '1.9'
149
+ text.gsub(/[^\x00-\x7F]+/, '')
150
+ else
151
+ ActiveSupport::Inflector.transliterate(text).to_s
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
@@ -13,6 +13,7 @@ module ActiveMerchant #:nodoc:
13
13
  # names.
14
14
  #
15
15
  # Important Notes
16
+ # * For checks you can purchase and store.
16
17
  # * AVS and CVV only work against the production server. You will always
17
18
  # get back X for AVS and no response for CVV against the test server.
18
19
  # * Nexus is the list of states or provinces where you have a physical
@@ -131,10 +132,10 @@ module ActiveMerchant #:nodoc:
131
132
 
132
133
  # Purchase is an auth followed by a capture
133
134
  # You must supply an order_id in the options hash
134
- def purchase(money, creditcard_or_reference, options = {})
135
+ def purchase(money, payment_method_or_reference, options = {})
135
136
  requires!(options, :order_id)
136
137
  setup_address_hash(options)
137
- commit(build_purchase_request(money, creditcard_or_reference, options), options)
138
+ commit(build_purchase_request(money, payment_method_or_reference, options), options)
138
139
  end
139
140
 
140
141
  def void(identification, options = {})
@@ -154,10 +155,10 @@ module ActiveMerchant #:nodoc:
154
155
  # Stores a customer subscription/profile with type "on-demand".
155
156
  # To charge the card while creating a profile, pass
156
157
  # options[:setup_fee] => money
157
- def store(creditcard, options = {})
158
+ def store(payment_method, options = {})
158
159
  requires!(options, :order_id)
159
160
  setup_address_hash(options)
160
- commit(build_create_subscription_request(creditcard, options), options)
161
+ commit(build_create_subscription_request(payment_method, options), options)
161
162
  end
162
163
 
163
164
  # Updates a customer subscription/profile
@@ -222,7 +223,7 @@ module ActiveMerchant #:nodoc:
222
223
 
223
224
  def build_auth_request(money, creditcard_or_reference, options)
224
225
  xml = Builder::XmlMarkup.new :indent => 2
225
- add_creditcard_or_subscription(xml, money, creditcard_or_reference, options)
226
+ add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
226
227
  add_auth_service(xml)
227
228
  add_business_rules_data(xml)
228
229
  xml.target!
@@ -250,11 +251,15 @@ module ActiveMerchant #:nodoc:
250
251
  xml.target!
251
252
  end
252
253
 
253
- def build_purchase_request(money, creditcard_or_reference, options)
254
+ def build_purchase_request(money, payment_method_or_reference, options)
254
255
  xml = Builder::XmlMarkup.new :indent => 2
255
- add_creditcard_or_subscription(xml, money, creditcard_or_reference, options)
256
- add_purchase_service(xml, options)
257
- add_business_rules_data(xml)
256
+ add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
257
+ if !payment_method_or_reference.is_a?(String) && card_brand(payment_method_or_reference) == 'check'
258
+ add_check_service(xml)
259
+ else
260
+ add_purchase_service(xml, options)
261
+ add_business_rules_data(xml)
262
+ end
258
263
  xml.target!
259
264
  end
260
265
 
@@ -297,16 +302,22 @@ module ActiveMerchant #:nodoc:
297
302
  xml.target!
298
303
  end
299
304
 
300
- def build_create_subscription_request(creditcard, options)
305
+ def build_create_subscription_request(payment_method, options)
301
306
  options[:subscription] = (options[:subscription] || {}).merge(:frequency => "on-demand", :amount => 0, :automatic_renew => false)
302
307
 
303
308
  xml = Builder::XmlMarkup.new :indent => 2
304
- add_address(xml, creditcard, options[:billing_address], options)
309
+ add_address(xml, payment_method, options[:billing_address], options)
305
310
  add_purchase_data(xml, options[:setup_fee] || 0, true, options)
306
- add_creditcard(xml, creditcard)
307
- add_creditcard_payment_method(xml)
311
+ if card_brand(payment_method) == 'check'
312
+ add_check(xml, payment_method)
313
+ add_check_payment_method(xml)
314
+ add_check_service(xml, options) if options[:setup_fee]
315
+ else
316
+ add_creditcard(xml, payment_method)
317
+ add_creditcard_payment_method(xml)
318
+ add_purchase_service(xml, options) if options[:setup_fee]
319
+ end
308
320
  add_subscription(xml, options)
309
- add_purchase_service(xml, options) if options[:setup_fee]
310
321
  add_subscription_create_service(xml, options)
311
322
  add_business_rules_data(xml)
312
323
  xml.target!
@@ -372,12 +383,12 @@ module ActiveMerchant #:nodoc:
372
383
  end
373
384
  end
374
385
 
375
- def add_address(xml, creditcard, address, options, shipTo = false)
386
+ def add_address(xml, payment_method, address, options, shipTo = false)
376
387
  requires!(options, :email)
377
388
 
378
389
  xml.tag! shipTo ? 'shipTo' : 'billTo' do
379
- xml.tag! 'firstName', creditcard.first_name if creditcard
380
- xml.tag! 'lastName', creditcard.last_name if creditcard
390
+ xml.tag! 'firstName', payment_method.first_name if payment_method
391
+ xml.tag! 'lastName', payment_method.last_name if payment_method
381
392
  xml.tag! 'street1', address[:address1]
382
393
  xml.tag! 'street2', address[:address2] unless address[:address2].blank?
383
394
  xml.tag! 'city', address[:city]
@@ -403,6 +414,14 @@ module ActiveMerchant #:nodoc:
403
414
  end
404
415
  end
405
416
 
417
+ def add_check(xml, check)
418
+ xml.tag! 'check' do
419
+ xml.tag! 'accountNumber', check.account_number
420
+ xml.tag! 'accountType', check.account_type[0]
421
+ xml.tag! 'bankTransitNumber', check.routing_number
422
+ end
423
+ end
424
+
406
425
  def add_tax_service(xml)
407
426
  xml.tag! 'taxService', {'run' => 'true'} do
408
427
  xml.tag!('nexus', @options[:nexus]) unless @options[:nexus].blank?
@@ -447,6 +466,10 @@ module ActiveMerchant #:nodoc:
447
466
  end
448
467
  end
449
468
 
469
+ def add_check_service(xml)
470
+ xml.tag! 'ecDebitService', {'run' => 'true'}
471
+ end
472
+
450
473
  def add_subscription_create_service(xml, options)
451
474
  xml.tag! 'paySubscriptionCreateService', {'run' => 'true'}
452
475
  end
@@ -491,14 +514,24 @@ module ActiveMerchant #:nodoc:
491
514
  end
492
515
  end
493
516
 
494
- def add_creditcard_or_subscription(xml, money, creditcard_or_reference, options)
495
- if creditcard_or_reference.is_a?(String)
517
+ def add_check_payment_method(xml)
518
+ xml.tag! 'subscription' do
519
+ xml.tag! 'paymentMethod', "check"
520
+ end
521
+ end
522
+
523
+ def add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
524
+ if payment_method_or_reference.is_a?(String)
525
+ add_purchase_data(xml, money, true, options)
526
+ add_subscription(xml, options, payment_method_or_reference)
527
+ elsif card_brand(payment_method_or_reference) == 'check'
528
+ add_address(xml, payment_method_or_reference, options[:billing_address], options)
496
529
  add_purchase_data(xml, money, true, options)
497
- add_subscription(xml, options, creditcard_or_reference)
530
+ add_check(xml, payment_method_or_reference)
498
531
  else
499
- add_address(xml, creditcard_or_reference, options[:billing_address], options)
532
+ add_address(xml, payment_method_or_reference, options[:billing_address], options)
500
533
  add_purchase_data(xml, money, true, options)
501
- add_creditcard(xml, creditcard_or_reference)
534
+ add_creditcard(xml, payment_method_or_reference)
502
535
  end
503
536
  end
504
537
 
@@ -65,7 +65,7 @@ module ActiveMerchant
65
65
  # See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
66
66
  # * <tt>:address</tt>:: billing address for card
67
67
  #
68
- # The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
68
+ # The continuous authority reference will be available in response#params['ca_reference'] if you have requested one
69
69
  def purchase(money, authorization_or_credit_card, options = {})
70
70
  requires!(options, :order_id)
71
71
 
@@ -93,7 +93,7 @@ module ActiveMerchant
93
93
  # See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
94
94
  # * <tt>:address</tt>:: billing address for card
95
95
  #
96
- # The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
96
+ # The continuous authority reference will be available in response#params['ca_reference'] if you have requested one
97
97
  def authorize(money, authorization_or_credit_card, options = {})
98
98
  requires!(options, :order_id)
99
99
 
@@ -448,7 +448,7 @@ module ActiveMerchant
448
448
  end
449
449
  end
450
450
 
451
- # Add credit_card detals to the passed XML Builder doc
451
+ # Add credit_card details to the passed XML Builder doc
452
452
  #
453
453
  # Parameters:
454
454
  # -xml: Builder document that is being built up