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
@@ -19,14 +19,10 @@ module ActiveMerchant #:nodoc:
19
19
  SUB_ID = '0'
20
20
  API_VERSION = '1.1.0'
21
21
 
22
- attr_reader :url
23
-
24
22
  def initialize(options = {})
25
23
  requires!(options, :login, :password, :pem)
26
- @options = options
27
24
 
28
- @options[:pem_password] = options[:password]
29
- @url = test? ? test_url : live_url
25
+ options[:pem_password] = options[:password]
30
26
  super
31
27
  end
32
28
 
@@ -49,11 +45,12 @@ module ActiveMerchant #:nodoc:
49
45
  commit(build_directory_request)
50
46
  end
51
47
 
52
- def test?
53
- @options[:test] || Base.gateway_mode == :test
48
+ private
49
+
50
+ def url
51
+ (test? ? test_url : live_url)
54
52
  end
55
53
 
56
- private
57
54
  def token
58
55
  if @token.nil?
59
56
  @token = create_fingerprint(@options[:pem])
@@ -3,16 +3,17 @@ module ActiveMerchant #:nodoc:
3
3
  module Billing #:nodoc:
4
4
  class InspireGateway < Gateway
5
5
  self.live_url = self.test_url = 'https://secure.inspiregateway.net/api/transact.php'
6
-
6
+
7
7
  self.supported_countries = ['US']
8
8
  self.supported_cardtypes = [:visa, :master, :american_express]
9
9
  self.homepage_url = 'http://www.inspiregateway.com'
10
10
  self.display_name = 'Inspire Commerce'
11
- # Creates a new InspireGateway
12
- #
11
+
12
+ # Creates a new InspireGateway
13
+ #
13
14
  # The gateway requires that a valid login and password be passed
14
15
  # in the +options+ hash.
15
- #
16
+ #
16
17
  # ==== Options
17
18
  #
18
19
  # * <tt>:login</tt> -- The Inspire Username.
@@ -20,48 +21,47 @@ module ActiveMerchant #:nodoc:
20
21
  # See the Inspire Integration Guide for details. (default: +false+)
21
22
  def initialize(options = {})
22
23
  requires!(options, :login, :password)
23
- @options = options
24
24
  super
25
- end
26
-
27
- # Pass :store => true in the options to store the
28
- # payment info at Inspire Gateway and get a generated
29
- # customer_vault_id in the response.
25
+ end
26
+
27
+ # Pass :store => true in the options to store the
28
+ # payment info at Inspire Gateway and get a generated
29
+ # customer_vault_id in the response.
30
30
  # Pass :store => some_number_or_string to specify the
31
31
  # customer_vault_id InspireGateway should use (make sure it's
32
32
  # unique).
33
33
  def authorize(money, creditcard, options = {})
34
34
  post = {}
35
35
  add_invoice(post, options)
36
- add_payment_source(post, creditcard,options)
37
- add_address(post, creditcard, options)
36
+ add_payment_source(post, creditcard,options)
37
+ add_address(post, creditcard, options)
38
38
  add_customer_data(post, options)
39
-
39
+
40
40
  commit('auth', money, post)
41
41
  end
42
-
42
+
43
43
  def purchase(money, payment_source, options = {})
44
44
  post = {}
45
45
  add_invoice(post, options)
46
- add_payment_source(post, payment_source, options)
47
- add_address(post, payment_source, options)
46
+ add_payment_source(post, payment_source, options)
47
+ add_address(post, payment_source, options)
48
48
  add_customer_data(post, options)
49
-
49
+
50
50
  commit('sale', money, post)
51
- end
52
-
51
+ end
52
+
53
53
  def capture(money, authorization, options = {})
54
54
  post ={}
55
55
  post[:transactionid] = authorization
56
56
  commit('capture', money, post)
57
57
  end
58
-
58
+
59
59
  def void(authorization, options = {})
60
60
  post ={}
61
61
  post[:transactionid] = authorization
62
62
  commit('void', nil, post)
63
63
  end
64
-
64
+
65
65
  # Update the values (such as CC expiration) stored at
66
66
  # InspireGateway. The CC number must be supplied in the
67
67
  # CreditCard object.
