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
@@ -57,18 +57,20 @@ module ActiveMerchant #:nodoc:
57
57
 
58
58
  def initialize(options = {})
59
59
  requires!(options, :merchant_id, :public_key, :private_key)
60
- @options = options
61
60
  @merchant_account_id = options[:merchant_account_id]
61
+
62
+ super
63
+
62
64
  Braintree::Configuration.merchant_id = options[:merchant_id]
63
65
  Braintree::Configuration.public_key = options[:public_key]
64
66
  Braintree::Configuration.private_key = options[:private_key]
65
67
  Braintree::Configuration.environment = (options[:environment] || (test? ? :sandbox : :production)).to_sym
66
68
  Braintree::Configuration.custom_user_agent = "ActiveMerchant #{ActiveMerchant::VERSION}"
69
+
67
70
  if wiredump_device
68
71
  Braintree::Configuration.logger = wiredump_device
69
72
  Braintree::Configuration.logger.level = Logger::DEBUG
70
73
  end
71
- super
72
74
  end
73
75
 
74
76
  def authorize(money, credit_card_or_vault_id, options = {})
@@ -93,7 +95,7 @@ module ActiveMerchant #:nodoc:
93
95
  def refund(*args)
94
96
  # legacy signature: #refund(transaction_id, options = {})
95
97
  # new signature: #refund(money, transaction_id, options = {})
96
- money, transaction_id, options = extract_refund_args(args)
98
+ money, transaction_id, _ = extract_refund_args(args)
97
99
  money = amount(money).to_s if money
98
100
 
99
101
  commit do
@@ -140,7 +142,7 @@ module ActiveMerchant #:nodoc:
140
142
 
141
143
  def update(vault_id, creditcard, options = {})
142
144
  braintree_credit_card = nil
143
- customer_update_result = commit do
145
+ commit do
144
146
  braintree_credit_card = Braintree::Customer.find(vault_id).credit_cards.detect { |cc| cc.default? }
145
147
  return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
146
148
 
@@ -362,9 +364,15 @@ module ActiveMerchant #:nodoc:
362
364
  :submit_for_settlement => options[:submit_for_settlement]
363
365
  }
364
366
  }
367
+
365
368
  if merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
366
369
  parameters[:merchant_account_id] = merchant_account_id
367
370
  end
371
+
372
+ if options[:recurring]
373
+ parameters[:recurring] = true
374
+ end
375
+
368
376
  if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
369
377
  parameters[:customer_id] = credit_card_or_vault_id
370
378
  else
@@ -2,24 +2,24 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  #
4
4
  # CardStream supports the following credit cards, which are auto-detected by
5
- # the gateway based on the card number used:
6
- # * AM American Express
7
- # * Diners Club
8
- # * Electron
9
- # * JCB
10
- # * UK Maestro
11
- # * Maestro International
12
- # * Mastercard
13
- # * Solo
14
- # * Style
15
- # * Switch
16
- # * Visa Credit
17
- # * Visa Debit
18
- # * Visa Purchasing
5
+ # the gateway based on the card number used:
6
+ # * AM American Express
7
+ # * Diners Club
8
+ # * Electron
9
+ # * JCB
10
+ # * UK Maestro
11
+ # * Maestro International
12
+ # * Mastercard
13
+ # * Solo
14
+ # * Style
15
+ # * Switch
16
+ # * Visa Credit
17
+ # * Visa Debit
18
+ # * Visa Purchasing
19
19
  #
20
20
  class CardStreamGateway < Gateway
21
21
  self.live_url = self.test_url = 'https://gateway.cardstream.com/process.ashx'
22
-
22
+
23
23
  self.money_format = :cents
24
24
  self.default_currency = 'GBP'
25
25
  self.supported_countries = ['GB']
@@ -29,7 +29,7 @@ module ActiveMerchant #:nodoc:
29
29
 
30
30
  APPROVED = '00'
31
31
 
