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
@@ -60,7 +60,6 @@ module ActiveMerchant #:nodoc:
60
60
 
61
61
  def initialize(options = {})
62
62
  requires!(options, :login, :password)
63
- @options = options
64
63
  super
65
64
  end
66
65
 
@@ -109,10 +108,6 @@ module ActiveMerchant #:nodoc:
109
108
  commit('refund', money, post)
110
109
  end
111
110
 
112
- def test?
113
- @options[:test] || Base.gateway_mode == :test
114
- end
115
-
116
111
  private
117
112
 
118
113
  def add_invoice(post, options)
@@ -3,20 +3,20 @@ module ActiveMerchant #:nodoc:
3
3
  module PayflowCommonAPI
4
4
  def self.included(base)
5
5
  base.default_currency = 'USD'
6
-
6
+
7
7
  base.class_attribute :partner
8
-
8
+
9
9
  # Set the default partner to PayPal
10
10
  base.partner = 'PayPal'
11
-
11
+
12
12
  base.supported_countries = ['US', 'CA', 'SG', 'AU']
13
-
13
+
14
14
  base.class_attribute :timeout
15
15
  base.timeout = 60
16
16
 
17
17
  base.test_url = 'https://pilot-payflowpro.paypal.com'
18
18
  base.live_url = 'https://payflowpro.paypal.com'
19
-
19
+
20
20
  # Enable safe retry of failed connections
21
21
  # Payflow is safe to retry because retried transactions use the same
22
22
  # X-VPS-Request-ID header. If a transaction is detected as a duplicate
@@ -25,9 +25,9 @@ module ActiveMerchant #:nodoc:
25
25
  # hash.
26
26
  base.retry_safe = true
27
27
  end
28
-
28
+
29
29
  XMLNS = 'http://www.paypal.com/XMLPay'
30
-
30
+
31
31
  CARD_MAPPING = {
32
32
  :visa => 'Visa',
33
33
  :master => 'MasterCard',
@@ -38,45 +38,40 @@ module ActiveMerchant #:nodoc:
38
38
  :switch => 'Switch',
39
39
  :solo => 'Solo'
40
40
  }
