activemerchant 1.28.0 → 1.29.1

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 (117) hide show
  1. data/CHANGELOG +41 -0
  2. data/CONTRIBUTORS +12 -0
  3. data/README.md +6 -0
  4. data/lib/active_merchant/billing/gateway.rb +2 -1
  5. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  6. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  7. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  8. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  9. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  10. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  11. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  12. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  13. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  14. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  16. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  17. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  18. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  19. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  20. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  21. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  22. data/lib/active_merchant/billing/gateways/eway_rapid.rb +300 -0
  23. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  24. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  25. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  26. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  27. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  28. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  29. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  30. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  31. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  32. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  33. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  34. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  35. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  36. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  37. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  38. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  39. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  40. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  41. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  42. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  43. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  44. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  45. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  46. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  47. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  48. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  49. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  50. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  51. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  54. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  55. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  56. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  57. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  58. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  59. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  62. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  63. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  64. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  65. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  66. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  67. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  68. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  69. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  70. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  71. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  72. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  75. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  76. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  77. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  78. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  79. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  80. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  81. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  82. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  83. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  84. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  85. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  86. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  87. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  88. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  89. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  90. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  91. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  92. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  93. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  94. data/lib/active_merchant/billing/gateways.rb +6 -7
  95. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  99. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
  102. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -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/common.rb +42 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -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 +17 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. data.tar.gz.sig +0 -0
  116. metadata +46 -27
  117. metadata.gz.sig +0 -0
@@ -10,22 +10,21 @@ module ActiveMerchant #:nodoc:
10
10
  self.abstract_class = true
11
11
 
12
12
  # Creates a new SageGateway
13
- #
13
+ #
14
14
  # The gateway requires that a valid login and password be passed
15
15
  # in the +options+ hash.
16
- #
16
+ #
17
17
  # ==== Options
18
18
  #
19
19
  # * <tt>:login</tt> - The Sage Payment Solutions Merchant ID Number.
20
20
  # * <tt>:password</tt> - The Sage Payment Solutions Merchant Key Number.
21
21
  def initialize(options = {})
22
22
  requires!(options, :login, :password)
23
- @options = options
24
23
  super
25
24
  end
26
-
25
+
27
26
  # Performs an authorization transaction
28
- #
27
+ #
29
28
  # ==== Parameters
30
29
  # * <tt>money</tt> - The amount to be authorized as an integer value in cents.
31
30
  # * <tt>credit_card</tt> - The CreditCard object to be used as the funding source for the transaction.
@@ -42,20 +41,20 @@ module ActiveMerchant #:nodoc:
42
41
  # * <tt>:phone</tt> - The billing address phone number
43
42
  # * <tt>:fax</tt> - The billing address fax number
44
43
  # * <tt>:shipping_address</tt> - The customer's shipping address as a hash of address information.
45
- # * <tt>:name</tt> - The name at the shipping address
44
+ # * <tt>:name</tt> - The name at the shipping address
46
45
  # * <tt>:address1</tt> - The shipping address street
47
46
  # * <tt>:city</tt> - The shipping address city
48
47
  # * <tt>:state</tt> - The shipping address state code
49
48
  # * <tt>:country</tt> - The 2 digit ISO shipping address country code
50
49
  # * <tt>:zip</tt> - The shipping address zip code
51
50
  # * <tt>:tax</tt> - The tax amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_tax</tt>.
52
- # * <tt>:shipping</tt> - The shipping amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_shipping</tt>.
51
+ # * <tt>:shipping</tt> - The shipping amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_shipping</tt>.
53
52
  def authorize(money, credit_card, options = {})
54
53
  bankcard.authorize(money, credit_card, options)
55
54
  end
56
-
55
+
57
56
  # Performs a purchase, which is essentially an authorization and capture in a single operation.
58
- #
57
+ #
59
58
  # ==== Parameters
60
59
  #
61
60
  # * <tt>money</tt> - The amount to be authorized as an integer value in cents.
@@ -73,7 +72,7 @@ module ActiveMerchant #:nodoc:
73
72
  # * <tt>:phone</tt> - The billing address phone number
74
73
  # * <tt>:fax</tt> - The billing address fax number
75
74
  # * <tt>:shipping_address</tt> - The customer's shipping address as a hash of address information.
76
- # * <tt>:name</tt> - The name at the shipping address
75
+ # * <tt>:name</tt> - The name at the shipping address
77
76
  # * <tt>:address1</tt> - The shipping address street
