activemerchant 1.28.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data.tar.gz.sig +3 -3
  2. data/CHANGELOG +36 -0
  3. data/CONTRIBUTORS +8 -0
  4. data/README.md +5 -0
  5. data/lib/active_merchant/billing/gateway.rb +2 -1
  6. data/lib/active_merchant/billing/gateways.rb +6 -7
  7. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  9. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  10. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  11. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  15. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  16. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  20. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  21. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  22. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  23. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  24. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  25. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  26. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  27. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  28. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  29. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  30. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  31. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  32. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  33. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  34. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  36. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  37. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  38. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  39. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  40. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  41. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  42. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  43. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  44. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  45. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  46. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  47. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  48. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  49. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  50. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  51. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  54. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  55. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  56. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  57. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  58. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  59. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  62. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  63. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  64. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  65. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  66. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  67. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  68. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  69. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  70. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  71. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  72. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  75. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  76. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  77. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  78. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  79. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  80. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  81. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  82. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  83. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  84. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  85. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  86. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  87. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  88. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  89. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  90. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  91. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  92. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  93. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  94. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  95. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  99. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  102. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
  103. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
  104. data/lib/active_merchant/billing/integrations/notification.rb +4 -0
  105. data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
  110. data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
  111. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
  112. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
  113. data/lib/active_merchant/billing/response.rb +19 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. metadata +45 -27
  116. metadata.gz.sig +0 -0
@@ -8,22 +8,17 @@ module ActiveMerchant #:nodoc:
8
8
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
9
9
  self.homepage_url = 'http://www.concordefsnet.com/'
10
10
  self.display_name = 'Efsnet'
11
-
11
+
12
12
  self.test_url = 'https://testefsnet.concordebiz.com/efsnet.dll'
13
13
  self.live_url = 'https://efsnet.concordebiz.com/efsnet.dll'
14
-
14
+
15
15
  # login is your Store ID
16
16
  # password is your Store Key
17
17
  def initialize(options = {})
18
18
  requires!(options, :login, :password)
19
- @options = options
20
- super
21
- end
22
-
23
- def test?
24
- @options[:test] || super
19
+ super
25
20
  end
26
-
21
+
27
22
  def authorize(money, creditcard, options = {})
28
23
  request = build_credit_card_request(money, creditcard, options)
29
24
  commit(:credit_card_authorize, request)
@@ -33,7 +28,7 @@ module ActiveMerchant #:nodoc:
33
28
  request = build_credit_card_request(money, creditcard, options)
34
29
  commit(:credit_card_charge, request)
35
30
  end
36
-
31
+
37
32
  def capture(money, identification, options = {})
38
33
  request = build_refund_or_settle_request(money, identification, options)
39
34
  commit(:credit_card_settle, request)
@@ -62,28 +57,28 @@ module ActiveMerchant #:nodoc:
62
57
  original_transaction_id, original_transaction_amount = identification.split(";")
63
58
  commit(:void_transaction, {:reference_number => format_reference_number(options[:order_id]), :transaction_id => original_transaction_id})
64
59
  end
65
-
60
+
66
61
  def voice_authorize(money, authorization_code, creditcard, options = {})
67
62
  options[:authorization_number] = authorization_code
68
63
  request = build_credit_card_request(money, creditcard, options)
69
64
  commit(:credit_card_voice_authorize, request)
70
65
  end
71
-
66
+
72
67
  def force(money, authorization_code, creditcard, options = {})
73
68
  options[:authorization_number] = authorization_code
74
69
  request = build_credit_card_request(money, creditcard, options)
75
70
  commit(:credit_card_capture, request)
76
71
  end
77
-
72
+
78
73
  def system_check
79
- commit(:system_check, {})
74
+ commit(:system_check, {})
80
75
  end
81
76
 
82
77
  private
83
78
 
84
79
  def build_refund_or_settle_request(money, identification, options = {})
85
80
  original_transaction_id, original_transaction_amount = identification.split(";")
86
-
81
+
87
82
  requires!(options, :order_id)
88
83
 