41
-
42
- TRANSACTIONS = {
41
+
42
+ TRANSACTIONS = {
43
43
  :purchase => "Sale",
44
44
  :authorization => "Authorization",
45
45
  :capture => "Capture",
46
46
  :void => "Void",
47
- :credit => "Credit"
47
+ :credit => "Credit"
48
48
  }
49
-
49
+
50
50
  CVV_CODE = {
51
51
  'Match' => 'M',
52
52
  'No Match' => 'N',
53
- 'Service Not Available' => 'U',
53
+ 'Service Not Available' => 'U',
54
54
  'Service not Requested' => 'P'
55
55
  }
56
-
56
+
57
57
  def initialize(options = {})
58
58
  requires!(options, :login, :password)
59
-
60
- @options = options
61
- @options[:partner] = partner if @options[:partner].blank?
59
+
60
+ options[:partner] = partner if options[:partner].blank?
62
61
  super
63
- end
64
-
65
- def test?
66
- @options[:test] || super
67
62
  end
68
-
63
+
69
64
  def capture(money, authorization, options = {})
70
65
  request = build_reference_request(:capture, money, authorization, options)
71
66
  commit(request, options)
72
67
  end
73
-
68
+
74
69
  def void(authorization, options = {})
75
70
  request = build_reference_request(:void, nil, authorization, options)
76
71
  commit(request, options)
77
72
  end
78
-
79
- private
73
+
74
+ private
80
75
  def build_request(body, options = {})
81
76
  xml = Builder::XmlMarkup.new
82
77
  xml.instruct!
@@ -104,12 +99,12 @@ module ActiveMerchant #:nodoc:
104
99
  end
105
100
  xml.target!
106
101
  end
107
-
102
+
108
103
  def build_reference_request(action, money, authorization, options)
109
104
  xml = Builder::XmlMarkup.new
110
105
  xml.tag! TRANSACTIONS[action] do
111
106
  xml.tag! 'PNRef', authorization
112
-
107
+
113
108
  unless money.nil?
114
109
  xml.tag! 'Invoice' do
115
110
  xml.tag!('TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money))
@@ -119,11 +114,11 @@ module ActiveMerchant #:nodoc:
119
114
  end
120
115
  end
121
116
  end
122
-
117
+
123
118
  xml.target!
124
119
  end
125
120
 
126
- def add_address(xml, tag, address, options)
121
+ def add_address(xml, tag, address, options)
127
122
  return if address.nil?
128
123
  xml.tag! tag do
129
124
  xml.tag! 'Name', address[:name] unless address[:name].blank?
@@ -131,7 +126,7 @@ module ActiveMerchant #:nodoc:
131
126
  xml.tag! 'Phone', address[:phone] unless address[:phone].blank?
132
127
  xml.tag! 'CustCode', options[:customer] if !options[:customer].blank? && tag == 'BillTo'
133
128
  xml.tag! 'PONum', options[:po_number] if !options[:po_number].blank? && tag == 'BillTo'
134
-
129
+
135
130
  xml.tag! 'Address' do
136
131
  xml.tag! 'Street', address[:address1] unless address[:address1].blank?
137
132
  xml.tag! 'City', address[:city] unless address[:city].blank?
@@ -141,26 +136,26 @@ module ActiveMerchant #:nodoc:
141
136
  end
142
137
  end
143
138
  end
144
-
139
+
145
140
  def parse(data)
146
141
  response = {}
147
142
  xml = REXML::Document.new(data)
148
143
  root = REXML::XPath.first(xml, "//ResponseData")
149
-
144
+
150
145
  # REXML::XPath in Ruby 1.8.6 is now unable to match nodes based on their attributes
151
146
  tx_result = REXML::XPath.first(root, "//TransactionResult")
152
-
147
+
153
148
  if tx_result && tx_result.attributes['Duplicate'] == "true"
154
- response[:duplicate] = true
149
+ response[:duplicate] = true
155
150
  end
156
-
151
+
157
152
  root.elements.to_a.each do |node|
158
153
  parse_element(response, node)
159
154
  end
160
155
 
161
156
  response
162
157
  end
163
-
158
+
164
159
  def parse_element(response, node)
165
160
  node_name = node.name.underscore.to_sym
166
161
  case
@@ -182,7 +177,7 @@ module ActiveMerchant #:nodoc:
182
177
  response[node_name] = node.text
183
178
  end
184
179
  end
185
-
180
+
186
181
  def build_headers(content_length)
187
182
  {
188
183
  "Content-Type" => "text/xml",
@@ -193,11 +188,11 @@ module ActiveMerchant #:nodoc:
193
188
  "X-VPS-Request-ID" => Utils.generate_unique_id
194
189
  }
195
190
  end
196
-
191
+
197
192
  def commit(request_body, options = {})
198
193
  request = build_request(request_body, options)
199
194
  headers = build_headers(request.size)
200
-
195
+
201
196
  response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers))
202
197
 
203
198
  build_response(response[:result] == "0", response[:message], response,
@@ -2,29 +2,29 @@ require 'rexml/document'
2
2
 
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
-
6
- # In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
7
- # In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
5
+
6
+ # In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
7
+ # In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
8
8
  # The Maybank in Malaysia is supported and the Citibank for Singapore.
9
9
  class PaymentExpressGateway < Gateway
10
10
  self.default_currency = 'NZD'
11
- # PS supports all major credit cards; Visa, Mastercard, Amex, Diners, BankCard & JCB.
12
- # Various white label cards can be accepted as well; Farmers, AirNZCard and Elders etc.
11
+ # PS supports all major credit cards; Visa, Mastercard, Amex, Diners, BankCard & JCB.
12
+ # Various white label cards can be accepted as well; Farmers, AirNZCard and Elders etc.
13
13
  # Please note that not all acquirers and Eftpos networks can support some of these card types.
14
14
  # VISA, Mastercard, Diners Club and Farmers cards are supported
15
15
  #
16
16
  # However, regular accounts with DPS only support VISA and Mastercard
17
17
  self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb ]
18
-
18
+
19
19
  self.supported_countries = %w[ AU MY NZ SG ZA GB US ]
20
-
20
+
21
21
  self.homepage_url = 'http://www.paymentexpress.com/'
22
22
  self.display_name = 'PaymentExpress'
23
23
 
24
24
  self.live_url = self.test_url = 'https://sec.paymentexpress.com/pxpost.aspx'
25
-
25
+
26
26
  APPROVED = '1'
27
-
27
+
28
28
  TRANSACTIONS = {
29
29
  :purchase => 'Purchase',
30
30
  :credit => 'Refund',
@@ -32,7 +32,7 @@ module ActiveMerchant #:nodoc:
32
32
  :capture => 'Complete',
33
33
  :validate => 'Validate'
34
34
  }
35
-
35
+
36
36
  # We require the DPS gateway username and password when the object is created.
37
37
  #
38
38
  # The PaymentExpress gateway also supports a :use_custom_payment_token boolean option.