32
- CURRENCY_CODES = {
32
+ CURRENCY_CODES = {
33
33
  "AUD"=> '036',
34
34
  "CAD"=> '124',
35
35
  "CZK"=> '203',
@@ -45,24 +45,24 @@ module ActiveMerchant #:nodoc:
45
45
  "USD"=> '840',
46
46
  "EUR"=> '978'
47
47
  }
48
-
48
+
49
49
  TRANSACTIONS = {
50
50
  :purchase => 'ESALE_KEYED',
51
51
  :refund => 'EREFUND_KEYED',
52
52
  :authorization => 'ESALE_KEYED'
53
53
  }
54
-
54
+
55
55
  CVV_CODE = {
56
- '0' => 'U',
56
+ '0' => 'U',
57
57
  '1' => 'P',
58
58
  '2' => 'M',
59
59
  '4' => 'N'
60
60
  }
61
-
62
- # 0 - No additional information available.
63
- # 1 - Postcode not checked.
64
- # 2 - Postcode matched.
65
- # 4 - Postcode not matched.
61
+
62
+ # 0 - No additional information available.
63
+ # 1 - Postcode not checked.
64
+ # 2 - Postcode matched.
65
+ # 4 - Postcode not matched.
66
66
  # 8 - Postcode partially matched.
67
67
  AVS_POSTAL_MATCH = {
68
68
  "0" => nil,
@@ -71,11 +71,11 @@ module ActiveMerchant #:nodoc:
71
71
  "4" => "N",
72
72
  "8" => "N"
73
73
  }
74
-
75
- # 0 - No additional information available.
76
- # 1 - Address numeric not checked.
77
- # 2 - Address numeric matched.
78
- # 4 - Address numeric not matched.
74
+
75
+ # 0 - No additional information available.
76
+ # 1 - Address numeric not checked.
77
+ # 2 - Address numeric matched.
78
+ # 4 - Address numeric not matched.
79
79
  # 8 - Address numeric partially matched.
80
80
  AVS_STREET_MATCH = {
81
81
  "0" => nil,
@@ -84,18 +84,17 @@ module ActiveMerchant #:nodoc:
84
84
  "4" => "N",
85
85
  "8" => "N"
86
86
  }
87
-
87
+
88
88
  def initialize(options = {})
89
89
  requires!(options, :login, :password)
90
- @options = options
91
90
  super
92
91
  end
93
92
 
94
93
  def purchase(money, credit_card, options = {})
95
94
  requires!(options, :order_id)
96
-
95
+
97
96
  post = {}
98
-
97
+
99
98
  add_amount(post, money, options)
100
99
  add_invoice(post, money, credit_card, options)
101
100
  add_credit_card(post, credit_card)
@@ -104,9 +103,9 @@ module ActiveMerchant #:nodoc:
104
103
 
105
104
  commit(:purchase, post)
106
105
  end
107
-
106
+
108
107
  private
109
-
108
+
110
109
  def add_amount(post, money, options)
111
110
  add_pair(post, :Amount, amount(money), :required => true)
112
111
  add_pair(post, :CurrencyCode, currency_code(options[:currency] || currency(money)), :required => true)
@@ -119,7 +118,7 @@ module ActiveMerchant #:nodoc:
119
118
 
120
119
  def add_address(post, options)
121
120
  address = options[:billing_address] || options[:address]
122
-
121
+
123
122
  return if address.nil?
124
123
 
125
124
  add_pair(post, :BillingStreet, address[:address1])
@@ -132,10 +131,10 @@ module ActiveMerchant #:nodoc:
132
131
  def add_invoice(post, money, credit_card, options)
133
132
  add_pair(post, :TransactionUnique, options[:order_id], :required => true)
134
133
  add_pair(post, :OrderDesc, options[:description] || options[:order_id], :required => true)
135
-
134
+
136
135
  if [ 'american_express', 'diners_club' ].include?(card_brand(credit_card).to_s)
137
- add_pair(post, :AEIT1Quantity, 1)
138
- add_pair(post, :AEIT1Description, (options[:description] || options[:order_id]).slice(0, 15))
136
+ add_pair(post, :AEIT1Quantity, 1)
137
+ add_pair(post, :AEIT1Description, (options[:description] || options[:order_id]).slice(0, 15))
139
138
  add_pair(post, :AEIT1GrossValue, amount(money))
140
139
  end
141
140
  end
@@ -143,20 +142,20 @@ module ActiveMerchant #:nodoc:
143
142
  def add_credit_card(post, credit_card)
144
143
  add_pair(post, :CardName, credit_card.name, :required => true)
145
144
  add_pair(post, :CardNumber, credit_card.number, :required => true)
146
-
145
+
147
146
  add_pair(post, :ExpiryDateMM, format(credit_card.month, :two_digits), :required => true)
148
147
  add_pair(post, :ExpiryDateYY, format(credit_card.year, :two_digits), :required => true)
149
-
148
+
150
149
  if requires_start_date_or_issue_number?(credit_card)
151
150
  add_pair(post, :StartDateMM, format(credit_card.start_month, :two_digits))
152
151
  add_pair(post, :StartDateYY, format(credit_card.start_year, :two_digits))
153
-
152
+
154
153
  add_pair(post, :IssueNumber, credit_card.issue_number)
155
154
  end
156
-
155
+
157
156
  add_pair(post, :CV2, credit_card.verification_value)
158
157
  end
159
-
158
+
160
159
  def commit(action, parameters)
161
160
  response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
162
161
 
@@ -188,19 +187,19 @@ module ActiveMerchant #:nodoc:
188
187
  :ReturnAVSCV2Message => "YES",
189
188
  :CountryCode => '826' # 826 for UK based merchant
190
189
  )