@@ -69,30 +69,30 @@ module ActiveMerchant #:nodoc:
69
69
  post = {}
70
70
  post[:customer_vault] = "update_customer"
71
71
  add_customer_vault_id(post, vault_id)
72
- add_creditcard(post, creditcard, options)
73
- add_address(post, creditcard, options)
72
+ add_creditcard(post, creditcard, options)
73
+ add_address(post, creditcard, options)
74
74
  add_customer_data(post, options)
75
-
75
+
76
76
  commit(nil, nil, post)
77
77
  end
78
-
78
+
79
79
  def delete(vault_id)
80
80
  post = {}
81
81
  post[:customer_vault] = "delete_customer"
82
- add_customer_vault_id(post, vault_id)
82
+ add_customer_vault_id(post, vault_id)
83
83
  commit(nil, nil, post)
84
84
  end
85
-
85
+
86
86
  # To match the other stored-value gateways, like TrustCommerce,
87
87
  # store and unstore need to be defined
88
88
  def store(creditcard, options = {})
89
89
  billing_id = options.delete(:billing_id).to_s || true
90
90
  authorize(100, creditcard, options.merge(:store => billing_id))
91
91
  end
92
-
92
+
93
93
  alias_method :unstore, :delete
94
94
 
95
- private
95
+ private
96
96
  def add_customer_data(post, options)
97
97
  if options.has_key? :email
98
98
  post[:email] = options[:email]
@@ -100,27 +100,27 @@ module ActiveMerchant #:nodoc:
100
100
 
101
101
  if options.has_key? :ip
102
102
  post[:ipaddress] = options[:ip]
103
- end
103
+ end
104
104
  end
105
105
 
106
- def add_address(post, creditcard, options)
106
+ def add_address(post, creditcard, options)
107
107
  if address = options[:billing_address] || options[:address]
108
108
  post[:address1] = address[:address1].to_s
109
109
  post[:address2] = address[:address2].to_s unless address[:address2].blank?
110
110
  post[:company] = address[:company].to_s
111
111
  post[:phone] = address[:phone].to_s
112
- post[:zip] = address[:zip].to_s
112
+ post[:zip] = address[:zip].to_s
113
113
  post[:city] = address[:city].to_s
114
114
  post[:country] = address[:country].to_s
115
115
  post[:state] = address[:state].blank? ? 'n/a' : address[:state]
116
- end
116
+ end
117
117
  end
118
118
 
119
119
  def add_invoice(post, options)
120
120
  post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
121
121
  post[:orderdescription] = options[:description]
122
122
  end
123
-
123
+
124
124
  def add_payment_source(params, source, options={})
125
125
  case determine_funding_source(source)
126
126
  when :vault then add_customer_vault_id(params, source)
@@ -128,13 +128,13 @@ module ActiveMerchant #:nodoc:
128
128
  when :check then add_check(params, source)
129
129
  end
130
130
  end
131
-
131
+
132
132
  def add_customer_vault_id(params,vault_id)
133
133
  params[:customer_vault_id] = vault_id
134
134
  end
135
-
135
+
136
136
  def add_creditcard(post, creditcard,options)
137
- if options[:store]
137
+ if options[:store]
138
138
  post[:customer_vault] = "add_customer"
139
139
  post[:customer_vault_id] = options[:store] unless options[:store] == true
140
140
  end
@@ -142,9 +142,9 @@ module ActiveMerchant #:nodoc:
142
142
  post[:cvv] = creditcard.verification_value if creditcard.verification_value?
143
143
  post[:ccexp] = expdate(creditcard)
144
144
  post[:firstname] = creditcard.first_name
145
- post[:lastname] = creditcard.last_name
145
+ post[:lastname] = creditcard.last_name
146
146
  end
147
-
147
+
148
148
  def add_check(post, check)
149
149
  post[:payment] = 'check' # Set transaction to ACH
150
150
  post[:checkname] = check.name # The name on the customer's Checking Account
@@ -153,38 +153,38 @@ module ActiveMerchant #:nodoc:
153
153
  post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
154
154
  post[:account_type] = check.account_type # The customer's type of ACH account
155
155
  end
156
-
156
+
157
157
  def parse(body)
158
158
  results = {}
159
159
  body.split(/&/).each do |pair|
