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
@@ -0,0 +1,93 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class OrbitalGateway < Gateway
4
+ # Unfortunately, Orbital uses their own special codes for AVS responses
5
+ # that are different than the standard codes defined in
6
+ # <tt>ActiveMerchant::Billing::AVSResult</tt>.
7
+ #
8
+ # This class encapsulates the response codes shown on page 240 of their spec:
9
+ # http://download.chasepaymentech.com/docs/orbital/orbital_gateway_xml_specification.pdf
10
+ #
11
+ class AVSResult < ActiveMerchant::Billing::AVSResult
12
+ CODES = {
13
+ '1' => 'No address supplied',
14
+ '2' => 'Bill-to address did not pass Auth Host edit checks',
15
+ '3' => 'AVS not performed',
16
+ '4' => 'Issuer does not participate in AVS',
17
+ '5' => 'Edit-error - AVS data is invalid',
18
+ '6' => 'System unavailable or time-out',
19
+ '7' => 'Address information unavailable',
20
+ '8' => 'Transaction Ineligible for AVS',
21
+ '9' => 'Zip Match/Zip 4 Match/Locale match',
22
+ 'A' => 'Zip Match/Zip 4 Match/Locale no match',
23
+ 'B' => 'Zip Match/Zip 4 no Match/Locale match',
24
+ 'C' => 'Zip Match/Zip 4 no Match/Locale no match',
25
+ 'D' => 'Zip No Match/Zip 4 Match/Locale match',
26
+ 'E' => 'Zip No Match/Zip 4 Match/Locale no match',
27
+ 'F' => 'Zip No Match/Zip 4 No Match/Locale match',
28
+ 'G' => 'No match at all',
29
+ 'H' => 'Zip Match/Locale match',
30
+ 'J' => 'Issuer does not participate in Global AVS',
31
+ 'JA' => 'International street address and postal match',
32
+ 'JB' => 'International street address match. Postal code not verified',
33
+ 'JC' => 'International street address and postal code not verified',
34
+ 'JD' => 'International postal code match. Street address not verified',
35
+ 'M1' => 'Merchant Override Decline',
36
+ 'M2' => 'Cardholder name, billing address, and postal code matches',
37
+ 'M3' => 'Cardholder name and billing code matches',
38
+ 'M4' => 'Cardholder name and billing address matches',
39
+ 'M5' => 'Cardholder name incorrect, billing address and postal code match',
40
+ 'M6' => 'Cardholder name incorrect, billing address matches',
41
+ 'M7' => 'Cardholder name incorrect, billing address matches',
42
+ 'M8' => 'Cardholder name, billing address and postal code are all incorrect',
43
+ 'N3' => 'Address matches, ZIP not verified',
44
+ 'N4' => 'Address and ZIP code not verified due to incompatible formats',
45
+ 'N5' => 'Address and ZIP code match (International only)',
46
+ 'N6' => 'Address not verified (International only)',
47
+ 'N7' => 'ZIP matches, address not verified',
48
+ 'N8' => 'Address and ZIP code match (International only)',
49
+ 'N9' => 'Address and ZIP code match (UK only)',
50
+ 'R' => 'Issuer does not participate in AVS',
51
+ 'UX' => 'Unknown',
52
+ 'X' => 'Zip Match/Zip 4 Match/Address Match',
53
+ 'Z' => 'Zip Match/Locale no match',
54
+ }
55
+
56
+ # Map vendor's AVS result code to a postal match code
57
+ ORBITAL_POSTAL_MATCH_CODE = {
58
+ 'Y' => %w( 9 A B C H JA JD M2 M3 M5 N5 N8 N9 X Z ),
59
+ 'N' => %w( D E F G M8 ),
60
+ 'X' => %w( 4 J R ),
61
+ nil => %w( 1 2 3 5 6 7 8 JB JC M1 M4 M6 M7 N3 N4 N6 N7 UX )
62
+ }.inject({}) do |map, (type, codes)|
63
+ codes.each { |code| map[code] = type }
64
+ map
65
+ end
66
+
67
+ # Map vendor's AVS result code to a street match code
68
+ ORBITAL_STREET_MATCH_CODE = {
69
+ 'Y' => %w( 9 B D F H JA JB M2 M4 M5 M6 M7 N3 N5 N7 N8 N9 X ),
70
+ 'N' => %w( A C E G M8 Z ),
71
+ 'X' => %w( 4 J R ),
72
+ nil => %w( 1 2 3 5 6 7 8 JC JD M1 M3 N4 N6 UX )
73
+ }.inject({}) do |map, (type, codes)|
74
+ codes.each { |code| map[code] = type }
75
+ map
76
+ end
77
+
78
+ def self.messages
79
+ CODES
80
+ end
81
+
82
+ def initialize(code)
83
+ @code = code.to_s.strip.upcase unless code.blank?
84
+ if @code
85
+ @message = CODES[@code]
86
+ @postal_match = ORBITAL_POSTAL_MATCH_CODE[@code]
87
+ @street_match = ORBITAL_STREET_MATCH_CODE[@code]
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -157,12 +157,11 @@ module ActiveMerchant #:nodoc:
157
157
 