89
84
  post = {
@@ -94,7 +89,7 @@ module ActiveMerchant #:nodoc:
94
89
  :client_ip_address => options[:ip]
95
90
  }
96
91
  end
97
-
92
+
98
93
  def build_credit_card_request(money, creditcard, options = {})
99
94
  requires!(options, :order_id)
100
95
 
@@ -103,17 +98,17 @@ module ActiveMerchant #:nodoc:
103
98
  :authorization_number => options[:authorization_number],
104
99
  :transaction_amount => amount(money),
105
100
  :client_ip_address => options[:ip]
106
-
101
+
107
102
  }
108
103
  add_creditcard(post,creditcard)
109
104
  add_address(post,options)
110
105
  post
111
106
  end
112
-
107
+
113
108
  def format_reference_number(number)
114
109
  number.to_s.slice(0,12)
115
110
  end
116
-
111
+
117
112
  def add_address(post,options)
118
113
  if address = options[:billing_address] || options[:address]
119
114
  if address[:address2]
@@ -123,7 +118,7 @@ module ActiveMerchant #:nodoc:
123
118
  end
124
119
  post[:billing_city] = address[:city].to_s
125
120
  post[:billing_state] = address[:state].blank? ? 'n/a' : address[:state]
126
- post[:billing_postal_code] = address[:zip].to_s
121
+ post[:billing_postal_code] = address[:zip].to_s
127
122
  post[:billing_country] = address[:country].to_s
128
123
  end
129
124
 
@@ -135,12 +130,12 @@ module ActiveMerchant #:nodoc:
135
130
  end
136
131
  post[:shipping_city] = address[:city].to_s
137
132
  post[:shipping_state] = address[:state].blank? ? 'n/a' : address[:state]
138
- post[:shipping_postal_code] = address[:zip].to_s
133
+ post[:shipping_postal_code] = address[:zip].to_s
139
134
  post[:shipping_country] = address[:country].to_s
140
135
  end
141
136
  end
142
137
 
143
- def add_creditcard(post, creditcard)
138
+ def add_creditcard(post, creditcard)
144
139
  post[:billing_name] = creditcard.name if creditcard.name
145
140
  post[:account_number] = creditcard.number
146
141
  post[:card_verification_value] = creditcard.verification_value if creditcard.verification_value?
@@ -148,8 +143,8 @@ module ActiveMerchant #:nodoc:
148
143
  post[:expiration_year] = sprintf("%.4i", creditcard.year)[-2..-1]
149
144
  end
150
145
 
151
-
152
- def commit(action, parameters)
146
+
147
+ def commit(action, parameters)
153
148
  response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters), 'Content-Type' => 'text/xml'))
154
149
 
155
150
  Response.new(success?(response), message_from(response[:result_message]), response,
@@ -159,19 +154,19 @@ module ActiveMerchant #:nodoc:
159
154
  :cvv_result => response[:cvv_response_code]
160
155
  )
161
156
  end
162
-
157
+
163
158
  def success?(response)
164
159
  response[:response_code] == '0'
165
160
  end
166
-
161
+
167
162
  def authorization_from(response, params)
168
163
  [ response[:transaction_id], params[:transaction_amount] ].compact.join(';')
169
164
  end
170
-
165
+
171
166
  def parse(xml)
172
167
  response = {}
173
168
 
174
- xml = REXML::Document.new(xml)
169
+ xml = REXML::Document.new(xml)
175
170
 
176
171
  xml.elements.each('//Reply//TransactionReply/*') do |node|
177
172
 
@@ -180,7 +175,7 @@ module ActiveMerchant #:nodoc:
180
175
  end unless xml.root.nil?
181
176
 
182
177
  response
183
- end
178
+ end
184
179
 
185
180
  def post_data(action, parameters = {})
186
181
  xml = REXML::Document.new("<?xml version='1.0' encoding='UTF-8'?>")
@@ -196,7 +191,7 @@ module ActiveMerchant #:nodoc:
196
191
 
197
192
  xml.to_s
198
193
  end
199
-
194
+
200
195
  def message_from(message)
201
196
  return 'Unspecified error' if message.blank?