191
-
190
+
192
191
  add_pair(parameters, :Dispatch, action == :authorization ? "LATER" : "NOW")
193
-
192
+
194
193
  parameters.collect { |key, value| "VP#{key}=#{CGI.escape(value.to_s)}" }.join("&")
195
194
  end
196
-
197
- # VPCrossReference
198
- # The value in VPCrossReference on a success transaction will contain
199
- # a unique reference that you may use to run future transactions.
200
- # Please note that cross reference transactions must come a static IP
201
- # addressed that has been pre-registered with Cardstream. To
202
- # register an IP address please send it to support@cardstream.com
203
- # with your Cardstream issued merchant ID and it will be added to
195
+
196
+ # VPCrossReference
197
+ # The value in VPCrossReference on a success transaction will contain
198
+ # a unique reference that you may use to run future transactions.
199
+ # Please note that cross reference transactions must come a static IP
200
+ # addressed that has been pre-registered with Cardstream. To
201
+ # register an IP address please send it to support@cardstream.com
202
+ # with your Cardstream issued merchant ID and it will be added to
204
203
  # your account.
205
204
  def parse(body)
206
205
  result = {}
@@ -209,14 +208,10 @@ module ActiveMerchant #:nodoc:
209
208
  a = pair.split("=")
210
209
  result[a[0].gsub(/^VP/,'').underscore.to_sym] = a[1]
211
210
  end
212
-
211
+
213
212
  result
214
213
  end
215
214
 
216
- def test?
217
- @options[:test] || Base.gateway_mode == :test
218
- end
219
-
220
215
  def currency_code(currency)
221
216
  CURRENCY_CODES[currency]
222
217
  end
@@ -26,7 +26,6 @@ module ActiveMerchant #:nodoc:
26
26
  # Otherwise, perform transactions against the production server.
27
27
  def initialize(options = {})
28
28
  requires!(options, :login, :password)
29
- @options = options
30
29
  super
31
30
  end
32
31
 
@@ -107,15 +107,9 @@ module ActiveMerchant #:nodoc:
107
107
  # if CVV would have failed
108
108
  def initialize(options = {})
109
109
  requires!(options, :login, :password)
110
- @options = options
111
110
  super
112
111
  end
113
112
 
114
- # Should run against the test servers or not?
115
- def test?
116
- @options[:test] || Base.gateway_mode == :test
117
- end
118
-
119
113
  # Request an authorization for an amount from CyberSource
120
114
  #