158
158
  def initialize(options = {})
159
159
  requires!(options, :login, :password)
160
- @options = options
161
160
  super
162
161
  end
163
162
 
164
163
  def purchase(money, creditcard, options = {})
165
- MultiResponse.new.tap do |r|
164
+ MultiResponse.run do |r|
166
165
  r.process{authorize(money, creditcard, options)}
167
166
  r.process{capture(money, r.authorization, options)}
168
167
  end
@@ -182,10 +181,6 @@ module ActiveMerchant #:nodoc:
182
181
  commit(action, build_request(action, options))
183
182
  end
184
183
 
185
- def test?
186
- @options[:test] || (Base.gateway_mode == :test)
187
- end
188
-
189
184
  private
190
185
 
191
186
  def successful?(response)
@@ -5,11 +5,11 @@ module ActiveMerchant #:nodoc:
5
5
  # This gateway accepts the following arguments:
6
6
  # :login => your PayJunction username
7
7
  # :password => your PayJunction pass
8
- #
8
+ #
9
9
  # Example use:
10
10
  #
11
11
  # gateway = ActiveMerchant::Billing::Base.gateway(:pay_junction).new(
12
- # :login => "my_account",
12
+ # :login => "my_account",
13
13
  # :password => "my_pass"
14
14
  # )
15
15
  #
@@ -51,14 +51,14 @@ module ActiveMerchant #:nodoc:
51
51
  # Test Transactions
52
52
  #
53
53
  # See the source for initialize() for test account information. Note that
54
- # PayJunction does not allow test transactions on your account, so if the
54
+ # PayJunction does not allow test transactions on your account, so if the
55
55
  # gateway is running in :test mode your transaction will be run against
56
56
  # PayJunction's global test account and will not show up in your account.
57
57
  #
58
- # Transactions ran on this account go through a test processor, so there is no
59
- # need to void or otherwise cancel transactions. However, for further safety,
60
- # please use the special card numbers 4433221111223344 or 4444333322221111 and
61
- # keep transaction amounts below $4.00 when testing.
58
+ # Transactions ran on this account go through a test processor, so there is no
59
+ # need to void or otherwise cancel transactions. However, for further safety,
60
+ # please use the special card numbers 4433221111223344 or 4444333322221111 and
61
+ # keep transaction amounts below $4.00 when testing.
62
62
  #
63
63
  # Also note, transactions ran for an amount between $0.00 and $1.99 will likely
64
64
  # result in denial. To demonstrate approvals, use amounts between $2.00 and $4.00.
@@ -67,12 +67,12 @@ module ActiveMerchant #:nodoc:
67
67
  # PayJunction Web Login with username 'pj-cm-01' and password 'pj-cm-01p'
68
68
  #
69
69
  # Usage Details
70
- #
70
+ #
71
71
  # Below is a map of values accepted by PayJunction and how you should submit