202
197
  message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
@@ -210,9 +205,9 @@ module ActiveMerchant #:nodoc:
210
205
  when "" then nil
211
206
  when "null" then nil
212
207
  else field
213
- end
214
- end
215
-
208
+ end
209
+ end
210
+
216
211
  def actions
217
212
  ACTIONS
218
213
  end
@@ -229,7 +224,7 @@ module ActiveMerchant #:nodoc:
229
224
  :void_transaction => %w(ReferenceNumber TransactionID),
230
225
  :credit_card_settle => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress),
231
226
  :system_check => %w(SystemCheck),
232
- }
227
+ }
233
228
  end
234
229
  end
235
230
  end
@@ -63,13 +63,13 @@ module ActiveMerchant #:nodoc:
63
63
  # * <tt>:test => +true+ or +false+</tt> -- Force test transactions
64
64
  def initialize(options = {})
65
65
  requires!(options, :login, :password)
66
- @options = options
67
66
  super
68
67
  end
69
68
 
70
69
  # Make a purchase
71
70
  def purchase(money, creditcard, options = {})
72
71
  form = {}
72
+ add_salestax(form, options)
73
73
  add_invoice(form, options)
74
74
  add_creditcard(form, creditcard)
75
75
  add_address(form, options)
@@ -87,6 +87,7 @@ module ActiveMerchant #:nodoc:
87
87
  # * <tt>:billing_address</tt> - The billing address for the cardholder.
88
88
  def authorize(money, creditcard, options = {})
89
89
  form = {}
90
+ add_salestax(form, options)
90
91
  add_invoice(form, options)
91
92
  add_creditcard(form, creditcard)
92
93
  add_address(form, options)
@@ -106,6 +107,7 @@ module ActiveMerchant #:nodoc:
106
107
  requires!(options, :credit_card)
107
108
 
108
109
  form = {}
110
+ add_salestax(form, options)
109
111
  add_approval_code(form, authorization)
110
112
  add_invoice(form, options)
111
113
  add_creditcard(form, options[:credit_card])
@@ -205,6 +207,10 @@ module ActiveMerchant #:nodoc:
205
207
  form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
206
208
  end
207
209
 
210
+ def add_salestax(form, options)
211
+ form[:salestax] = options[:tax] if options[:tax].present?
212
+ end
213
+
208
214
  def expdate(creditcard)
209
215
  year = sprintf("%.4i", creditcard.year)
210
216
  month = sprintf("%.2i", creditcard.month)
@@ -54,7 +54,6 @@ module ActiveMerchant #:nodoc:
54
54
  # password: referrer url (for authorize authentication)
55
55
  def initialize(options = {})
56
56
  requires!(options, :login)
57
- @options = options
58
57
  super
59
58
  end
60
59
 
@@ -3,7 +3,7 @@ require 'rexml/document'
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  # First, make sure you have everything setup correctly and all of your dependencies in place with:
6
- #
6
+ #
7
7
  # require 'rubygems'
8
8
  # require 'active_merchant'
9
9
  #
@@ -17,10 +17,10 @@ module ActiveMerchant #:nodoc:
17
17
  # Next, create a credit card object using a eWay approved test card number (4444333322221111).
18
18
  #
19
19
  # creditcard = ActiveMerchant::Billing::CreditCard.new(
20
- # :number => '4444333322221111',
21
- # :month => 8,
22
- # :year => 2006,
23
- # :first_name => 'Longbob',
20
+ # :number => '4444333322221111',
21
+ # :month => 8,
22
+ # :year => 2006,
23
+ # :first_name => 'Longbob',
24
24
  # :last_name => 'Longsen',
25
25
  # :verification_value => '123'
26
26
  # )
@@ -28,7 +28,7 @@ module ActiveMerchant #:nodoc:
28
28
  # :order_id => '1230123',
29
29
  # :email => 'bob@testbob.com',
30
30
  # :address => { :address1 => '47 Bobway',
31
- # :city => 'Bobville',
31
+ # :city => 'Bobville',
32
32
  # :state => 'WA',