121
115
  # You must supply an :order_id in the options hash
@@ -148,12 +142,13 @@ module ActiveMerchant #:nodoc:
148
142
  end
149
143
 
150
144
  def refund(money, identification, options = {})
151
- commit(build_credit_request(money, identification, options), options)
145
+ commit(build_refund_request(money, identification, options), options)
152
146
  end
153
147
 
154
- def credit(money, identification, options = {})
155
- deprecated CREDIT_DEPRECATION_MESSAGE
156
- refund(money, identification, options)
148
+ # Adds credit to a subscription (stand alone credit).
149
+ def credit(money, reference, options = {})
150
+ requires!(options, :order_id)
151
+ commit(build_credit_request(money, reference, options), options)
157
152
  end
158
153
 
159
154
  # Stores a customer subscription/profile with type "on-demand".
@@ -281,7 +276,7 @@ module ActiveMerchant #:nodoc:
281
276
  xml.target!
282
277
  end
283
278
 
284
- def build_credit_request(money, identification, options)
279
+ def build_refund_request(money, identification, options)
285
280
  order_id, request_id, request_token = identification.split(";")
286
281
  options[:order_id] = order_id
287
282
 
@@ -292,6 +287,16 @@ module ActiveMerchant #:nodoc:
292
287
  xml.target!
293
288
  end
294
289
 
290
+ def build_credit_request(money, reference, options)
291
+ xml = Builder::XmlMarkup.new :indent => 2
292
+
293
+ add_purchase_data(xml, money, true, options)
294
+ add_subscription(xml, options, reference)
295
+ add_credit_service(xml)
296
+
297
+ xml.target!
298
+ end
299
+
295
300
  def build_create_subscription_request(creditcard, options)
296
301
  options[:subscription] = (options[:subscription] || {}).merge(:frequency => "on-demand", :amount => 0, :automatic_renew => false)
297
302
 
@@ -435,10 +440,10 @@ module ActiveMerchant #:nodoc:
435
440
  end
436
441
  end
437
442
 
438
- def add_credit_service(xml, request_id, request_token)
443
+ def add_credit_service(xml, request_id = nil, request_token = nil)
439
444
  xml.tag! 'ccCreditService', {'run' => 'true'} do
440
- xml.tag! 'captureRequestID', request_id
441
- xml.tag! 'captureRequestToken', request_token
445
+ xml.tag! 'captureRequestID', request_id if request_id
446
+ xml.tag! 'captureRequestToken', request_token if request_token
442
447
  end
443
448
  end
444
449
 
@@ -8,9 +8,9 @@ module ActiveMerchant
8
8
  # usable:
9
9
  # American Express, ATM, Carte Blanche, Diners Club, Discover,
10
10
  # EnRoute, GE Capital, JCB, Laser, Maestro, Mastercard, Solo,
11
- # Switch, Visa, Visa Delta, VISA Electron, Visa Purchasing
11
+ # Switch, Visa, Visa Delta, VISA Electron, Visa Purchasing
12
12
  #
13
- # Note continuous authority is only supported for :visa, :master and :american_express card types
13
+ # Note continuous authority is only supported for :visa, :master and :american_express card types
14
14
  self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ]
15
15
 
16
16
  self.homepage_url = 'http://www.datacash.com/'
@@ -37,24 +37,23 @@ module ActiveMerchant
37
37
  DATACASH_SUCCESS = '1'
38
38
 
39
39
  # Creates a new DataCashGateway
40
- #
40
+ #
41
41
  # The gateway requires that a valid login and password be passed
42
42
  # in the +options+ hash.
43
- #
43
+ #
44
44
  # ==== Options
45
45
  #
46
46
  # * <tt>:login</tt> -- The Datacash account login.
47
47
  # * <tt>:password</tt> -- The Datacash account password.
48
48
  # * <tt>:test => +true+ or +false+</tt> -- Use the test or live Datacash url.
49
- #
49
+ #
50
50
  def initialize(options = {})
51
51
  requires!(options, :login, :password)
52
- @options = options
53
52
  super
54
53
  end
55
54
 