72
72
  # each to ActiveMerchant
73
73
  #
74
74
  # PayJunction Field ActiveMerchant Use
75
- #
75
+ #
76
76
  # dc_logon provide as :login value to gateway instantation
77
77
  # dc_password provide as :password value to gateway instantiation
78
78
  #
@@ -106,12 +106,12 @@ module ActiveMerchant #:nodoc:
106
106
 
107
107
  TEST_LOGIN = 'pj-ql-01'
108
108
  TEST_PASSWORD = 'pj-ql-01p'
109
-
109
+
110
110
  SUCCESS_CODES = ["00", "85"]
111
111
  SUCCESS_MESSAGE = 'The transaction was approved.'
112
-
112
+
113
113
  FAILURE_MESSAGE = 'The transaction was declined.'
114
-
114
+
115
115
  DECLINE_CODES = {
116
116
  "AE" => 'Address verification failed because address did not match.',
117
117
  'ZE' => 'Address verification failed because zip did not match.',
@@ -143,13 +143,13 @@ module ActiveMerchant #:nodoc:
143
143
  '15' => 'Declined because there is no such issuer.',
144
144
  '96' => 'Declined because of a system error.',
145
145
  'N7' => 'Declined because of a CVV2/CVC2 mismatch.',
146
- 'M4' => 'Declined.',
146
+ 'M4' => 'Declined.',
147
147
  "FE" => "There was a format error with your Trinity Gateway Service (API) request.",
148
148
  "LE" => "Could not log you in (problem with dc_logon and/or dc_password).",
149
149
  'NL' => 'Aborted because of a system error, please try again later. ',
150
150
  'AB' => 'Aborted because of an upstream system error, please try again later.'
151
151
  }
152
-
152
+
153
153
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
154
154
  self.supported_countries = ['US']
155
155
  self.homepage_url = 'http://www.payjunction.com/'
@@ -157,31 +157,30 @@ module ActiveMerchant #:nodoc:
157
157
 
158
158
  def initialize(options = {})
159
159
  requires!(options, :login, :password)
160
- @options = options
161
160
  super
162
161
  end
163
-
162
+
164
163
  # The first half of the preauth(authorize)/postauth(capture) model.
165
164
  # Checks to make sure funds are available for a transaction, and returns a
166
165
  # transaction_id that can be used later to postauthorize (capture) the funds.
167
166
  def authorize(money, payment_source, options = {})
168
167
  parameters = {
169
168
  :transaction_amount => amount(money),
170
- }
171
-
169
+ }
170
+
172
171
  add_payment_source(parameters, payment_source)
173
172
  add_address(parameters, options)
174
173
  add_optional_fields(parameters, options)
175
174
  commit('AUTHORIZATION', parameters)
176
175
  end
177
-
176
+
178
177
  # A simple sale, capturing funds immediately.
179
178
  # Execute authorization and capture in a single step.
180
- def purchase(money, payment_source, options = {})
179
+ def purchase(money, payment_source, options = {})
181
180
  parameters = {
182
181
  :transaction_amount => amount(money),
183
- }
184
-
182
+ }
183
+
185
184
  add_payment_source(parameters, payment_source)
186
185
  add_address(parameters, options)
187
186
  add_optional_fields(parameters, options)
@@ -195,14 +194,14 @@ module ActiveMerchant #:nodoc:
195
194
  :transaction_id => authorization,
196
195
  :posture => 'capture'
197
196
  }
198
-
199
- add_optional_fields(parameters, options)
197
+
198
+ add_optional_fields(parameters, options)
200
199
  commit('update', parameters)
201
200
  end
202
-
201
+
203
202
  # Return money to a card that was previously billed.
204
203
  # _authorization_ should be the transaction id of the transaction we are returning.