78
77
  # * <tt>:city</tt> - The shipping address city
79
78
  # * <tt>:state</tt> - The shipping address state code
@@ -95,8 +94,8 @@ module ActiveMerchant #:nodoc:
95
94
  else
96
95
  bankcard.purchase(money, source, options)
97
96
  end
98
- end
99
-
97
+ end
98
+
100
99
  # Captures authorized funds.
101
100
  #
102
101
  # ==== Parameters
@@ -106,7 +105,7 @@ module ActiveMerchant #:nodoc:
106
105
  def capture(money, reference, options = {})
107
106
  bankcard.capture(money, reference, options)
108
107
  end
109
-
108
+
110
109
  # Voids a prior transaction. Works for both CreditCard and Check transactions.
111
110
  #
112
111
  # ==== Parameters
@@ -133,15 +132,15 @@ module ActiveMerchant #:nodoc:
133
132
  bankcard.credit(money, source, options)
134
133
  end
135
134
  end
136
-
135
+
137
136
  private
138
137
  def bankcard
139
138
  @bankcard ||= SageBankcardGateway.new(@options)
140
139
  end
141
-
140
+
142
141
  def virtual_check
143
142
  @virtual_check ||= SageVirtualCheckGateway.new(@options)
144
- end
143
+ end
145
144
  end
146
145
  end
147
146
  end
@@ -1,6 +1,6 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
- class SagePayGateway < Gateway
3
+ class SagePayGateway < Gateway
4
4
  cattr_accessor :simulate
5
5
  self.simulate = false
6
6
 
@@ -9,9 +9,9 @@ module ActiveMerchant #:nodoc:
9
9
  self.test_url = 'https://test.sagepay.com/gateway/service'
10
10
  self.live_url = 'https://live.sagepay.com/gateway/service'
11
11
  self.simulator_url = 'https://test.sagepay.com/Simulator'
12
-
12
+
13
13
  APPROVED = 'OK'
14
-
14
+
15
15
  TRANSACTIONS = {
16
16
  :purchase => 'PAYMENT',
17
17
  :credit => 'REFUND',
@@ -20,7 +20,7 @@ module ActiveMerchant #:nodoc:
20
20
  :void => 'VOID',
21
21
  :abort => 'ABORT'
22
22
  }
23
-
23
+
24
24
  CREDIT_CARDS = {
25
25
  :visa => "VISA",
26
26
  :master => "MC",
@@ -35,36 +35,31 @@ module ActiveMerchant #:nodoc:
35
35
  }
36
36
 
37
37
  ELECTRON = /^(424519|42496[23]|450875|48440[6-8]|4844[1-5][1-5]|4917[3-5][0-9]|491880)\d{10}(\d{3})?$/
38
-
38
+
39
39
  AVS_CVV_CODE = {
40
- "NOTPROVIDED" => nil,
40
+ "NOTPROVIDED" => nil,
41
41
  "NOTCHECKED" => 'X',
42
42
  "MATCHED" => 'Y',
43
43
  "NOTMATCHED" => 'N'
44
44
  }
45
-
45
+
46
46
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :switch, :solo, :maestro, :diners_club]
47
47
  self.supported_countries = ['GB']
48
48
  self.default_currency = 'GBP'
49
-
49
+
50
50
  self.homepage_url = 'http://www.sagepay.com'
51
51
  self.display_name = 'SagePay'
52
52
 
53
53
  def initialize(options = {})
54
54
  requires!(options, :login)
55
- @options = options
56
55
  super
57
56
  end
58
-
59
- def test?
60
- @options[:test] || super
61
- end
62
-
57
+
63
58
  def purchase(money, credit_card, options = {})
64
59
  requires!(options, :order_id)
65
-
60
+
66
61
  post = {}
67
-
62
+
68
63
  add_amount(post, money, options)
69
64
  add_invoice(post, options)
70
65
  add_credit_card(post, credit_card)
@@ -73,12 +68,12 @@ module ActiveMerchant #:nodoc:
73
68
 
74
69
  commit(:purchase, post)
75
70
  end
76
-
71
+
77
72
  def authorize(money, credit_card, options = {})
78
73
  requires!(options, :order_id)
79
-
74
+
80
75
  post = {}
81
-
76
+
82
77
  add_amount(post, money, options)