56
55
  # Perform a purchase, which is essentially an authorization and capture in a single operation.
57
- #
56
+ #
58
57
  # ==== Parameters
59
58
  # * <tt>money</tt> The amount to be authorized as an Integer value in cents.
60
59
  # * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
@@ -62,8 +61,8 @@ module ActiveMerchant
62
61
  # * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
63
62
  # * <tt>:set_up_continuous_authority</tt>
64
63
  # Set to true to set up a recurring historic transaction account be set up.
65
- # Only supported for :visa, :master and :american_express card types
66
- # See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
64
+ # Only supported for :visa, :master and :american_express card types
65
+ # See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
67
66
  # * <tt>:address</tt>:: billing address for card
68
67
  #
69
68
  # The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
@@ -79,7 +78,7 @@ module ActiveMerchant
79
78
  commit(request)
80
79
  end
81
80
 
82
- # Performs an authorization, which reserves the funds on the customer's credit card, but does not
81
+ # Performs an authorization, which reserves the funds on the customer's credit card, but does not
83
82
  # charge the card.
84
83
  #
85
84
  # ==== Parameters
@@ -90,8 +89,8 @@ module ActiveMerchant
90
89
  # * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
91
90
  # * <tt>:set_up_continuous_authority</tt>::
92
91
  # Set to true to set up a recurring historic transaction account be set up.
93
- # Only supported for :visa, :master and :american_express card types
94
- # See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
92
+ # Only supported for :visa, :master and :american_express card types
93
+ # See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
95
94
  # * <tt>:address</tt>:: billing address for card
96
95
  #
97
96
  # The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
@@ -108,20 +107,20 @@ module ActiveMerchant
108
107
  end
109
108
 
110
109
  # Captures the funds from an authorized transaction.
111
- #
110
+ #
112
111
  # ==== Parameters
113
112
  #
114
113
  # * <tt>money</tt> -- The amount to be captured as anInteger value in cents.
115
- # * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
114
+ # * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
116
115
  def capture(money, authorization, options = {})
117
116
  commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
118
- end
117
+ end
119
118
 
120
119
  # Void a previous transaction
121
- #
120
+ #
122
121
  # ==== Parameters
123
122
  #
124
- # * <tt>authorization</tt> - The authorization returned from the previous authorize request.
123
+ # * <tt>authorization</tt> - The authorization returned from the previous authorize request.
125
124
  def void(authorization, options = {})
126
125
  request = build_void_or_capture_request(CANCEL_TYPE, nil, authorization, options)
127
126
 
@@ -129,7 +128,7 @@ module ActiveMerchant
129
128
  end
130
129
 
131
130
  # Refund to a card
132
- #
131
+ #
133
132
  # ==== Parameters
134
133
  #
135
134
  # * <tt>money</tt> The amount to be refunded as an Integer value in cents. Set to nil for a full refund on existing transaction.
@@ -151,14 +150,9 @@ module ActiveMerchant
151
150
  commit(build_transaction_refund_request(money, reference))
152
151
  end
153
152
 
154
- # Is the gateway running in test mode?
155
- def test?
156
- @options[:test] || super
157
- end
158
-
159
- private
153
+ private
160
154
  # Create the xml document for a 'cancel' or 'fulfill' transaction.
161
- #
155
+ #
162
156
  # Final XML should look like:
163
157
  # <Request>
164
158
  # <Authentication>
@@ -176,14 +170,14 @@ module ActiveMerchant
176
170
  # </HistoricTxn>
177
171
  # </Transaction>
178
172
  # </Request>
179
- #
173
+ #
180
174
  # Parameters:
181
175
  # * <tt>type</tt> must be FULFILL_TYPE or CANCEL_TYPE
182
176
  # * <tt>money</tt> - optional - Integer value in cents
183
177
  # * <tt>authorization</tt> - the Datacash authorization from a previous succesful authorize transaction
184
178
  # * <tt>options</tt>
185
179
  # * <tt>order_id</tt> - A unique reference for the transaction
186
- #
180
+ #
187
181
  # Returns:
188
182
  # -Builder xml document
189
183
  #
@@ -194,14 +188,14 @@ module ActiveMerchant
194
188
  xml.instruct!
195
189
  xml.tag! :Request do
196
190
  add_authentication(xml)
197
-
191
+
198
192
  xml.tag! :Transaction do
199
193
  xml.tag! :HistoricTxn do
200
194
  xml.tag! :reference, reference
201
195
  xml.tag! :authcode, auth_code
202
196
  xml.tag! :method, type
203
197
  end
204
-
198
+
205
199
  if money
206
200
  xml.tag! :TxnDetails do
207
201
  xml.tag! :merchantreference, format_reference_number(options[:order_id])
@@ -214,9 +208,9 @@ module ActiveMerchant
214
208
  end
215
209
 
216
210
  # Create the xml document for an 'auth' or 'pre' transaction with a credit card
217
- #
211
+ #
218
212
  # Final XML should look like:
219
- #
213
+ #
220
214
  # <Request>
221
215
  # <Authentication>
222
216
  # <client>99000000</client>
@@ -261,7 +255,7 @@ module ActiveMerchant
261
255
  # </CardTxn>
262
256
  # </Transaction>
263
257
  # </Request>
264
- #
258
+ #
265
259
  # Parameters:
266
260
  # -type must be 'auth' or 'pre'
267
261
  # -money - A money object with the price and currency
@@ -270,7 +264,7 @@ module ActiveMerchant
270
264
  # :order_id is the merchant reference number
271
265
  # :billing_address is the billing address for the cc
272
266
  # :address is the delivery address
273
- #
267
+ #
274
268
  # Returns:
275
269
  # -xml: Builder document containing the markup
276
270
  #
@@ -279,7 +273,7 @@ module ActiveMerchant
279
273
  xml.instruct!
280
274
  xml.tag! :Request do
281
275
  add_authentication(xml)
282
-
276
+
283
277
  xml.tag! :Transaction do
284
278
  if options[:set_up_continuous_authority]
285
279
  xml.tag! :ContAuthTxn, :type => 'setup'
@@ -299,35 +293,35 @@ module ActiveMerchant
299
293
 
300
294
  # Create the xml document for an 'auth' or 'pre' transaction with
301
295
  # continuous authorization
302
- #
296
+ #
303
297
  # Final XML should look like:
304
- #
305
- # <Request>
306
- # <Transaction>
307
- # <ContAuthTxn type="historic" />
308
- # <TxnDetails>
309
- # <merchantreference>3851231</merchantreference>
310
- # <capturemethod>cont_auth</capturemethod>
311
- # <amount currency="GBP">18.50</amount>
312
- # </TxnDetails>
313
- # <HistoricTxn>
314
- # <reference>4500200040925092</reference>
315
- # <method>auth</method>
316
- # </HistoricTxn>
317
- # </Transaction>
318
- # <Authentication>
319
- # <client>99000001</client>
320
- # <password>mypasswd</password>
321
- # </Authentication>
298
+ #
299
+ # <Request>
300
+ # <Transaction>
301
+ # <ContAuthTxn type="historic" />
302
+ # <TxnDetails>
303
+ # <merchantreference>3851231</merchantreference>
304
+ # <capturemethod>cont_auth</capturemethod>
305
+ # <amount currency="GBP">18.50</amount>
306
+ # </TxnDetails>
307
+ # <HistoricTxn>
308
+ # <reference>4500200040925092</reference>
309
+ # <method>auth</method>
310
+ # </HistoricTxn>
311
+ # </Transaction>
312
+ # <Authentication>
313
+ # <client>99000001</client>
314
+ # <password>mypasswd</password>
315
+ # </Authentication>
322
316
  # </Request>
323
- #
317
+ #
324
318
  # Parameters:
325
319
  # -type must be 'auth' or 'pre'
326
320
  # -money - A money object with the price and currency
327
321
  # -authorization - The authorization containing a continuous authority reference previously set up on a credit card
328
322
  # -options:
329
323
  # :order_id is the merchant reference number