205
- def refund(money, authorization, options = {})
204
+ def refund(money, authorization, options = {})
206
205
  parameters = {
207
206
  :transaction_amount => amount(money),
208
207
  :transaction_id => authorization
@@ -228,7 +227,7 @@ module ActiveMerchant #:nodoc:
228
227
  commit('update', parameters)
229
228
  end
230
229
 
231
- # Set up a sale that will be made on a regular basis for the same amount
230
+ # Set up a sale that will be made on a regular basis for the same amount
232
231
  # (ex. $20 a month for 12 months)
233
232
  #
234
233
  # The parameter :periodicity should be specified as either :monthly, :weekly, or :daily
@@ -236,12 +235,12 @@ module ActiveMerchant #:nodoc:
236
235
  #
237
236
  # gateway.recurring('2000', creditcard, :periodicity => :monthly, :payments => 12)
238
237
  #
239
- # The optional parameter :starting_at takes a date or time argument or a string in
240
- # YYYYMMDD format and can be used to specify when the first charge will be made.
241
- # If omitted the first charge will be immediate.
242
- def recurring(money, payment_source, options = {})
238
+ # The optional parameter :starting_at takes a date or time argument or a string in
239
+ # YYYYMMDD format and can be used to specify when the first charge will be made.
240
+ # If omitted the first charge will be immediate.
241
+ def recurring(money, payment_source, options = {})
243
242
  requires!(options, [:periodicity, :monthly, :weekly, :daily], :payments)
244
-
243
+
245
244
  periodic_type = case options[:periodicity]
246
245
  when :monthly
247
246
  'month'
@@ -250,7 +249,7 @@ module ActiveMerchant #:nodoc:
250
249
  when :daily
251
250
  'day'
252
251
  end
253
-
252
+
254
253
  if options[:starting_at].nil?
255
254
  start_date = Time.now.strftime('%Y-%m-%d')
256
255
  elsif options[:starting_at].is_a?(String)
@@ -259,7 +258,7 @@ module ActiveMerchant #:nodoc:
259
258
  else
260
259
  start_date = options[:starting_at].strftime('%Y-%m-%d')
261
260
  end
262
-
261
+
263
262
  parameters = {
264
263
  :transaction_amount => amount(money),
265
264
  :schedule_periodic_type => periodic_type,
@@ -268,23 +267,23 @@ module ActiveMerchant #:nodoc:
268
267
  :schedule_periodic_number => 1,
269
268
  :schedule_start => start_date
270
269
  }
271
-
270
+
272
271
  add_payment_source(parameters, payment_source)
273
272
  add_optional_fields(parameters, options)
274
- add_address(parameters, options)
273
+ add_address(parameters, options)
275
274
  commit('AUTHORIZATION_CAPTURE', parameters)
276
275
  end
277
-
276
+
278
277
  def test?
279
- test_login? || @options[:test] || super
278
+ (test_login? || super)
280
279
  end
281
280
 
282
281
  private
283
-
282
+
284
283
  def test_login?
285
284
  @options[:login] == TEST_LOGIN && @options[:password] == TEST_PASSWORD
286
285
  end
287
-
286
+
288
287
  # add fields depending on payment source selected (cc or transaction id)
289
288
  def add_payment_source(params, source)
290
289
  if source.is_a?(String)
@@ -293,54 +292,54 @@ module ActiveMerchant #:nodoc:
293
292
  add_creditcard(params, source)
294
293
  end
295
294
  end
296
-
295
+
297
296
  # add fields for credit card
298
297
  def add_creditcard(params, creditcard)
299
298
  params[:name] = creditcard.name
300
299
  params[:number] = creditcard.number
301
300
  params[:expiration_month] = creditcard.month
302
- params[:expiration_year] = creditcard.year
301
+ params[:expiration_year] = creditcard.year
303
302
  params[:verification_number] = creditcard.verification_value if creditcard.verification_value?
304
303
  end
305
-
304
+
306
305
  # add field for "instant" transaction, using previous transaction id
307
306
  def add_billing_id(params, billingid)
308
307
  params[:transaction_id] = billingid
309
308
  end
310
-
309
+
311
310
  # add address fields if present
312
311
  def add_address(params, options)
313
312
  address = options[:billing_address] || options[:address]
314
-
315
- if address
313
+
314
+ if address
316
315
  params[:address] = address[:address1] unless address[:address1].blank?
317
316
  params[:city] = address[:city] unless address[:city].blank?
318
317
  params[:state] = address[:state] unless address[:state].blank?
319
318
  params[:zipcode] = address[:zip] unless address[:zip].blank?
320
319
  params[:country] = address[:country] unless address[:country].blank?
321
- end
320
+ end
322
321
  end
323
-
322
+
324
323
  def add_optional_fields(params, options)
325
324
  params[:notes] = options[:description] unless options[:description].blank?
326
325
  params[:invoice] = options[:order_id].to_s.gsub(/[^-\/\w.,']/, '') unless options[:order_id].blank?
327
326
  end
328
-
327
+
329
328
  def commit(action, parameters)
330
329
  url = test? ? self.test_url : self.live_url
331
330
 
332
331
  response = parse( ssl_post(url, post_data(action, parameters)) )
333
-
334
- Response.new(successful?(response), message_from(response), response,
335
- :test => test?,
332
+
333
+ Response.new(successful?(response), message_from(response), response,
334
+ :test => test?,
336
335
  :authorization => response[:transaction_id] || parameters[:transaction_id]
337
336
  )
338
337
  end
339
-
338
+
340
339
  def successful?(response)
341
340
  SUCCESS_CODES.include?(response[:response_code]) || response[:query_status] == true
342
341
  end
343
-
342
+
344
343
  def message_from(response)
345
344
  if successful?(response)
346
345
  SUCCESS_MESSAGE
@@ -348,7 +347,7 @@ module ActiveMerchant #:nodoc:
348
347
  DECLINE_CODES[response[:response_code]] || FAILURE_MESSAGE
349
348
  end
350
349
  end
351
-
350
+
352
351
  def post_data(action, params)
353
352
  if test?
354
353
  # test requests must use global test account
@@ -360,18 +359,18 @@ module ActiveMerchant #:nodoc:
360
359
  end
361
360
  params[:version] = API_VERSION
362
361
  params[:transaction_type] = action
363
-
362
+
364
363
  params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join("&")
365
364
  end
366
-
365
+
367
366
  def parse(body)
368
367
  # PayJunction uses the Field Separator ASCII character to separate key/val
369
368
  # pairs in the response. The <FS> character's octal value is 034.
370
369
  #
371
370
  # Sample response:
372
- #
373
- # transaction_id=44752<FS>response_code=M4<FS>response_message=Declined (INV TEST CARD).
374
-
371
+ #
372
+ # transaction_id=44752<FS>response_code=M4<FS>response_message=Declined (INV TEST CARD).
373
+
375
374
  pairs = body.chomp.split("\034")
376
375
  response = {}
377
376
  pairs.each do |pair|
@@ -380,7 +379,7 @@ module ActiveMerchant #:nodoc:
380
379
  end
381
380
  response
382
381
  end
383
-
382
+
384
383
  # Make a ruby type out of the response string
385
384
  def normalize(field)
386
385
  case field
@@ -389,9 +388,9 @@ module ActiveMerchant #:nodoc:
389
388
  when "" then nil
390
389
  when "null" then nil
391
390
  else field
392
- end
391
+ end
393
392
  end
394
-
393
+
395
394
  end
396
395
  end
397
396
  end
@@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class PaySecureGateway < Gateway
4
4
  self.live_url = self.test_url = 'https://clearance.commsecure.com.au/cgi-bin/PSDirect'
5
-
5
+
6
6
  self.money_format = :cents
7
7
 
8
8
  # Currently Authorization and Capture is not implemented because
@@ -10,13 +10,13 @@ module ActiveMerchant #:nodoc:
10
10
  TRANSACTIONS = {
11
11
  :purchase => 'PURCHASE',
12
12
  :authorization => 'AUTHORISE',
13
- :capture => 'ADVICE',
13
+ :capture => 'ADVICE',
14
14
  :credit => 'REFUND'
15
15
  }
16
-
16
+
17
17
  SUCCESS = 'Accepted'
18
18
  SUCCESS_MESSAGE = 'The transaction was approved'
19
-
19
+
20
20
  self.supported_countries = ['AU']
21
21
  self.homepage_url = 'http://www.commsecure.com.au/paysecure.shtml'
22
22
  self.display_name = 'PaySecure'
@@ -24,21 +24,20 @@ module ActiveMerchant #:nodoc:
24
24
 
25
25
  def initialize(options = {})
26
26
  requires!(options, :login, :password)
27
- @options = options
28
27
  super
29
- end
28
+ end
30
29
 
31
30
  def purchase(money, credit_card, options = {})
32
31
  requires!(options, :order_id)
33
-
32
+
34
33
  post = {}
35
34
  add_amount(post, money)
36
35
  add_invoice(post, options)
37
- add_credit_card(post, credit_card)
38
-
36
+ add_credit_card(post, credit_card)
37
+
39
38
  commit(:purchase, money, post)
40
- end
41
-
39
+ end
40
+
42
41
  private
43
42
  # Used for capturing, which is currently not supported.
44
43
  def add_reference(post, identification)
@@ -46,72 +45,72 @@ module ActiveMerchant #:nodoc:
46
45
  post[:authnum] = auth
47
46
  post[:transid] = trans_id
48
47
  end
49
-
48
+
50
49
  def add_amount(post, money)
51
50
  post[:amount] = amount(money)
52
51
  end
53
-
52
+
54
53
  def add_invoice(post, options)
55
54
  post[:merchant_transid] = options[:order_id].to_s.slice(0,21)
56
55
  post[:memnum] = options[:invoice]
57
56
  post[:custnum] = options[:customer]
58
57
  post[:clientdata] = options[:description]
59
58
  end
60
-
61
- def add_credit_card(post, credit_card)
59
+
60
+ def add_credit_card(post, credit_card)
62
61
  post[:cardnum] = credit_card.number
63
62
  post[:cardname] = credit_card.name
64
63
  post[:expiry] = expdate(credit_card)
65
64
  post[:cvv2] = credit_card.verification_value
66
65
  end
67
-
66
+
68
67
  def expdate(credit_card)
69
68
  year = sprintf("%.4i", credit_card.year)
70
69
  month = sprintf("%.2i", credit_card.month)
71
70
 
72
71
  "#{month}#{year[-2..-1]}"
73
72
  end
74
-
73
+
75
74
  def commit(action, money, parameters)
76
75
  response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
77
-
78
- Response.new(successful?(response), message_from(response), response,
79
- :test => test_response?(response),
76
+
77
+ Response.new(successful?(response), message_from(response), response,
78
+ :test => test_response?(response),
80
79
  :authorization => authorization_from(response)
81
80
  )
82
-
81
+
83
82
  end
84
-
83
+
85
84
  def successful?(response)
86
85
  response[:status] == SUCCESS
87
86
  end
88
-
87
+
89
88
  def authorization_from(response)
90
89
  [ response[:authnum], response[:transid] ].compact.join(";")
91
90
  end
92
-
91
+
93
92
  def test_response?(response)
94
93
  !!(response[:transid] =~ /SimProxy/)
95
94
  end
96
-
95
+
97
96
  def message_from(response)
98
97
  successful?(response) ? SUCCESS_MESSAGE : response[:errorstring]
99
98
  end
100
-
99
+
101
100
  def parse(body)
102
101
  response = {}
103
- body.to_s.each_line do |l|
102
+ body.to_s.each_line do |l|
104
103
  key, value = l.split(":", 2)
105
104
  response[key.to_s.downcase.to_sym] = value.strip
106
105
  end
107
106
  response
108
- end
109
-
107
+ end
108
+
110
109
  def post_data(action, parameters = {})
111
110
  parameters[:request_type] = TRANSACTIONS[action]
112
111
  parameters[:merchant_id] = @options[:login]
113
112
  parameters[:password] = @options[:password]
114
-
113
+
115
114
  parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&")
116
115
  end
117
116
  end