33
33
  # :country => 'Australia',
34
34
  # :zip => '2000'
@@ -63,88 +63,87 @@ module ActiveMerchant #:nodoc:
63
63
  # This should be enough to get you started with eWay and active_merchant. For further information, review the methods
64
64
  # below and the rest of active_merchant's documentation.
65
65
 
66
- class EwayGateway < Gateway
66
+ class EwayGateway < Gateway
67
67
  self.test_url = 'https://www.eway.com.au/gateway/xmltest/testpage.asp'
68
68
  self.live_url = 'https://www.eway.com.au/gateway/xmlpayment.asp'
69
69
 
70
70
  class_attribute :test_cvn_url, :live_cvn_url
71
71
  self.test_cvn_url = 'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp'
72
72
  self.live_cvn_url = 'https://www.eway.com.au/gateway_cvn/xmlpayment.asp'
73
-
73
+
74
74
  MESSAGES = {
75
75
  "00" => "Transaction Approved",
76
76
  "01" => "Refer to Issuer",
77
- "02" => "Refer to Issuer, special",
77
+ "02" => "Refer to Issuer, special",
78
78
  "03" => "No Merchant",
79
- "04" => "Pick Up Card",
80
- "05" => "Do Not Honour",
79
+ "04" => "Pick Up Card",
80
+ "05" => "Do Not Honour",
81
81
  "06" => "Error",
82
- "07" => "Pick Up Card, Special",
83
- "08" => "Honour With Identification",
82
+ "07" => "Pick Up Card, Special",
83
+ "08" => "Honour With Identification",
84
84
  "09" => "Request In Progress",
85
- "10" => "Approved For Partial Amount",
86
- "11" => "Approved, VIP",
87
- "12" => "Invalid Transaction",
85
+ "10" => "Approved For Partial Amount",
86
+ "11" => "Approved, VIP",
87
+ "12" => "Invalid Transaction",
88
88
  "13" => "Invalid Amount",
89
- "14" => "Invalid Card Number",
90
- "15" => "No Issuer",
91
- "16" => "Approved, Update Track 3",
92
- "19" => "Re-enter Last Transaction",
93
- "21" => "No Action Taken",
94
- "22" => "Suspected Malfunction",
95
- "23" => "Unacceptable Transaction Fee",
96
- "25" => "Unable to Locate Record On File",
97
- "30" => "Format Error",
98
- "31" => "Bank Not Supported By Switch",
99
- "33" => "Expired Card, Capture",
100
- "34" => "Suspected Fraud, Retain Card",
101
- "35" => "Card Acceptor, Contact Acquirer, Retain Card",
102
- "36" => "Restricted Card, Retain Card",
103
- "37" => "Contact Acquirer Security Department, Retain Card",
104
- "38" => "PIN Tries Exceeded, Capture",
105
- "39" => "No Credit Account",
106
- "40" => "Function Not Supported",
107
- "41" => "Lost Card",
108
- "42" => "No Universal Account",
109
- "43" => "Stolen Card",
110
- "44" => "No Investment Account",
111
- "51" => "Insufficient Funds",
112
- "52" => "No Cheque Account",
113
- "53" => "No Savings Account",
114
- "54" => "Expired Card",
115
- "55" => "Incorrect PIN",
116
- "56" => "No Card Record",
117
- "57" => "Function Not Permitted to Cardholder",
118
- "58" => "Function Not Permitted to Terminal",
119
- "59" => "Suspected Fraud",
120
- "60" => "Acceptor Contact Acquirer",
121
- "61" => "Exceeds Withdrawal Limit",
122
- "62" => "Restricted Card",
123
- "63" => "Security Violation",
124
- "64" => "Original Amount Incorrect",
125
- "66" => "Acceptor Contact Acquirer, Security",
126
- "67" => "Capture Card",
127
- "75" => "PIN Tries Exceeded",
128
- "82" => "CVV Validation Error",
129
- "90" => "Cutoff In Progress",
130
- "91" => "Card Issuer Unavailable",
131
- "92" => "Unable To Route Transaction",
132
- "93" => "Cannot Complete, Violation Of The Law",
133
- "94" => "Duplicate Transaction",
89
+ "14" => "Invalid Card Number",
90
+ "15" => "No Issuer",
91
+ "16" => "Approved, Update Track 3",
92
+ "19" => "Re-enter Last Transaction",
93
+ "21" => "No Action Taken",
94
+ "22" => "Suspected Malfunction",
95
+ "23" => "Unacceptable Transaction Fee",
96
+ "25" => "Unable to Locate Record On File",
97
+ "30" => "Format Error",
98
+ "31" => "Bank Not Supported By Switch",
99
+ "33" => "Expired Card, Capture",
100
+ "34" => "Suspected Fraud, Retain Card",
101
+ "35" => "Card Acceptor, Contact Acquirer, Retain Card",
102
+ "36" => "Restricted Card, Retain Card",
103
+ "37" => "Contact Acquirer Security Department, Retain Card",
104
+ "38" => "PIN Tries Exceeded, Capture",
105
+ "39" => "No Credit Account",
106
+ "40" => "Function Not Supported",
107
+ "41" => "Lost Card",
108
+ "42" => "No Universal Account",
109
+ "43" => "Stolen Card",
110
+ "44" => "No Investment Account",
111
+ "51" => "Insufficient Funds",
112
+ "52" => "No Cheque Account",
113
+ "53" => "No Savings Account",
114
+ "54" => "Expired Card",
115
+ "55" => "Incorrect PIN",
116
+ "56" => "No Card Record",
117
+ "57" => "Function Not Permitted to Cardholder",
118
+ "58" => "Function Not Permitted to Terminal",
119
+ "59" => "Suspected Fraud",
120
+ "60" => "Acceptor Contact Acquirer",
121
+ "61" => "Exceeds Withdrawal Limit",
122
+ "62" => "Restricted Card",
123
+ "63" => "Security Violation",
124
+ "64" => "Original Amount Incorrect",
125
+ "66" => "Acceptor Contact Acquirer, Security",
126
+ "67" => "Capture Card",
127
+ "75" => "PIN Tries Exceeded",
128
+ "82" => "CVV Validation Error",
129
+ "90" => "Cutoff In Progress",
130
+ "91" => "Card Issuer Unavailable",
131
+ "92" => "Unable To Route Transaction",
132
+ "93" => "Cannot Complete, Violation Of The Law",
133
+ "94" => "Duplicate Transaction",
134
134
  "96" => "System Error"
135
135
  }