160
160
  key,val = pair.split(/=/)
161
161
  results[key] = val
162
162
  end
163
-
163
+
164
164
  results
165
- end
166
-
165
+ end
166
+
167
167
  def commit(action, money, parameters)
168
168
  parameters[:amount] = amount(money) if money
169
-
169
+
170
170
  response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
171
171
 
172
- Response.new(response["response"] == "1", message_from(response), response,
172
+ Response.new(response["response"] == "1", message_from(response), response,
173
173
  :authorization => response["transactionid"],
174
174
  :test => test?,
175
175
  :cvv_result => response["cvvresponse"],
176
176
  :avs_result => { :code => response["avsresponse"] }
177
177
  )
178
-
178
+
179
179
  end
180
-
180
+
181
181
  def expdate(creditcard)
182
182
  year = sprintf("%.4i", creditcard.year)
183
183
  month = sprintf("%.2i", creditcard.month)
184
184
 
185
185
  "#{month}#{year[-2..-1]}"
186
186
  end
187
-
187
+
188
188
 
189
189
  def message_from(response)
190
190
  case response["responsetext"]
@@ -196,7 +196,7 @@ module ActiveMerchant #:nodoc:
196
196
  response["responsetext"]
197
197
  end
198
198
  end
199
-
199
+
200
200
  def post_data(action, parameters = {})
201
201
  post = {}
202
202
  post[:username] = @options[:login]
@@ -204,11 +204,11 @@ module ActiveMerchant #:nodoc:
204
204
  post[:type] = action if action
205
205
 
206
206
  request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
207
- request
207
+ request
208
208
  end
209
-
209
+
210
210
  def determine_funding_source(source)
211
- case
211
+ case
212
212
  when source.is_a?(String) then :vault
213
213
  when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
214
214
  when card_brand(source) == 'check' then :check
@@ -15,13 +15,12 @@ module ActiveMerchant #:nodoc:
15
15
 
16
16
  # The name of the gateway
17
17
  self.display_name = 'InstaPay'
18
-
18
+
19
19
  SUCCESS = "Accepted"
20
20
  SUCCESS_MESSAGE = "The transaction has been approved"
21
21
 
22
22
  def initialize(options = {})
23
23
  requires!(options, :login)
24
- @options = options
25
24
  super
26
25
  end
27
26
 
@@ -47,24 +46,24 @@ module ActiveMerchant #:nodoc:
47
46
 
48
47
  commit('ns_quicksale_cc', post)
49
48
  end
50
-
49
+
51
50
  def capture(money, authorization, options = {})
52
51
  post = {}
53
52
  add_amount(post, money)
54
- add_reference(post, authorization)
53
+ add_reference(post, authorization)
55
54
  commit('ns_quicksale_cc', post)
56
55
  end
57
56
 
58
57
  private
59
-
58
+
60
59
  def add_amount(post, money)
61
60
  post[:amount] = amount(money)
62
61
  end
63
-
62
+
64
63
  def add_reference(post, reference)
65
64
  post[:postonly] = reference
66
65
  end
67
-
66
+
68
67
  def add_customer_data(post, options)
69
68
  post[:ci_email] = options[:email]
70
69
  post["ci_IP Address"] = options[:ip]
@@ -87,7 +86,7 @@ module ActiveMerchant #:nodoc:
87
86
  post[:ci_shipcity] = address[:city]
88
87
  post[:ci_shipstate] = address[:state]
89
88
  post[:ci_shipzip] = address[:zip]
90
- post[:ci_shipcountry] = address[:country]
89
+ post[:ci_shipcountry] = address[:country]
91
90
  end
92
91
  end
93
92
 
@@ -108,10 +107,10 @@ module ActiveMerchant #:nodoc:
108
107
  def parse(body)
109
108
  results = {}
110
109
  fields = body.split("\r\n")
111
-
112
- response = fields[1].split('=')
110
+
111
+ response = fields[1].split('=')
113
112
  response_data = response[1].split(':')
114
-
113
+
115
114
  if response[0] == SUCCESS
116
115
  results[:success] = true
117
116
  results[:message] = SUCCESS_MESSAGE
@@ -3,27 +3,27 @@ module ActiveMerchant #:nodoc:
3
3
  # For more information on the Iridium Gateway please download the
4
4
  # documentation from their Merchant Management System.
5
5
  #
6
- # The login and password are not the username and password you use to
7
- # login to the Iridium Merchant Management System. Instead, you will
6
+ # The login and password are not the username and password you use to
7
+ # login to the Iridium Merchant Management System. Instead, you will
8
8
  # use the API username and password you were issued separately.
9
9
  class IridiumGateway < Gateway
10
- self.live_url = self.test_url = 'https://gw1.iridiumcorp.net/'
10
+ self.live_url = self.test_url = 'https://gw1.iridiumcorp.net/'
11
11
 
12
12
  # The countries the gateway supports merchants from as 2 digit ISO country codes
13
13
  self.supported_countries = ['GB', 'ES']
14
14
  self.default_currency = 'EUR'
15
15
  self.money_format = :cents
16
-
16
+
17
17
  # The card types supported by the payment gateway
18
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
19
-
18
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :solo, :diners_club]
19
+
20
20
  # The homepage URL of the gateway