83
78
  add_invoice(post, options)
84
79
  add_credit_card(post, credit_card)
@@ -87,20 +82,20 @@ module ActiveMerchant #:nodoc:
87
82
 
88
83
  commit(:authorization, post)
89
84
  end
90
-
85
+
91
86
  # You can only capture a transaction once, even if you didn't capture the full amount the first time.
92
87
  def capture(money, identification, options = {})
93
88
  post = {}
94
-
89
+
95
90
  add_reference(post, identification)
96
91
  add_release_amount(post, money, options)
97
-
92
+
98
93
  commit(:capture, post)
99
94
  end
100
-
95
+
101
96
  def void(identification, options = {})
102
97
  post = {}
103
-
98
+
104
99
  add_reference(post, identification)
105
100
  action = abort_or_void_from(identification)
106
101
 
@@ -110,13 +105,13 @@ module ActiveMerchant #:nodoc:
110
105
  # Refunding requires a new order_id to passed in, as well as a description
111
106
  def refund(money, identification, options = {})
112
107
  requires!(options, :order_id, :description)
113
-
108
+
114
109
  post = {}
115
-
110
+
116
111
  add_credit_reference(post, identification)
117
112
  add_amount(post, money, options)
118
113
  add_invoice(post, options)
119
-
114
+
120
115
  commit(:credit, post)
121
116
  end
122
117
 
@@ -124,26 +119,26 @@ module ActiveMerchant #:nodoc:
124
119
  deprecated CREDIT_DEPRECATION_MESSAGE
125
120
  refund(money, identification, options)
126
121
  end
127
-
122
+
128
123
  private
129
124
  def add_reference(post, identification)
130
- order_id, transaction_id, authorization, security_key = identification.split(';')
131
-
125
+ order_id, transaction_id, authorization, security_key = identification.split(';')
126
+
132
127
  add_pair(post, :VendorTxCode, order_id)
133
128
  add_pair(post, :VPSTxId, transaction_id)
134
129
  add_pair(post, :TxAuthNo, authorization)
135
130
  add_pair(post, :SecurityKey, security_key)
136
131
  end
137
-
132
+
138
133
  def add_credit_reference(post, identification)
139
- order_id, transaction_id, authorization, security_key = identification.split(';')
140
-
134
+ order_id, transaction_id, authorization, security_key = identification.split(';')
135
+
141
136
  add_pair(post, :RelatedVendorTxCode, order_id)
142
137
  add_pair(post, :RelatedVPSTxId, transaction_id)
143
138
  add_pair(post, :RelatedTxAuthNo, authorization)
144
139
  add_pair(post, :RelatedSecurityKey, security_key)
145
140
  end
146
-
141
+
147
142
  def add_amount(post, money, options)
148
143
  currency = options[:currency] || currency(money)
149
144
  add_pair(post, :Amount, localized_amount(money, currency), :required => true)
@@ -173,7 +168,7 @@ module ActiveMerchant #:nodoc:
173
168
  add_pair(post, :BillingCountry, billing_address[:country])
174
169
  add_pair(post, :BillingPostCode, billing_address[:zip])
175
170
  end
176
-
171
+
177
172
  if shipping_address = options[:shipping_address] || billing_address
178
173
  first_name, last_name = parse_first_and_last_name(shipping_address[:name])
179
174
  add_pair(post, :DeliverySurname, last_name)
@@ -195,59 +190,59 @@ module ActiveMerchant #:nodoc:
195
190
  def add_credit_card(post, credit_card)
196
191
  add_pair(post, :CardHolder, credit_card.name, :required => true)
197
192
  add_pair(post, :CardNumber, credit_card.number, :required => true)
198
-
193
+
199
194
  add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true)
200
-
195
+
201
196
  if requires_start_date_or_issue_number?(credit_card)
202
197
  add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year))
203
198
  add_pair(post, :IssueNumber, credit_card.issue_number)
204
199
  end
205
200
  add_pair(post, :CardType, map_card_type(credit_card))
206
-
201
+
207
202
  add_pair(post, :CV2, credit_card.verification_value)
208
203
  end
209
-
204
+
210
205
  def sanitize_order_id(order_id)
211
206
  order_id.to_s.gsub(/[^-a-zA-Z0-9._]/, '')
212
207
  end
213
-
208
+
214
209
  def map_card_type(credit_card)