136
-
137
- self.money_format = :cents
136
+
137
+ self.money_format = :cents
138
138
  self.supported_countries = ['AU']
139
139
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
140
140
  self.homepage_url = 'http://www.eway.com.au/'
141
141
  self.display_name = 'eWAY'
142
-
143
- def initialize(options = {})
142
+
143
+ def initialize(options = {})
144
144
  requires!(options, :login)
145
- @options = options
146
145
  super
147
- end
146
+ end
148
147
 
149
148
  # ewayCustomerEmail, ewayCustomerAddress, ewayCustomerPostcode
150
149
  def purchase(money, creditcard, options = {})
@@ -152,20 +151,16 @@ module ActiveMerchant #:nodoc:
152
151
 
153
152
  post = {}
154
153
  add_creditcard(post, creditcard)
155
- add_address(post, options)
154
+ add_address(post, options)
156
155
  add_customer_data(post, options)
157
156
  add_invoice_data(post, options)
158
157
  # The request fails if all of the fields aren't present
159
158
  add_optional_data(post)
160
-
159
+
161
160
  commit(money, post)
162
161
  end
163
-
164
- def test?
165
- @options[:test] || super
166
- end
167
-
168
- private
162
+
163
+ private
169
164
 
170
165
  def requires_address!(options)
171
166
  raise ArgumentError.new("Missing eWay required parameters: address or billing_address") unless (options.has_key?(:address) or options.has_key?(:billing_address))
@@ -178,9 +173,9 @@ module ActiveMerchant #:nodoc:
178
173
  post[:CustomerFirstName] = creditcard.first_name
