activemerchant 1.56.0 → 1.66.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +331 -0
  3. data/README.md +9 -9
  4. data/lib/active_merchant/billing/check.rb +3 -0
  5. data/lib/active_merchant/billing/credit_card.rb +8 -3
  6. data/lib/active_merchant/billing/credit_card_methods.rb +41 -1
  7. data/lib/active_merchant/billing/gateway.rb +14 -6
  8. data/lib/active_merchant/billing/gateways/adyen.rb +228 -0
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +157 -44
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +7 -4
  11. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +283 -0
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +68 -2
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -2
  14. data/lib/active_merchant/billing/gateways/blue_snap.rb +348 -0
  15. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  16. data/lib/active_merchant/billing/gateways/braintree_blue.rb +58 -20
  17. data/lib/active_merchant/billing/gateways/bridge_pay.rb +37 -8
  18. data/lib/active_merchant/billing/gateways/card_stream.rb +161 -40
  19. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -0
  20. data/lib/active_merchant/billing/gateways/checkout_v2.rb +5 -2
  21. data/lib/active_merchant/billing/gateways/citrus_pay.rb +24 -0
  22. data/lib/active_merchant/billing/gateways/clearhaus.rb +24 -40
  23. data/lib/active_merchant/billing/gateways/conekta.rb +6 -1
  24. data/lib/active_merchant/billing/gateways/creditcall.rb +1 -1
  25. data/lib/active_merchant/billing/gateways/credorax.rb +310 -0
  26. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  27. data/lib/active_merchant/billing/gateways/cyber_source.rb +80 -64
  28. data/lib/active_merchant/billing/gateways/data_cash.rb +10 -304
  29. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  30. data/lib/active_merchant/billing/gateways/elavon.rb +40 -26
  31. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  32. data/lib/active_merchant/billing/gateways/fat_zebra.rb +16 -2
  33. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -1
  34. data/lib/active_merchant/billing/gateways/forte.rb +10 -2
  35. data/lib/active_merchant/billing/gateways/global_collect.rb +311 -0
  36. data/lib/active_merchant/billing/gateways/global_transport.rb +1 -0
  37. data/lib/active_merchant/billing/gateways/iats_payments.rb +13 -0
  38. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  39. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  40. data/lib/active_merchant/billing/gateways/jetpay.rb +33 -19
  41. data/lib/active_merchant/billing/gateways/kushki.rb +217 -0
  42. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  43. data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -0
  44. data/lib/active_merchant/billing/gateways/litle.rb +29 -13
  45. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  46. data/lib/active_merchant/billing/gateways/maxipago.rb +145 -122
  47. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +15 -1
  48. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +10 -7
  49. data/lib/active_merchant/billing/gateways/mercury.rb +13 -5
  50. data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -1
  51. data/lib/active_merchant/billing/gateways/migs.rb +23 -1
  52. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  53. data/lib/active_merchant/billing/gateways/moneris.rb +21 -1
  54. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -0
  55. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  56. data/lib/active_merchant/billing/gateways/netbanx.rb +245 -0
  57. data/lib/active_merchant/billing/gateways/nmi.rb +30 -9
  58. data/lib/active_merchant/billing/gateways/omise.rb +9 -5
  59. data/lib/active_merchant/billing/gateways/openpay.rb +10 -1
  60. data/lib/active_merchant/billing/gateways/opp.rb +362 -0
  61. data/lib/active_merchant/billing/gateways/orbital.rb +28 -7
  62. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  63. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  64. data/lib/active_merchant/billing/gateways/payeezy.rb +61 -12
  65. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/payflow.rb +6 -0
  67. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/paymill.rb +29 -11
  69. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -6
  71. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -2
  72. data/lib/active_merchant/billing/gateways/payu_latam.rb +402 -0
  73. data/lib/active_merchant/billing/gateways/pin.rb +6 -3
  74. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  75. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  76. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +0 -2
  78. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -1
  79. data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
  80. data/lib/active_merchant/billing/gateways/qvalent.rb +44 -1
  81. data/lib/active_merchant/billing/gateways/redsys.rb +3 -0
  82. data/lib/active_merchant/billing/gateways/s5.rb +8 -5
  83. data/lib/active_merchant/billing/gateways/safe_charge.rb +220 -0
  84. data/lib/active_merchant/billing/gateways/sage.rb +397 -128
  85. data/lib/active_merchant/billing/gateways/sage_pay.rb +45 -20
  86. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -5
  87. data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
  89. data/lib/active_merchant/billing/gateways/securion_pay.rb +46 -17
  90. data/lib/active_merchant/billing/gateways/stripe.rb +125 -29
  91. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  92. data/lib/active_merchant/billing/gateways/tns.rb +13 -222
  93. data/lib/active_merchant/billing/gateways/trans_first.rb +40 -16
  94. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +606 -0
  95. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
  96. data/lib/active_merchant/billing/gateways/vanco.rb +14 -10
  97. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  98. data/lib/active_merchant/billing/gateways/wepay.rb +73 -38
  99. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -0
  100. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  101. data/lib/active_merchant/billing/gateways/worldpay.rb +48 -16
  102. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -0
  103. data/lib/active_merchant/country.rb +6 -4
  104. data/lib/active_merchant/posts_data.rb +1 -1
  105. data/lib/active_merchant/version.rb +1 -1
  106. metadata +32 -13
  107. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  108. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  109. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  110. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -89
  111. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -115
  112. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  113. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