21
21
  self.homepage_url = 'http://www.iridiumcorp.co.uk/'
22
-
22
+
23
23
  # The name of the gateway
24
24
  self.display_name = 'Iridium'
25
-
26
- CURRENCY_CODES = {
25
+
26
+ CURRENCY_CODES = {
27
27
  "AUD" => '036',
28
28
  "CAD" => '124',
29
29
  "EUR" => '978',
@@ -32,31 +32,30 @@ module ActiveMerchant #:nodoc:
32
32
  "NZD" => '554',
33
33
  "USD" => '840',
34
34
  }
35
-
35
+
36
36
  def initialize(options = {})
37
37
  requires!(options, :login, :password)
38
- @options = options
39
38
  super
40
- end
41
-
39
+ end
40
+
42
41
  def authorize(money, creditcard, options = {})
43
42
  commit(build_purchase_request('PREAUTH', money, creditcard, options), options)
44
43
  end
45
-
44
+
46
45
  def purchase(money, payment_source, options = {})
47
46
  setup_address_hash(options)
48
-
47
+
49
48
  if payment_source.respond_to?(:number)
50
49
  commit(build_purchase_request('SALE', money, payment_source, options), options)
51
50
  else
52
51
  commit(build_reference_request('SALE', money, payment_source, options), options)
53
52
  end
54
- end
55
-
53
+ end
54
+
56
55
  def capture(money, authorization, options = {})
57
56
  commit(build_reference_request('COLLECTION', money, authorization, options), options)
58
57
  end
59
-
58
+
60
59
  def credit(money, authorization, options={})
61
60
  deprecated CREDIT_DEPRECATION_MESSAGE
62
61
  refund(money, authorization, options)
@@ -65,12 +64,12 @@ module ActiveMerchant #:nodoc:
65
64
  def refund(money, authorization, options={})
66
65
  commit(build_reference_request('REFUND', money, authorization, options), options)
67
66
  end
68
-
67
+
69
68
  def void(authorization, options={})
70
69
  commit(build_reference_request('VOID', nil, authorization, options), options)
71
70
  end
72
-
73
- private
71
+
72
+ private
74
73
 
75
74
  def build_purchase_request(type, money, creditcard, options)
76
75
  options.merge!(:action => 'CardDetailsTransaction')
@@ -80,7 +79,7 @@ module ActiveMerchant #:nodoc:
80
79
  add_customerdetails(xml, creditcard, options[:billing_address], options)
81
80
  end
82
81
  end
83
-
82
+
84
83
  def build_reference_request(type, money, authorization, options)
85
84
  options.merge!(:action => 'CrossReferenceTransaction')
86
85
  order_id, cross_reference, auth_id = authorization.split(";")
@@ -96,13 +95,13 @@ module ActiveMerchant #:nodoc:
96
95
  end
97
96
  end
98
97
  end
99
-
98
+
100
99
  def build_request(options)
101
100
  requires!(options, :action)
102
101
  xml = Builder::XmlMarkup.new :indent => 2
103
102
  xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
104
- xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
105
- 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
103
+ xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
104
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
106
105
  'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
107
106
  xml.tag! 'soap:Body' do
108
107
  xml.tag! options[:action], {'xmlns' => "https://www.thepaymentgateway.net/"} do
@@ -120,7 +119,7 @@ module ActiveMerchant #:nodoc:
120
119
  options[:billing_address] = options[:billing_address] || options[:address] || {}
121
120
  options[:shipping_address] = options[:shipping_address] || {}
122
121
  end
123
-
122
+
124
123
  def add_purchase_data(xml, type, money, options)
125
124
  requires!(options, :order_id)
126
125
  xml.tag! 'TransactionDetails', {'Amount' => amount(money), 'CurrencyCode' => currency_code(options[:currency] || currency(money))} do
@@ -150,13 +149,13 @@ module ActiveMerchant #:nodoc:
150
149
  end
151
150
  xml.tag! 'PhoneNumber', address[:phone]
152
151
  end
153
-
152
+
154
153
  xml.tag! 'EmailAddress', options[:email]
155
154
  xml.tag! 'CustomerIPAddress', options[:ip] || "127.0.0.1"
156
- end
155
+ end
157
156
  end
158
157
 
159
- def add_creditcard(xml, creditcard)
158
+ def add_creditcard(xml, creditcard)
160
159
  xml.tag! 'CardDetails' do
161
160
  xml.tag! 'CardName', creditcard.name
162
161
  xml.tag! 'CV2', creditcard.verification_value if creditcard.verification_value
@@ -164,7 +163,7 @@ module ActiveMerchant #:nodoc:
164
163
  xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, "0"), 'Year' => creditcard.year.to_s[/\d\d$/] }