330
- #
324
+ #
331
325
  # Returns:
332
326
  # -xml: Builder document containing the markup
333
327
  #
@@ -356,25 +350,25 @@ module ActiveMerchant
356
350
  end
357
351
 
358
352
  # Create the xml document for a full or partial refund transaction with
359
- #
353
+ #
360
354
  # Final XML should look like:
361
355
  #
362
- # <Request>
363
- # <Authentication>
364
- # <client>99000001</client>
365
- # <password>*******</password>
366
- # </Authentication>
367
- # <Transaction>
368
- # <HistoricTxn>
369
- # <method>txn_refund</method>
370
- # <reference>12345678</reference>
371
- # </HistoricTxn>
372
- # <TxnDetails>
373
- # <amount>10.00</amount>
374
- # </TxnDetails>
356
+ # <Request>
357
+ # <Authentication>
358
+ # <client>99000001</client>
359
+ # <password>*******</password>
360
+ # </Authentication>
361
+ # <Transaction>
362
+ # <HistoricTxn>
363
+ # <method>txn_refund</method>
364
+ # <reference>12345678</reference>
365
+ # </HistoricTxn>
366
+ # <TxnDetails>
367
+ # <amount>10.00</amount>
368
+ # </TxnDetails>
375
369
  # </Transaction>
376
- # </Request>
377
- #
370
+ # </Request>
371
+ #
378
372
  def build_transaction_refund_request(money, reference)
379
373
  xml = Builder::XmlMarkup.new :indent => 2
380
374
  xml.instruct!
@@ -396,27 +390,27 @@ module ActiveMerchant
396
390
  end
397
391
 
398
392
  # Create the xml document for a full or partial refund with
399
- #
393
+ #
400
394
  # Final XML should look like:
401
395
  #
402
- # <Request>
403
- # <Authentication>
404
- # <client>99000001</client>
405
- # <password>*****</password>
406
- # </Authentication>
407
- # <Transaction>
408
- # <CardTxn>
409
- # <Card>
410
- # <pan>633300*********1</pan>
411
- # <expirydate>04/06</expirydate>
412
- # <startdate>01/04</startdate>
413
- # </Card>
414
- # <method>refund</method>
415
- # </CardTxn>
416
- # <TxnDetails>
417
- # <merchantreference>1000001</merchantreference>
418
- # <amount currency="GBP">95.99</amount>
419
- # </TxnDetails>
396
+ # <Request>
397
+ # <Authentication>
398
+ # <client>99000001</client>
399
+ # <password>*****</password>
400
+ # </Authentication>
401
+ # <Transaction>
402
+ # <CardTxn>
403
+ # <Card>
404
+ # <pan>633300*********1</pan>
405
+ # <expirydate>04/06</expirydate>
406
+ # <startdate>01/04</startdate>
407
+ # </Card>
408
+ # <method>refund</method>
409
+ # </CardTxn>
410
+ # <TxnDetails>
411
+ # <merchantreference>1000001</merchantreference>
412
+ # <amount currency="GBP">95.99</amount>
413
+ # </TxnDetails>
420
414
  # </Transaction>
421
415
  # </Request>
422
416
  def build_refund_request(money, credit_card, options)
@@ -440,13 +434,13 @@ module ActiveMerchant
440
434
 
441
435
 
442
436
  # Adds the authentication element to the passed builder xml doc
443
- #
437
+ #
444
438
  # Parameters:
445
439
  # -xml: Builder document that is being built up
446
- #
440
+ #
447
441
  # Returns:
448
442
  # -none: The results is stored in the passed xml document
449
- #
443
+ #
450
444
  def add_authentication(xml)
451
445
  xml.tag! :Authentication do
452
446
  xml.tag! :client, @options[:login]
@@ -455,17 +449,17 @@ module ActiveMerchant
455
449
  end
456
450
 
457
451
  # Add credit_card detals to the passed XML Builder doc
458
- #
452
+ #
459
453
  # Parameters:
460
454
  # -xml: Builder document that is being built up