215
210
  raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank?
216
-
211
+
217
212
  card_type = card_brand(credit_card).to_sym
218
-
213
+
219
214
  # Check if it is an electron card
220
- if card_type == :visa && credit_card.number =~ ELECTRON
215
+ if card_type == :visa && credit_card.number =~ ELECTRON
221
216
  CREDIT_CARDS[:electron]
222
- else
217
+ else
223
218
  CREDIT_CARDS[card_type]
224
219
  end
225
220
  end
226
-
221
+
227
222
  # MMYY format
228
223
  def format_date(month, year)
229
224
  return nil if year.blank? || month.blank?
230
-
225
+
231
226
  year = sprintf("%.4i", year)
232
227
  month = sprintf("%.2i", month)
233
228
 
234
229
  "#{month}#{year[-2..-1]}"
235
230
  end
236
-
231
+
237
232
  def commit(action, parameters)
238
233
  response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
239
-
234
+
240
235
  Response.new(response["Status"] == APPROVED, message_from(response), response,
241
236
  :test => test?,
242
237
  :authorization => authorization_from(response, parameters, action),
243
- :avs_result => {
238
+ :avs_result => {
244
239
  :street_match => AVS_CVV_CODE[ response["AddressResult"] ],
245
240
  :postal_match => AVS_CVV_CODE[ response["PostCodeResult"] ],
246
241
  },
247
242
  :cvv_result => AVS_CVV_CODE[ response["CV2Result"] ]
248
243
  )
249
244
  end
250
-
245
+
251
246
  def authorization_from(response, params, action)
252
247
  [ params[:VendorTxCode],
253
248
  response["VPSTxId"],
@@ -264,12 +259,12 @@ module ActiveMerchant #:nodoc:
264
259
  def url_for(action)
265
260
  simulate ? build_simulator_url(action) : build_url(action)
266
261
  end
267
-
262
+
268
263
  def build_url(action)
269
264
  endpoint = [ :purchase, :authorization ].include?(action) ? "vspdirect-register" : TRANSACTIONS[action].downcase
270
265
  "#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
271
266
  end
272
-
267
+
273
268
  def build_simulator_url(action)
274
269
  endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
275
270
  "#{self.simulator_url}/#{endpoint}"
@@ -285,10 +280,10 @@ module ActiveMerchant #:nodoc:
285
280
  :TxType => TRANSACTIONS[action],
286
281
  :VPSProtocol => "2.23"
287
282
  )
288
-
283
+
289
284
  parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
290
285
  end
291
-
286
+
292
287
  # SagePay returns data in the following format
293
288
  # Key1=value1
294
289
  # Key2=value2
@@ -306,12 +301,12 @@ module ActiveMerchant #:nodoc:
306
301
 
307
302
  def parse_first_and_last_name(value)
308
303
  name = value.to_s.split(' ')
309
-
304
+
310
305
  last_name = name.pop || ''
311
306
  first_name = name.join(' ')
312
307
  [ first_name[0,20], last_name[0,20] ]
313
308
  end
314
-
309
+
315
310
  def localized_amount(money, currency)
316
311
  amount = amount(money)
317
312
  CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s) ? amount.split('.').first : amount
@@ -17,10 +17,9 @@ module ActiveMerchant #:nodoc:
17
17
 
18
18
  def initialize(options = {})
19
19
  requires!(options, :login)
20
- @options = options
21
20
  super
22
21
  end
23
-
22
+
24
23
  def test?
25
24
  @options[:login] == "TEST0"
26
25
  end
@@ -17,16 +17,13 @@ module ActiveMerchant #:nodoc:
17
17
  end
18
18
 
19
19
  requires!(options, :login, :password, :processor_token)
20
- @options = options
21
20
  Samurai.options = {
22
21
  :merchant_key => options[:login],
23
22
  :merchant_password => options[:password],
24
23
  :processor_token => options[:processor_token]
25
24
  }
26
- end
27
25
 
28
- def test?
29
- @options[:test] || super
26
+ super
30
27
  end
31
28
 
32
29
  def authorize(money, credit_card_or_vault_id, options = {})
@@ -58,7 +58,6 @@ module ActiveMerchant #:nodoc:
58
58
 
59
59
  def initialize(options = {})
60
60
  requires!(options, :login, :password)
61
- @options = options
62
61
  super
63
62
  end
64
63
 