179
174
  post[:CustomerLastName] = creditcard.last_name
180
175
  post[:CardHoldersName] = creditcard.name
181
-
176
+
182
177
  post[:CVN] = creditcard.verification_value if creditcard.verification_value?
183
- end
178
+ end
184
179
 
185
180
  def add_address(post, options)
186
181
  if address = options[:billing_address] || options[:address]
@@ -192,7 +187,7 @@ module ActiveMerchant #:nodoc:
192
187
  def add_customer_data(post, options)
193
188
  post[:CustomerEmail] = options[:email]
194
189
  end
195
-
190
+
196
191
  def add_invoice_data(post, options)
197
192
  post[:CustomerInvoiceRef] = options[:order_id]
198
193
  post[:CustomerInvoiceDescription] = options[:description]
@@ -202,10 +197,10 @@ module ActiveMerchant #:nodoc:
202
197
  post[:TrxnNumber] = nil
203
198
  post[:Option1] = nil
204
199
  post[:Option2] = nil
205
- post[:Option3] = nil
200
+ post[:Option3] = nil
206
201
  end
207
202
 
208
- def commit(money, parameters)
203
+ def commit(money, parameters)
209
204
  parameters[:TotalAmount] = amount(money)
210
205
 
211
206
  response = parse( ssl_post(gateway_url(parameters[:CVN], test?), post_data(parameters)) )
@@ -213,13 +208,13 @@ module ActiveMerchant #:nodoc:
213
208
  Response.new(success?(response), message_from(response[:ewaytrxnerror]), response,
214
209
  :authorization => response[:ewayauthcode],
215
210
  :test => /\(Test( CVN)? Gateway\)/ === response[:ewaytrxnerror]
216
- )
211
+ )
217
212
  end
218
-
213
+
219
214
  def success?(response)
220
215
  response[:ewaytrxnstatus] == "True"
221
216
  end
222
-
217
+
223
218
  # Parse eway response xml into a convinient hash
224
219
  def parse(xml)
225
220
  # "<?xml version=\"1.0\"?>".
@@ -233,10 +228,10 @@ module ActiveMerchant #:nodoc:
233
228
  # <ewayReturnAmount>10</ewayReturnAmount>
234
229
  # <ewayAuthCode>123456</ewayAuthCode>
235
230
  # <ewayTrxnReference>987654321</ewayTrxnReference>
236
- # </ewayResponse>
231
+ # </ewayResponse>
237
232
 
238
233
  response = {}
239
- xml = REXML::Document.new(xml)
234
+ xml = REXML::Document.new(xml)
240
235
  xml.elements.each('//ewayResponse/*') do |node|
241
236
 
242
237
  response[node.name.downcase.to_sym] = normalize(node.text)
@@ -244,20 +239,20 @@ module ActiveMerchant #:nodoc:
244
239
  end unless xml.root.nil?
245
240
 
246
241
  response
247
- end
242
+ end
248
243
 
249
244
  def post_data(parameters = {})
250
245
  parameters[:CustomerID] = @options[:login]
251
-
246
+
252
247
  xml = REXML::Document.new
253
248
  root = xml.add_element("ewaygateway")
254
-
249
+
255
250
  parameters.each do |key, value|
256
251
  root.add_element("eway#{key}").text = value
257
- end
252
+ end
258
253
  xml.to_s
259
254
  end
260
-
255
+
261
256
  def message_from(message)
262
257
  return '' if message.blank?
263
258
  MESSAGES[message[0,2]] || message
@@ -271,9 +266,9 @@ module ActiveMerchant #:nodoc:
271
266
  when "" then nil
272
267
  when "null" then nil
273
268
  else field
274
- end
269
+ end
275
270
  end
276
-
271
+
277
272
  def gateway_url(cvn, test)
278
273
  if cvn
279
274
  test ? self.test_cvn_url : self.live_cvn_url
@@ -281,7 +276,7 @@ module ActiveMerchant #:nodoc:
281
276
  test ? self.test_url : self.live_url
282
277
  end
283
278
  end
284
-
279
+
285
280
  end
286
281
  end
287
282
  end