@@ -0,0 +1,292 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class DigitzsGateway < Gateway
4
+ include Empty
5
+
6
+ self.test_url = 'https://beta.digitzsapi.com/sandbox'
7
+ self.live_url = 'https://beta.digitzsapi.com/v3'
8
+
9
+ self.supported_countries = ['US']
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
12
+ self.money_format = :cents
13
+
14
+ self.homepage_url = 'https://digitzs.com'
15
+ self.display_name = 'Digitzs'
16
+
17
+ def initialize(options={})
18
+ requires!(options, :app_key, :api_key)
19
+ super
20
+ end
21
+
22
+ def purchase(money, payment, options={})
23
+ MultiResponse.run do |r|
24
+ r.process { commit("auth/token", app_token_request(options)) }
25
+ r.process { commit('payments', purchase_request(money, payment, options), options.merge({ app_token: app_token_from(r) })) }
26
+ end
27
+ end
28
+
29
+ def refund(money, authorization, options={})
30
+ MultiResponse.run do |r|
31
+ r.process { commit("auth/token", app_token_request(options)) }
32
+ r.process { commit('payments', refund_request(money, authorization, options), options.merge({ app_token: app_token_from(r) })) }
33
+ end
34
+ end
35
+
36
+ def store(payment, options = {})
37
+ MultiResponse.run do |r|
38
+ r.process { commit("auth/token", app_token_request(options)) }
39
+ options.merge!({ app_token: app_token_from(r) })
40
+
41
+ if options[:customer_id].present?
42
+ customer_id = check_customer_exists(options)
43
+
44
+ if customer_id
45
+ r.process { add_credit_card_to_customer(payment, options) }
46
+ else
47
+ r.process { add_customer_with_credit_card(payment, options) }
48
+ end
49
+ else
50
+ r.process { add_customer_with_credit_card(payment, options) }
51
+ end
52
+ end
53
+ end
54
+
55
+ def supports_scrubbing?
56
+ true
57
+ end
58
+
59
+ def scrub(transcript)
60
+ transcript.
61
+ gsub(%r((Authorization: Bearer ).+), '\1[FILTERED]').
62
+ gsub(%r((X-Api-Key: )\w+), '\1[FILTERED]').
63
+ gsub(%r((\"id\\\":\\\").+), '\1[FILTERED]').
64
+ gsub(%r((\"appKey\\\":\\\").+), '\1[FILTERED]').
65
+ gsub(%r((\"appToken\\\":\\\").+), '\1[FILTERED]').
66
+ gsub(%r((\"code\\\":\\\")\d+), '\1[FILTERED]').
67
+ gsub(%r((\"number\\\":\\\")\d+), '\1[FILTERED]')
68
+ end
69
+
70
+ private
71
+
72
+ def new_post
73
+ {
74
+ data: {
75
+ attributes: {}
76
+ }
77
+ }
78
+ end
79
+
80
+ def add_split(post, options)
81
+ return unless options[:payment_type] == "card_split" || options[:payment_type] == "token_split"
82
+
83
+ post[:data][:attributes][:split] = {
84
+ merchantId: options[:split_merchant_id],
85
+ amount: amount(options[:split_amount])
86
+ }
87
+ end
88
+
89
+ def add_payment(post, payment, options)
90
+ if payment.is_a? String
91
+ customer_id, token = split_authorization(payment)
92
+ post[:data][:attributes][:token] = {
93
+ customerId: customer_id,
94
+ tokenId: token
95
+ }
96
+ else
97
+ post[:data][:attributes][:card] = {
98
+ type: payment.brand,
99
+ holder: payment.name,
100
+ number: payment.number,
101
+ expiry: expdate(payment),
102
+ code: payment.verification_value
103
+ }
104
+ end
105
+ end
106
+
107
+ def add_transaction(post, money, options)
108
+ post[:data][:attributes][:transaction] = {
109
+ amount: amount(money),
110
+ currency: (options[:currency] || currency(money)),
111
+ invoice: options[:order_id] || generate_unique_id
112
+ }
113
+ end
114
+
115
+ def add_address(post, options)
116
+ if address = options[:billing_address] || options[:address]
117
+ post[:data][:attributes][:billingAddress] = {
118
+ line1: address[:address1] || "",
119
+ line2: address[:address2] || "",
120
+ city: address[:city] || "",
121
+ state: address[:state] || "",
122
+ zip: address[:zip] || "",
123
+ country: address["country"] || "USA"
124
+ }
125
+ end
126
+ end
127
+
128
+ def app_token_request(options)
129
+ post = new_post
130
+ post[:data][:type] = "auth"
131
+ post[:data][:attributes] = { appKey: @options[:app_key] }
132
+
133
+ post
134
+ end
135
+
136
+ def purchase_request(money, payment, options)
137
+ post = new_post
138
+ post[:data][:type] = "payments"
139
+ post[:data][:attributes][:merchantId] = options[:merchant_id]
140
+ post[:data][:attributes][:paymentType] = determine_payment_type(payment, options)
141
+ add_split(post, options)
142
+ add_payment(post, payment, options)
143
+ add_transaction(post, money, options)
144
+ add_address(post, options)
145
+
146
+ post
147
+ end
148
+
149
+ def refund_request(money, authorization, options)
150
+ post = new_post
151
+ post[:data][:type] = "payments"
152
+ post[:data][:attributes][:merchantId] = options[:merchant_id]
153
+ post[:data][:attributes][:paymentType] = "cardRefund"
154
+ post[:data][:attributes][:originalTransaction] = {id: authorization}
155
+ add_transaction(post, money, options)
156
+
157
+ post
158
+ end
159
+
160
+ def create_customer_request(payment, options)
161
+ post = new_post
162
+ post[:data][:type] = "customers"
163
+ post[:data][:attributes] = {
164
+ merchantId: options[:merchant_id],
165
+ name: payment.name,
166
+ externalId: "#{SecureRandom.hex(16)}"
167
+ }
168
+
169
+ post
170
+ end
171
+
172
+ def create_token_request(payment, options)
173
+ post = new_post
174
+ post[:data][:type] = "tokens"
175
+ post[:data][:attributes] = {
176
+ tokenType: "card",
177
+ customerId: options[:customer_id],
178
+ label: "Credit Card",
179
+ }
180
+ add_payment(post, payment, options)
181
+ add_address(post, options)
182
+
183
+ post
184
+ end
185
+
186
+ def check_customer_exists(options = {})
187
+ url = (test? ? test_url : live_url)
188
+ response = parse(ssl_get(url + "/customers/#{options[:customer_id]}", headers(options)))
189
+
190
+ return response.try(:[], "data").try(:[], "customerId") if success_from(response)
191
+ return nil
192
+ end
193
+
194
+ def add_credit_card_to_customer(payment, options = {})
195
+ commit('tokens', create_token_request(payment, options), options)
196
+ end
197
+
198
+ def add_customer_with_credit_card(payment, options = {})
199
+ customer_response = commit('customers', create_customer_request(payment, options), options)
200
+ options.merge!({customer_id: customer_response.authorization})
201
+ commit('tokens', create_token_request(payment, options), options)
202
+ end
203
+
204
+ def parse(body)
205
+ JSON.parse(body)
206
+ end
207
+
208
+ def commit(action, parameters, options={})
209
+ url = (test? ? test_url : live_url)
210
+ response = parse(ssl_post(url + "/#{action}", parameters.to_json, headers(options)))
211
+
212
+ Response.new(
213
+ success_from(response),
214
+ message_from(response),
215
+ response,
216
+ authorization: authorization_from(response),
217
+ avs_result: AVSResult.new(code: avs_result_from(response)),
218
+ cvv_result: CVVResult.new(cvv_result_from(response)),
219
+ test: test?,
220
+ error_code: error_code_from(response)
221
+ )
222
+ end
223
+
224
+ def success_from(response)
225
+ response["errors"].nil? && response["message"].nil?
226
+ end
227
+
228
+ def message_from(response)
229
+ return response["message"] if response["message"]
230
+ return "Success" if success_from(response)
231
+ response["errors"].map {|error_hash| error_hash["detail"] }.join(", ")
232
+ end
233
+
234
+ def authorization_from(response)
235
+ if customer_id = response.try(:[], "data").try(:[], "attributes").try(:[], "customerId")
236
+ "#{customer_id}|#{response.try(:[], "data").try(:[], "id")}"
237
+ else
238
+ response.try(:[], "data").try(:[], "id")
239
+ end
240
+ end
241
+
242
+ def avs_result_from(response)
243
+ response.try(:[], "data").try(:[], "attributes").try(:[], "transaction").try(:[], "avsResult")
244
+ end
245
+
246
+ def cvv_result_from(response)
247
+ response.try(:[], "data").try(:[], "attributes").try(:[], "transaction").try(:[], "codeResult")
248
+ end
249
+
250
+ def app_token_from(response)
251
+ response.params.try(:[], "data").try(:[], "attributes").try(:[], "appToken")
252
+ end
253
+
254
+ def headers(options)
255
+ headers = {
256
+ 'Content-Type' => 'application/json',
257
+ 'x-api-key' => @options[:api_key]
258
+ }
259
+
260
+ headers.merge!({"Authorization" => "Bearer #{options[:app_token]}"}) if options[:app_token]
261
+ headers
262
+ end
263
+
264
+ def error_code_from(response)
265
+ unless success_from(response)
266
+ response["errors"].nil? ? response["message"] : response["errors"].map {|error_hash| error_hash["code"] }.join(", ")
267
+ end
268
+ end
269
+
270
+ def split_authorization(authorization)
271
+ customer_id, token = authorization.split("|")
272
+ [customer_id, token]
273
+ end
274
+
275
+ def determine_payment_type(payment, options)
276
+ return "cardSplit" if options[:payment_type] == "card_split"
277
+ return "tokenSplit" if options[:payment_type] == "token_split"
278
+ return "token" if payment.is_a? String
279
+ "card"
280
+ end
281
+
282
+ def handle_response(response)
283
+ case response.code.to_i
284
+ when 200..499
285
+ response.body
286
+ else
287
+ raise ResponseError.new(response)
288
+ end
289
+ end
290
+ end
291
+ end
292
+ end
@@ -30,6 +30,8 @@ module ActiveMerchant #:nodoc:
30
30
  # puts response.authorization # Retrieve the unique transaction ID returned by Elavon
31
31
  #
32
32
  class ElavonGateway < Gateway
33
+ include Empty
34
+
33
35
  class_attribute :test_url, :live_url, :delimiter, :actions
34
36
 
35
37
  self.test_url = 'https://demo.myvirtualmerchant.com/VirtualMerchantDemo/process.do'
@@ -212,8 +214,8 @@ module ActiveMerchant #:nodoc:
212
214
  private
213
215
 
214
216
  def add_invoice(form,options)
215
- form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
216
- form[:description] = options[:description].to_s.slice(0, 255)
217
+ form[:invoice_number] = truncate((options[:order_id] || options[:invoice]), 10)
218
+ form[:description] = truncate(options[:description], 255)
217
219
  end
218
220
 
219
221
  def add_approval_code(form, authorization)
@@ -236,8 +238,8 @@ module ActiveMerchant #:nodoc:
236
238
  add_verification_value(form, creditcard)
237
239
  end
238
240
 
239
- form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
240
- form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
241
+ form[:first_name] = truncate(creditcard.first_name, 20)
242
+ form[:last_name] = truncate(creditcard.last_name, 30)
241
243
  end
242
244
 
243
245
  def add_token(form, token)
@@ -250,8 +252,9 @@ module ActiveMerchant #:nodoc:
250
252
  end
251
253
 
252
254
  def add_customer_data(form, options)
253
- form[:email] = options[:email].to_s.slice(0, 100) unless options[:email].blank?
254
- form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
255
+ form[:email] = truncate(options[:email], 100) unless empty?(options[:email])
256
+ form[:customer_code] = truncate(options[:customer], 10) unless empty?(options[:customer])
257
+ form[:customer_number] = options[:customer_number] unless empty?(options[:customer_number])
255
258
  end
256
259
 
257
260
  def add_salestax(form, options)
@@ -262,27 +265,27 @@ module ActiveMerchant #:nodoc:
262
265
  billing_address = options[:billing_address] || options[:address]
263
266
 
264
267
  if billing_address
265
- form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
266
- form[:address2] = billing_address[:address2].to_s.slice(0, 30)
267
- form[:avs_zip] = billing_address[:zip].to_s.gsub(/[^a-zA-Z0-9]/, '').slice(0, 9)
268
- form[:city] = billing_address[:city].to_s.slice(0, 30)
269
- form[:state] = billing_address[:state].to_s.slice(0, 10)
270
- form[:company] = billing_address[:company].to_s.slice(0, 50)
271
- form[:phone] = billing_address[:phone].to_s.slice(0, 20)
272
- form[:country] = billing_address[:country].to_s.slice(0, 50)
268
+ form[:avs_address] = truncate(billing_address[:address1], 30)
269
+ form[:address2] = truncate(billing_address[:address2], 30)
270
+ form[:avs_zip] = truncate(billing_address[:zip].to_s.gsub(/[^a-zA-Z0-9]/, ''), 9)
271
+ form[:city] = truncate(billing_address[:city], 30)
272
+ form[:state] = truncate(billing_address[:state], 10)
273
+ form[:company] = truncate(billing_address[:company], 50)
274
+ form[:phone] = truncate(billing_address[:phone], 20)
275
+ form[:country] = truncate(billing_address[:country], 50)
273
276
  end
274
277
 
275
278
  if shipping_address = options[:shipping_address]
276
279
  first_name, last_name = split_names(shipping_address[:name])
277
- form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
278
- form[:ship_to_last_name] = last_name.to_s.slice(0, 30)
279
- form[:ship_to_address1] = shipping_address[:address1].to_s.slice(0, 30)
280
- form[:ship_to_address2] = shipping_address[:address2].to_s.slice(0, 30)
281
- form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30)
282
- form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10)
283
- form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50)
284
- form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50)
285
- form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
280
+ form[:ship_to_first_name] = truncate(first_name, 20)
281
+ form[:ship_to_last_name] = truncate(last_name, 30)
282
+ form[:ship_to_address1] = truncate(shipping_address[:address1], 30)
283
+ form[:ship_to_address2] = truncate(shipping_address[:address2], 30)
284
+ form[:ship_to_city] = truncate(shipping_address[:city], 30)
285
+ form[:ship_to_state] = truncate(shipping_address[:state], 10)
286
+ form[:ship_to_company] = truncate(shipping_address[:company], 50)
287
+ form[:ship_to_country] = truncate(shipping_address[:country], 50)
288
+ form[:ship_to_zip] = truncate(shipping_address[:zip], 10)
286
289
  end
287
290
  end
288
291
 
@@ -327,7 +330,19 @@ module ActiveMerchant #:nodoc:
327
330
  def post_data(parameters)
328
331
  result = preamble
329
332
  result.merge!(parameters)
330
- result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
333
+ result.collect { |key, value| post_data_string(key, value) }.join("&")
334
+ end
335
+
336
+ def post_data_string(key, value)
337
+ if custom_field?(key)
338
+ "#{key}=#{CGI.escape(value.to_s)}"
339
+ else
340
+ "ssl_#{key}=#{CGI.escape(value.to_s)}"
341
+ end
342
+ end
343
+
344
+ def custom_field?(field_name)
345
+ field_name == :customer_number
331
346
  end
332
347
 
333
348
  def preamble
@@ -338,7 +353,7 @@ module ActiveMerchant #:nodoc:
338
353
  'result_format' => 'ASCII'
339
354
  }
340
355
 
341
- result['user_id'] = @options[:user] unless @options[:user].blank?
356
+ result['user_id'] = @options[:user] unless empty?(@options[:user])
342
357
  result
343
358
  end
344
359
 
@@ -354,4 +369,3 @@ module ActiveMerchant #:nodoc:
354
369
  end
355
370
  end
356
371
  end
357
-