@@ -4,24 +4,21 @@ module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  class SecurePayGateway < AuthorizeNetGateway
6
6
  self.live_url = self.test_url = 'https://www.securepay.com/AuthSpayAdapter/process.aspx'
7
-
7
+
8
8
  self.homepage_url = 'http://www.securepay.com/'
9
9
  self.display_name = 'SecurePay'
10
-
10
+
11
11
  # Limit support to purchase() for the time being
12
12
  # JRuby chokes here
13
13
  # undef_method :authorize, :capture, :void, :credit
14
-
14
+
15
15
  undef_method :authorize
16
16
  undef_method :capture
17
17
  undef_method :void
18
18
  undef_method :credit
19
-
20
- def test?
21
- Base.gateway_mode == :test
22
- end
23
-
19
+
24
20
  private
21
+
25
22
  def split(response)
26
23
  response.split(',')
27
24
  end
@@ -58,14 +58,9 @@ module ActiveMerchant #:nodoc:
58
58
 
59
59
  def initialize(options = {})
60
60
  requires!(options, :login, :password)
61
- @options = options
62
61
  super
63
62
  end
64
63
 
65
- def test?
66
- @options[:test] || super
67
- end
68
-
69
64
  def purchase(money, credit_card_or_stored_id, options = {})
70
65
  if credit_card_or_stored_id.respond_to?(:number)
71
66
  requires!(options, :order_id)
@@ -18,7 +18,7 @@ module ActiveMerchant #:nodoc:
18
18
  8 => "Bad or malformed request",
19
19
  9 => "Invalid card number"
20
20
  }
21
-
21
+
22
22
  self.default_currency = 'NZD'
23
23
  self.supported_countries = ['NZ']
24
24
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
@@ -27,33 +27,32 @@ module ActiveMerchant #:nodoc:
27
27
 
28
28
  def initialize(options = {})
29
29
  requires!(options, :login, :password)
30
- @options = options
31
30
  super
32
- end
33
-
31
+ end
32
+
34
33
  def purchase(money, creditcard, options = {})
35
34
  post = SecurePayTechPostData.new
36
35
 
37
36
  add_invoice(post, money, options)
38
- add_creditcard(post, creditcard)
39
-
37
+ add_creditcard(post, creditcard)
38
+
40
39
  commit(:purchase, post)
41
- end
42
-
43
- private
44
-
40
+ end
41
+
42
+ private
43
+
45
44
  def add_invoice(post, money, options)
46
45
  post[:Amount] = amount(money)
47
46
  post[:Currency] = options[:currency] || currency(money)
48
47
 
49
48
  post[:OrderReference] = options[:order_id]
50
49
  end
51
-
50
+
52
51
  def add_creditcard(post, creditcard)
53
52
  post[:CardNumber] = creditcard.number
54
53
  post[:CardExpiry] = expdate(creditcard)
55
54
  post[:CardHolderName] = creditcard.name
56
-
55
+
57
56
  if creditcard.verification_value?
58
57
  post[:EnableCSC] = true
59
58
  post[:CSC] = creditcard.verification_value
@@ -62,7 +61,7 @@ module ActiveMerchant #:nodoc:
62
61
  # SPT will autodetect this
63
62
  post[:CardType] = 0
64
63
  end
65
-
64
+
66
65
  def parse(body)
67
66
  response = CGI.unescape(body).split(',')
68
67
 
@@ -80,13 +79,13 @@ module ActiveMerchant #:nodoc:
80
79
  end
81
80
 
82
81
  result
83
- end
84
-
82
+ end
83
+
85
84
  def commit(action, post)
86
85
  response = parse( ssl_post(self.live_url, post_data(action, post) ) )
87
86
 
88
- Response.new(response[:result_code] == 1, message_from(response), response,
89
- :test => test?,
87
+ Response.new(response[:result_code] == 1, message_from(response), response,
88
+ :test => test?,
90
89
  :authorization => response[:merchant_transaction_reference]
91
90
  )
92
91
  end
@@ -94,7 +93,7 @@ module ActiveMerchant #:nodoc:
94
93
  def message_from(result)
95
94
  PAYMENT_GATEWAY_RESPONSES[result[:result_code]]
96
95
  end
97
-
96
+
98
97
  def post_data(action, post)
99
98
  post[:MerchantID] = @options[:login]
100
99
  post[:MerchantKey] = @options[:password]