@@ -40,25 +40,22 @@ module ActiveMerchant #:nodoc:
40
40
  # then the token will be sent as the DPS specified "DpsBillingId". This is per the documentation at
41
41
  # http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling
42
42
  def initialize(options = {})
43
- # A DPS username and password must exist
44
43
  requires!(options, :login, :password)
45
- # Make the options an instance variable
46
- @options = options
47
44
  super
48
45
  end
49
-
46
+
50
47
  # Funds are transferred immediately.
51
48
  #
52
49
  # `payment_source` can be a usual ActiveMerchant credit_card object, or can also
53
- # be a string of the `DpsBillingId` or `BillingId` which can be gotten through the
50
+ # be a string of the `DpsBillingId` or `BillingId` which can be gotten through the
54
51
  # store method. If you are using a `BillingId` instead of `DpsBillingId` you must
55
52
  # also set the instance method `#use_billing_id_for_token` to true, see the `#store`
56
53
  # method for an example of how to do this.
57
54
  def purchase(money, payment_source, options = {})
58
55
  request = build_purchase_or_authorization_request(money, payment_source, options)
59
- commit(:purchase, request)
56
+ commit(:purchase, request)
60
57
  end
61
-
58
+
62
59
  # NOTE: Perhaps in options we allow a transaction note to be inserted
63
60
  # Verifies that funds are available for the requested card and amount and reserves the specified amount.
64
61
  # See: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
@@ -68,19 +65,19 @@ module ActiveMerchant #:nodoc:
68
65
  request = build_purchase_or_authorization_request(money, payment_source, options)
69
66
  commit(:authorization, request)
70
67
  end
71
-
68
+
72
69
  # Transfer pre-authorized funds immediately
73
70
  # See: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
74
71
  def capture(money, identification, options = {})
75
- request = build_capture_or_credit_request(money, identification, options)
72
+ request = build_capture_or_credit_request(money, identification, options)
76
73
  commit(:capture, request)
77
74
  end
78
-
75
+
79
76
  # Refund funds to the card holder
80
77
  def refund(money, identification, options = {})
81
78
  requires!(options, :description)
82
-
83
- request = build_capture_or_credit_request(money, identification, options)
79
+
80
+ request = build_capture_or_credit_request(money, identification, options)
84
81
  commit(:credit, request)
85
82
  end
86
83
 
@@ -88,9 +85,9 @@ module ActiveMerchant #:nodoc:
88
85
  deprecated CREDIT_DEPRECATION_MESSAGE
89
86
  refund(money, identification, options)
90
87
  end
91
-
88
+
92
89
  # Token Based Billing
93
- #
90
+ #
94
91
  # Instead of storing the credit card details locally, you can store them inside the
95
92
  # Payment Express system and instead bill future transactions against a token.
96
93
  #
@@ -102,7 +99,7 @@ module ActiveMerchant #:nodoc:
102
99
  # initialization of your gateway object.
103
100
  #
104
101
  # To specify and use your own token, you need to do two things.
105
- #
102
+ #
106
103
  # Firstly, pass in a `:billing_id` as an option in the hash of this store method. No
107
104
  # validation is done on this BillingId by PaymentExpress so you must ensure that it is unique.
108
105
  #
@@ -124,37 +121,37 @@ module ActiveMerchant #:nodoc:
124
121
  request = build_token_request(credit_card, options)
125
122
  commit(:validate, request)
126
123
  end
127
-
124
+
128
125
  private
129
126
 
130
127
  def use_custom_payment_token?
131
128
  @options[:use_custom_payment_token]
132
129
  end
133
-
130
+
134
131
  def build_purchase_or_authorization_request(money, payment_source, options)
135
- result = new_transaction
132
+ result = new_transaction
136
133
 
137
134
  if payment_source.is_a?(String)
138
135
  add_billing_token(result, payment_source)
139
136
  else
140
137
  add_credit_card(result, payment_source)
141
138
  end
142
-
139
+
143
140
  add_amount(result, money, options)
144
141
  add_invoice(result, options)
145
142
  add_address_verification_data(result, options)
146
143
  result
147
144
  end
148
-
145
+
149
146
  def build_capture_or_credit_request(money, identification, options)
150
147
  result = new_transaction
151
-
148
+
152
149
  add_amount(result, money, options)
153
150
  add_invoice(result, options)
154
151
  add_reference(result, identification)
155
152
  result
156
153
  end
157
-
154
+
158
155
  def build_token_request(credit_card, options)
159
156
  result = new_transaction
160
157
  add_credit_card(result, credit_card)