165
164
  end
166
165
  end
167
-
166
+
168
167
  def add_merchant_data(xml, options)
169
168
  xml.tag! 'MerchantAuthentication', {"MerchantID" => @options[:login], "Password" => @options[:password]}
170
169
  end
@@ -174,13 +173,13 @@ module ActiveMerchant #:nodoc:
174
173
  response = parse(ssl_post(test? ? self.test_url : self.live_url, request,
175
174
  {"SOAPAction" => "https://www.thepaymentgateway.net/#{options[:action]}",
176
175
  "Content-Type" => "text/xml; charset=utf-8" }))
177
-
176
+
178
177
  success = response[:transaction_result][:status_code] == "0"
179
178
  message = response[:transaction_result][:message]
180
179
  authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(";") : nil
181
-
182
- Response.new(success, message, response,
183
- :test => test?,
180
+
181
+ Response.new(success, message, response,
182
+ :test => test?,
184
183
  :authorization => authorization)
185
184
  end
186
185
 
@@ -190,19 +189,19 @@ module ActiveMerchant #:nodoc:
190
189
  if (root = REXML::XPath.first(xml, "//CardDetailsTransactionResponse")) or
191
190
  (root = REXML::XPath.first(xml, "//CrossReferenceTransactionResponse"))
192
191
  root.elements.to_a.each do |node|
193
- case node.name
192
+ case node.name
194
193
  when 'Message'
195
194
  reply[:message] = reply(node.text)
196
195
  else
197
196
  parse_element(reply, node)
198
197
  end
199
198
  end
200
- elsif root = REXML::XPath.first(xml, "//soap:Fault")
199
+ elsif root = REXML::XPath.first(xml, "//soap:Fault")
201
200
  parse_element(reply, root)
202
201
  reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}"
203
202
  end
204
203
  reply
205
- end
204
+ end
206
205
 
207
206
  def parse_element(reply, node)
208
207
  case node.name
@@ -236,7 +235,7 @@ module ActiveMerchant #:nodoc:
236
235
  k = node.name.underscore.to_sym
237
236
  if node.has_elements?
238
237
  reply[k] = {}
239
- node.elements.each{|e| parse_element(reply[k], e) }
238
+ node.elements.each{|e| parse_element(reply[k], e) }
240
239
  else
241
240
  if node.has_attributes?
242
241
  reply[k] = {}
@@ -248,7 +247,7 @@ module ActiveMerchant #:nodoc:
248
247
  end
249
248
  reply
250
249
  end
251
-
250
+
252
251
  def currency_code(currency)
253
252
  CURRENCY_CODES[currency]
254
253
  end