461
455
  # -credit_card: ActiveMerchant::Billing::CreditCard object
462
456
  # -billing_address: Hash containing all of the billing address details
463
- #
457
+ #
464
458
  # Returns:
465
459
  # -none: The results is stored in the passed xml document
466
- #
460
+ #
467
461
  def add_credit_card(xml, credit_card, address)
468
-
462
+
469
463
  xml.tag! :Card do
470
464
 
471
465
  # DataCash calls the CC number 'pan'
@@ -474,7 +468,7 @@ module ActiveMerchant
474
468
 
475
469
  # optional values - for Solo etc
476
470
  if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
477
-
471
+
478
472
  xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?
479
473
 
480
474
  if !credit_card.start_month.blank? && !credit_card.start_year.blank?
@@ -492,14 +486,14 @@ module ActiveMerchant
492
486
  xml.tag! :postcode, address[:zip] unless address[:zip].blank?
493
487
  end
494
488
 
495
- # The ExtendedPolicy defines what to do when the passed data
489
+ # The ExtendedPolicy defines what to do when the passed data
496
490
  # matches, or not...
497
- #
491
+ #
498
492
  # All of the following elements MUST be present for the
499
493
  # xml to be valid (or can drop the ExtendedPolicy and use
500
494
  # a predefined one
501
495
  xml.tag! :ExtendedPolicy do
502
- xml.tag! :cv2_policy,
496
+ xml.tag! :cv2_policy,
503
497
  :notprovided => POLICY_REJECT,
504
498
  :notchecked => POLICY_REJECT,
505
499
  :matched => POLICY_ACCEPT,
@@ -511,7 +505,7 @@ module ActiveMerchant
511
505
  :matched => POLICY_ACCEPT,
512
506
  :notmatched => POLICY_REJECT,
513
507
  :partialmatch => POLICY_ACCEPT
514
- xml.tag! :address_policy,
508
+ xml.tag! :address_policy,
515
509
  :notprovided => POLICY_ACCEPT,
516
510
  :notchecked => POLICY_ACCEPT,
517
511
  :matched => POLICY_ACCEPT,
@@ -523,15 +517,15 @@ module ActiveMerchant
523
517
  end
524
518
 
525
519
  # Send the passed data to DataCash for processing
526
- #
520
+ #
527
521
  # Parameters:
528
522
  # -request: The XML data that is to be sent to Datacash
529
- #
523
+ #
530
524
  # Returns:
531
525
  # - ActiveMerchant::Billing::Response object
532
- #
526
+ #
533
527
  def commit(request)
534
- response = parse(ssl_post(test? ? self.test_url : self.live_url, request))
528
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, request))
535
529
 
536
530
  Response.new(response[:status] == DATACASH_SUCCESS, response[:reason], response,
537
531
  :test => test?,
@@ -540,11 +534,11 @@ module ActiveMerchant
540
534
  end
541
535
 
542
536
  # Returns a date string in the format Datacash expects
543
- #
537
+ #
544
538
  # Parameters:
545
539
  # -month: integer, the month
546
540
  # -year: integer, the year
547
- #
541
+ #
548
542
  # Returns:
549
543
  # -String: date in MM/YY format
550
544
  #
@@ -556,10 +550,10 @@ module ActiveMerchant
556
550
  #
557
551
  # Parameters:
558
552
  # -body: The XML returned from Datacash
559
- #
553
+ #
560
554
  # Returns:
561
555
  # -a hash with all of the values returned in the Datacash XML response
562
- #
556
+ #
563
557
  def parse(body)
564
558
 
565
559
  response = {}
@@ -571,14 +565,14 @@ module ActiveMerchant
571
565
  end
572
566
 
573
567
  response
574
- end
568
+ end
575
569
 
576
570
  # Parse an xml element
577
571
  #
578
572
  # Parameters:
579
573
  # -response: The hash that the values are being returned in
580
574
  # -node: The node that is currently being read
581
- #
575
+ #
582
576
  # Returns:
583
577
  # - none (results are stored in the passed hash)
584
578
  def parse_element(response, node)