@@ -162,26 +159,26 @@ module ActiveMerchant #:nodoc:
162
159
  add_token_request(result, options)
163
160
  result
164
161
  end
165
-
162
+
166
163
  def add_credentials(xml)
167
164
  xml.add_element("PostUsername").text = @options[:login]
168
165
  xml.add_element("PostPassword").text = @options[:password]
169
166
  end
170
-
167
+
171
168
  def add_reference(xml, identification)
172
169
  xml.add_element("DpsTxnRef").text = identification
173
170
  end
174
-
171
+
175
172
  def add_credit_card(xml, credit_card)
176
173
  xml.add_element("CardHolderName").text = credit_card.name
177
174
  xml.add_element("CardNumber").text = credit_card.number
178
175
  xml.add_element("DateExpiry").text = format_date(credit_card.month, credit_card.year)
179
-
176
+
180
177
  if credit_card.verification_value?
181
178
  xml.add_element("Cvc2").text = credit_card.verification_value
182
179
  xml.add_element("Cvc2Presence").text = "1"
183
180
  end
184
-
181
+
185
182
  if requires_start_date_or_issue_number?(credit_card)
186
183
  xml.add_element("DateStart").text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank?
187
184
  xml.add_element("IssueNumber").text = credit_card.issue_number unless credit_card.issue_number.blank?
@@ -195,37 +192,37 @@ module ActiveMerchant #:nodoc:
195
192
  xml.add_element("DpsBillingId").text = token
196
193
  end
197
194
  end
198
-
195
+
199
196
  def add_token_request(xml, options)
200
197
  xml.add_element("BillingId").text = options[:billing_id] if options[:billing_id]
201
198
  xml.add_element("EnableAddBillCard").text = 1
202
199
  end
203
-
200
+
204
201
  def add_amount(xml, money, options)
205
202
  xml.add_element("Amount").text = amount(money)
206
203
  xml.add_element("InputCurrency").text = options[:currency] || currency(money)
207
204
  end
208
-
205
+
209
206
  def add_transaction_type(xml, action)
210
207
  xml.add_element("TxnType").text = TRANSACTIONS[action]
211
208
  end
212
-
209
+
213
210
  def add_invoice(xml, options)
214
211
  xml.add_element("TxnId").text = options[:order_id].to_s.slice(0, 16) unless options[:order_id].blank?
215
212
  xml.add_element("MerchantReference").text = options[:description] unless options[:description].blank?
216
213
  end
217
-
214
+
218
215
  def add_address_verification_data(xml, options)
219
216
  address = options[:billing_address] || options[:address]
220
217
  return if address.nil?
221
-
218
+
222
219
  xml.add_element("EnableAvsData").text = 1
223
220
  xml.add_element("AvsAction").text = 1
224
-
221
+
225
222
  xml.add_element("AvsStreetAddress").text = address[:address1]
226
223
  xml.add_element("AvsPostCode").text = address[:zip]
227
224
  end
228
-
225
+
229
226
  def new_transaction
230
227
  REXML::Document.new.add_element("Txn")
231
228
  end
@@ -234,10 +231,10 @@ module ActiveMerchant #:nodoc:
234
231
  def commit(action, request)
235
232
  add_credentials(request)
236
233
  add_transaction_type(request, action)
237
-
234
+
238
235
  # Parse the XML response
239
236
  response = parse( ssl_post(self.live_url, request.to_s) )
240
-
237
+
241
238
  # Return a response
242
239
  PaymentExpressResponse.new(response[:success] == APPROVED, response[:card_holder_help_text], response,
243
240
  :test => response[:test_mode] == '1',
@@ -249,7 +246,7 @@ module ActiveMerchant #:nodoc:
249
246
  def parse(xml_string)
250
247
  response = {}
251
248
 
252
- xml = REXML::Document.new(xml_string)
249
+ xml = REXML::Document.new(xml_string)
253
250
 
254
251
  # Gather all root elements such as HelpText
255
252
  xml.elements.each('Txn/*') do |element|
@@ -262,15 +259,15 @@ module ActiveMerchant #:nodoc:
262
259
  xml.elements.each('Txn/Transaction/*') do |element|
263
260
  response[element.name.underscore.to_sym] = element.text
264
261
  end
265
-
262
+
266
263
  response
267
264
  end
268
-
265
+
269
266
  def format_date(month, year)
270
267
  "#{format(month, :two_digits)}#{format(year, :two_digits)}"
271
268
  end
272
269
  end
273
-
270
+
274
271
  class PaymentExpressResponse < Response
275
272
  # add a method to response so we can easily get the token
276
273
  # for Validate transactions