activemerchant 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +226 -0
  3. data/CONTRIBUTERS +52 -0
  4. data/README +34 -24
  5. data/Rakefile +152 -0
  6. data/gem-public_cert.pem +20 -0
  7. data/init.rb +3 -0
  8. data/lib/active_merchant.rb +3 -1
  9. data/lib/active_merchant/billing/credit_card.rb +21 -17
  10. data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
  11. data/lib/active_merchant/billing/gateway.rb +160 -44
  12. data/lib/active_merchant/billing/gateways.rb +2 -15
  13. data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
  14. data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
  15. data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +77 -29
  21. data/lib/active_merchant/billing/gateways/exact.rb +230 -0
  22. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
  23. data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
  24. data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
  25. data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
  26. data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
  27. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
  28. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
  29. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
  30. data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
  31. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
  32. data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
  34. data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
  36. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
  37. data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
  38. data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
  39. data/lib/active_merchant/billing/gateways/protx.rb +285 -0
  40. data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
  41. data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
  42. data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
  43. data/lib/active_merchant/billing/gateways/realex.rb +212 -0
  44. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  45. data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
  46. data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
  47. data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
  48. data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
  49. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  50. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
  51. data/lib/active_merchant/billing/integrations/helper.rb +8 -1
  52. data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
  53. data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
  54. data/lib/active_merchant/billing/integrations/notification.rb +1 -1
  55. data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
  56. data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
  57. data/lib/active_merchant/lib/error.rb +4 -0
  58. data/lib/active_merchant/lib/post_data.rb +22 -0
  59. data/lib/active_merchant/lib/posts_data.rb +23 -5
  60. data/lib/active_merchant/lib/requires_parameters.rb +2 -2
  61. data/lib/active_merchant/lib/validateable.rb +1 -1
  62. data/lib/support/gateway_support.rb +45 -0
  63. data/lib/tasks/cia.rb +1 -1
  64. data/script/generate +14 -0
  65. data/script/generator/base.rb +45 -0
  66. data/script/generator/generator.rb +24 -0
  67. data/script/generator/generators/gateway/gateway_generator.rb +14 -0
  68. data/script/generator/generators/gateway/templates/gateway.rb +73 -0
  69. data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
  70. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
  71. data/script/generator/generators/integration/integration_generator.rb +25 -0
  72. data/script/generator/generators/integration/templates/helper.rb +34 -0
  73. data/script/generator/generators/integration/templates/helper_test.rb +54 -0
  74. data/script/generator/generators/integration/templates/integration.rb +18 -0
  75. data/script/generator/generators/integration/templates/module_test.rb +9 -0
  76. data/script/generator/generators/integration/templates/notification.rb +100 -0
  77. data/script/generator/generators/integration/templates/notification_test.rb +41 -0
  78. data/script/generator/manifest.rb +20 -0
  79. data/test/extra/binding_of_caller.rb +80 -0
  80. data/test/extra/breakpoint.rb +547 -0
  81. data/test/fixtures.yml +251 -0
  82. data/test/remote_tests/remote_authorize_net_test.rb +113 -0
  83. data/test/remote_tests/remote_brain_tree_test.rb +78 -0
  84. data/test/remote_tests/remote_card_stream_test.rb +160 -0
  85. data/test/remote_tests/remote_cyber_source_test.rb +130 -0
  86. data/test/remote_tests/remote_data_cash_test.rb +155 -0
  87. data/test/remote_tests/remote_efsnet_test.rb +93 -0
  88. data/test/remote_tests/remote_eway_test.rb +71 -0
  89. data/test/remote_tests/remote_exact_test.rb +59 -0
  90. data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
  91. data/test/remote_tests/remote_linkpoint_test.rb +144 -0
  92. data/test/remote_tests/remote_moneris_test.rb +110 -0
  93. data/test/remote_tests/remote_net_registry_test.rb +120 -0
  94. data/test/remote_tests/remote_pay_junction_test.rb +162 -0
  95. data/test/remote_tests/remote_payflow_express_test.rb +50 -0
  96. data/test/remote_tests/remote_payflow_test.rb +241 -0
  97. data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
  98. data/test/remote_tests/remote_payment_express_test.rb +136 -0
  99. data/test/remote_tests/remote_paypal_express_test.rb +49 -0
  100. data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
  101. data/test/remote_tests/remote_paypal_test.rb +163 -0
  102. data/test/remote_tests/remote_plugnpay_test.rb +70 -0
  103. data/test/remote_tests/remote_protx_test.rb +184 -0
  104. data/test/remote_tests/remote_psigate_test.rb +87 -0
  105. data/test/remote_tests/remote_psl_card_test.rb +105 -0
  106. data/test/remote_tests/remote_quickpay_test.rb +182 -0
  107. data/test/remote_tests/remote_realex_test.rb +227 -0
  108. data/test/remote_tests/remote_secure_pay_test.rb +36 -0
  109. data/test/remote_tests/remote_trans_first_test.rb +37 -0
  110. data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
  111. data/test/remote_tests/remote_usa_epay_test.rb +57 -0
  112. data/test/remote_tests/remote_verifi_test.rb +107 -0
  113. data/test/remote_tests/remote_viaklix_test.rb +53 -0
  114. data/test/test_helper.rb +132 -0
  115. data/test/unit/base_test.rb +61 -0
  116. data/test/unit/country_code_test.rb +33 -0
  117. data/test/unit/country_test.rb +64 -0
  118. data/test/unit/credit_card_formatting_test.rb +24 -0
  119. data/test/unit/credit_card_methods_test.rb +37 -0
  120. data/test/unit/credit_card_test.rb +365 -0
  121. data/test/unit/gateways/authorize_net_test.rb +140 -0
  122. data/test/unit/gateways/bogus_test.rb +43 -0
  123. data/test/unit/gateways/brain_tree_test.rb +77 -0
  124. data/test/unit/gateways/card_stream_test.rb +37 -0
  125. data/test/unit/gateways/cyber_source_test.rb +151 -0
  126. data/test/unit/gateways/data_cash_test.rb +23 -0
  127. data/test/unit/gateways/efsnet_test.rb +70 -0
  128. data/test/unit/gateways/eway_test.rb +105 -0
  129. data/test/unit/gateways/exact_test.rb +118 -0
  130. data/test/unit/gateways/gateway_test.rb +24 -0
  131. data/test/unit/gateways/linkpoint_test.rb +165 -0
  132. data/test/unit/gateways/moneris_test.rb +167 -0
  133. data/test/unit/gateways/net_registry_test.rb +478 -0
  134. data/test/unit/gateways/pay_junction_test.rb +61 -0
  135. data/test/unit/gateways/payflow_express_test.rb +165 -0
  136. data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
  137. data/test/unit/gateways/payflow_test.rb +230 -0
  138. data/test/unit/gateways/payflow_uk_test.rb +68 -0
  139. data/test/unit/gateways/payment_express_test.rb +215 -0
  140. data/test/unit/gateways/paypal_express_test.rb +222 -0
  141. data/test/unit/gateways/paypal_test.rb +241 -0
  142. data/test/unit/gateways/plugnpay_test.rb +79 -0
  143. data/test/unit/gateways/protx_test.rb +110 -0
  144. data/test/unit/gateways/psigate_test.rb +110 -0
  145. data/test/unit/gateways/psl_card_test.rb +51 -0
  146. data/test/unit/gateways/quickpay_test.rb +125 -0
  147. data/test/unit/gateways/realex_test.rb +150 -0
  148. data/test/unit/gateways/secure_pay_test.rb +78 -0
  149. data/test/unit/gateways/trans_first_test.rb +125 -0
  150. data/test/unit/gateways/trust_commerce_test.rb +57 -0
  151. data/test/unit/gateways/usa_epay_test.rb +117 -0
  152. data/test/unit/gateways/verifi_test.rb +91 -0
  153. data/test/unit/gateways/viaklix_test.rb +72 -0
  154. data/test/unit/integrations/action_view_helper_test.rb +54 -0
  155. data/test/unit/integrations/bogus_module_test.rb +16 -0
  156. data/test/unit/integrations/chronopay_module_test.rb +9 -0
  157. data/test/unit/integrations/gestpay_module_test.rb +10 -0
  158. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  159. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  160. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  161. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  162. data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
  163. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  164. data/test/unit/integrations/nochex_module_test.rb +9 -0
  165. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  166. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  167. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  168. data/test/unit/integrations/notifications/notification_test.rb +41 -0
  169. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  170. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  171. data/test/unit/integrations/paypal_module_test.rb +24 -0
  172. data/test/unit/integrations/two_checkout_module_test.rb +9 -0
  173. data/test/unit/post_data_test.rb +55 -0
  174. data/test/unit/response_test.rb +14 -0
  175. data/test/unit/validateable_test.rb +56 -0
  176. metadata +160 -7
  177. metadata.gz.sig +0 -0
  178. data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
@@ -1,38 +1,32 @@
1
- # Author:: Lucas Carlson (mailto:lucas@rufy.com)
2
- # Copyright:: Copyright (c) 2005 Lucas Carlson
3
- # License:: Distributes under the same terms as Ruby
4
-
5
1
  require 'rexml/document'
6
2
 
7
3
  module ActiveMerchant #:nodoc:
8
4
  module Billing #:nodoc:
9
- # TO USE:
10
5
  # First, make sure you have everything setup correctly and all of your dependencies in place with:
11
6
  #
12
7
  # require 'rubygems'
13
- # require 'money'
14
8
  # require 'active_merchant'
15
9
  #
16
- # The second line is a require for the 'money' library. Make sure you have it installed with 'gem install money'
17
- #
18
- # Using the money library, create a money object. Pass the dollar value in cents. In this case, $10 US becomes 1000.
10
+ # ActiveMerchant expects the amounts to be given as an Integer in cents. In this case, $10 US becomes 1000.
19
11
  #
20
- # tendollar = Money.us_dollar(1000)
12
+ # tendollar = 1000
21
13
  #
22
14
  # Next, create a credit card object using a TC approved test card.
23
15
  #
24
- # creditcard = ActiveMerchant::Billing::CreditCard.new({
16
+ # creditcard = ActiveMerchant::Billing::CreditCard.new(
25
17
  # :number => '4111111111111111',
26
18
  # :month => 8,
27
19
  # :year => 2006,
28
20
  # :first_name => 'Longbob',
29
21
  # :last_name => 'Longsen'
30
- # })
22
+ # )
31
23
  # options = {
32
- # :login => '87654321',
33
24
  # :order_id => '1230123',
34
25
  # :email => 'bob@testbob.com',
35
- # :address => { :address1 => '47 Bobway, Bobville, WA, Australia',
26
+ # :address => { :address1 => '47 Bobway',
27
+ # :city => 'Bobville',
28
+ # :state => 'WA',
29
+ # :country => 'Australia',
36
30
  # :zip => '2000'
37
31
  # }
38
32
  # :description => 'purchased items'
@@ -41,7 +35,7 @@ module ActiveMerchant #:nodoc:
41
35
  # To finish setting up, create the active_merchant object you will be using, with the eWay gateway. If you have a
42
36
  # functional eWay account, replace :login with your account info.
43
37
  #
44
- # gateway = ActiveMerchant::Billing::Base.gateway(:eway).new()
38
+ # gateway = ActiveMerchant::Billing::Base.gateway(:eway).new(:login => '87654321')
45
39
  #
46
40
  # Now we are ready to process our transaction
47
41
  #
@@ -73,13 +67,66 @@ module ActiveMerchant #:nodoc:
73
67
  LIVE_CVN_URL = 'https://www.eway.com.au/gateway_cvn/xmlpayment.asp'
74
68
 
75
69
  MESSAGES = {
76
- "00" => "Transaction was successfully processed",
77
- "A8" => "Amount is invalid",
78
- "A9" => "Card number is invalid",
79
- "AA" => "Account is invalid",
80
- "AB" => "Card expiry date is invalid",
81
- "01" => "Card verification number didn't match",
82
- "05" => "Card verification number didn't match"
70
+ "00" => "Transaction Approved",
71
+ "01" => "Refer to Issuer",
72
+ "02" => "Refer to Issuer, special",
73
+ "03" => "No Merchant",
74
+ "04" => "Pick Up Card",
75
+ "05" => "Do Not Honour",
76
+ "06" => "Error",
77
+ "07" => "Pick Up Card, Special",
78
+ "08" => "Honour With Identification",
79
+ "09" => "Request In Progress",
80
+ "10" => "Approved For Partial Amount",
81
+ "11" => "Approved, VIP",
82
+ "12" => "Invalid Transaction",
83
+ "13" => "Invalid Amount",
84
+ "14" => "Invalid Card Number",
85
+ "15" => "No Issuer",
86
+ "16" => "Approved, Update Track 3",
87
+ "19" => "Re-enter Last Transaction",
88
+ "21" => "No Action Taken",
89
+ "22" => "Suspected Malfunction",
90
+ "23" => "Unacceptable Transaction Fee",
91
+ "25" => "Unable to Locate Record On File",
92
+ "30" => "Format Error",
93
+ "31" => "Bank Not Supported By Switch",
94
+ "33" => "Expired Card, Capture",
95
+ "34" => "Suspected Fraud, Retain Card",
96
+ "35" => "Card Acceptor, Contact Acquirer, Retain Card",
97
+ "36" => "Restricted Card, Retain Card",
98
+ "37" => "Contact Acquirer Security Department, Retain Card",
99
+ "38" => "PIN Tries Exceeded, Capture",
100
+ "39" => "No Credit Account",
101
+ "40" => "Function Not Supported",
102
+ "41" => "Lost Card",
103
+ "42" => "No Universal Account",
104
+ "43" => "Stolen Card",
105
+ "44" => "No Investment Account",
106
+ "51" => "Insufficient Funds",
107
+ "52" => "No Cheque Account",
108
+ "53" => "No Savings Account",
109
+ "54" => "Expired Card",
110
+ "55" => "Incorrect PIN",
111
+ "56" => "No Card Record",
112
+ "57" => "Function Not Permitted to Cardholder",
113
+ "58" => "Function Not Permitted to Terminal",
114
+ "59" => "Suspected Fraud",
115
+ "60" => "Acceptor Contact Acquirer",
116
+ "61" => "Exceeds Withdrawal Limit",
117
+ "62" => "Restricted Card",
118
+ "63" => "Security Violation",
119
+ "64" => "Original Amount Incorrect",
120
+ "66" => "Acceptor Contact Acquirer, Security",
121
+ "67" => "Capture Card",
122
+ "75" => "PIN Tries Exceeded",
123
+ "82" => "CVV Validation Error",
124
+ "90" => "Cutoff In Progress",
125
+ "91" => "Card Issuer Unavailable",
126
+ "92" => "Unable To Route Transaction",
127
+ "93" => "Cannot Complete, Violation Of The Law",
128
+ "94" => "Duplicate Transaction",
129
+ "96" => "System Error"
83
130
  }
84
131
 
85
132
  attr_reader :url
@@ -87,6 +134,10 @@ module ActiveMerchant #:nodoc:
87
134
  attr_reader :options
88
135
 
89
136
  self.money_format = :cents
137
+ self.supported_countries = ['AU']
138
+ self.supported_cardtypes = [:visa, :master]
139
+ self.homepage_url = 'http://www.eway.com.au/'
140
+ self.display_name = 'eWAY'
90
141
 
91
142
  def initialize(options = {})
92
143
  requires!(options, :login)
@@ -109,10 +160,6 @@ module ActiveMerchant #:nodoc:
109
160
  commit(money, post)
110
161
  end
111
162
 
112
- def self.supported_cardtypes
113
- [:visa, :master]
114
- end
115
-
116
163
  private
117
164
  def add_creditcard(post, creditcard)
118
165
  post[:CardNumber] = creditcard.number
@@ -127,7 +174,7 @@ module ActiveMerchant #:nodoc:
127
174
 
128
175
  def add_address(post, options)
129
176
  if address = options[:billing_address] || options[:address]
130
- post[:CustomerAddress] = address[:address1]
177
+ post[:CustomerAddress] = [ address[:address1], address[:address2], address[:city], address[:state], address[:country] ].compact.join(', ')
131
178
  post[:CustomerPostcode] = address[:zip]
132
179
  end
133
180
  end
@@ -162,9 +209,11 @@ module ActiveMerchant #:nodoc:
162
209
 
163
210
  success = (response[:ewaytrxnstatus] == "True")
164
211
  message = message_from(response[:ewaytrxnerror])
212
+ test = /\(Test( CVN)? Gateway\)/ === response[:ewaytrxnerror]
165
213
 
166
214
  Response.new(success, message, @response,
167
- :authorization => response[:ewayauthcode]
215
+ :authorization => response[:ewayauthcode],
216
+ :test => test
168
217
  )
169
218
  end
170
219
 
@@ -184,7 +233,6 @@ module ActiveMerchant #:nodoc:
184
233
  # </ewayResponse>
185
234
 
186
235
  response = {}
187
-
188
236
  xml = REXML::Document.new(xml)
189
237
  xml.elements.each('//ewayResponse/*') do |node|
190
238
 
@@ -0,0 +1,230 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class ExactGateway < Gateway
4
+ URL = 'https://secure2.e-xact.com/vplug-in/transaction/rpc-enc/service.asmx'
5
+
6
+ API_VERSION = "8.5"
7
+
8
+ TEST_LOGINS = [ {:login => "A00049-01", :password => "test1"},
9
+ {:login => "A00427-01", :password => "testus"} ]
10
+
11
+ TRANSACTIONS = { :sale => "00",
12
+ :authorization => "01",
13
+ :capture => "32",
14
+ :credit => "34" }
15
+
16
+
17
+ ENVELOPE_NAMESPACES = { 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
18
+ 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
19
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
20
+ }
21
+
22
+ SEND_AND_COMMIT_ATTRIBUTES = { 'xmlns:n1' => "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Request",
23
+ 'env:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
24
+ }
25
+
26
+ SEND_AND_COMMIT_SOURCE_ATTRIBUTES = { 'xmlns:n2' => 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes',
27
+ 'xsi:type' => 'n2:Transaction'
28
+ }
29
+
30
+ POST_HEADERS = { 'soapAction' => "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/SendAndCommit",
31
+ 'Content-Type' => 'text/xml'
32
+ }
33
+
34
+ SUCCESS = "true"
35
+
36
+ SENSITIVE_FIELDS = [ :verification_str2, :expiry_date, :card_number ]
37
+
38
+ self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover]
39
+ self.supported_countries = ['CA', 'US']
40
+ self.homepage_url = 'http://www.e-xact.com'
41
+ self.display_name = 'E-xact'
42
+
43
+ attr_reader :url
44
+ attr_reader :response
45
+ attr_reader :options
46
+
47
+ def initialize(options = {})
48
+ requires!(options, :login, :password)
49
+ @options = options
50
+
51
+ if TEST_LOGINS.include?( { :login => options[:login], :password => options[:password] } )
52
+ @test_mode = true
53
+ end
54
+
55
+ super
56
+ end
57
+
58
+ def test?
59
+ @test_mode || Base.gateway_mode == :test
60
+ end
61
+
62
+ def authorize(money, credit_card, options = {})
63
+ if result = test_result_from_cc_number(credit_card.number)
64
+ return result
65
+ end
66
+
67
+ commit(:authorization, build_sale_or_authorization_request(money, credit_card, options))
68
+ end
69
+
70
+ def purchase(money, credit_card, options = {})
71
+ if result = test_result_from_cc_number(credit_card.number)
72
+ return result
73
+ end
74
+
75
+ commit(:sale, build_sale_or_authorization_request(money, credit_card, options))
76
+ end
77
+
78
+ def capture(money, authorization, options = {})
79
+ commit(:capture, build_capture_or_credit_request(money, authorization, options))
80
+ end
81
+
82
+ def credit(money, authorization, options = {})
83
+ commit(:credit, build_capture_or_credit_request(money, authorization, options))
84
+ end
85
+
86
+ private
87
+ def build_request(action, body)
88
+ xml = Builder::XmlMarkup.new
89
+
90
+ xml.instruct!
91
+ xml.tag! 'env:Envelope', ENVELOPE_NAMESPACES do
92
+ xml.tag! 'env:Body' do
93
+ xml.tag! 'n1:SendAndCommit', SEND_AND_COMMIT_ATTRIBUTES do
94
+ xml.tag! 'SendAndCommitSource', SEND_AND_COMMIT_SOURCE_ATTRIBUTES do
95
+ add_credentials(xml)
96
+ add_transaction_type(xml, action)
97
+ xml << body
98
+ end
99
+ end
100
+ end
101
+ end
102
+ xml.target!
103
+ end
104
+
105
+ def build_sale_or_authorization_request(money, credit_card, options)
106
+ xml = Builder::XmlMarkup.new
107
+
108
+ add_amount(xml, money)
109
+ add_credit_card(xml, credit_card)
110
+ add_customer_data(xml, options)
111
+ add_invoice(xml, options)
112
+
113
+ xml.target!
114
+ end
115
+
116
+ def build_capture_or_credit_request(money, identification, options)
117
+ xml = Builder::XmlMarkup.new
118
+
119
+ add_identification(xml, identification)
120
+ add_amount(xml, money)
121
+ add_customer_data(xml, options)
122
+
123
+ xml.target!
124
+ end
125
+
126
+ def add_credentials(xml)
127
+ xml.tag! 'ExactID', @options[:login]
128
+ xml.tag! 'Password', @options[:password]
129
+ end
130
+
131
+ def add_transaction_type(xml, action)
132
+ xml.tag! 'Transaction_Type', TRANSACTIONS[action]
133
+ end
134
+
135
+ def add_identification(xml, identification)
136
+ authorization_num, transaction_tag = identification.split(';')
137
+
138
+ xml.tag! 'Authorization_Num', authorization_num
139
+ xml.tag! 'Transaction_Tag', transaction_tag
140
+ end
141
+
142
+ def add_amount(xml, money)
143
+ xml.tag! 'DollarAmount', amount(money)
144
+ end
145
+
146
+ def add_credit_card(xml, credit_card)
147
+ xml.tag! 'Card_Number', credit_card.number
148
+ xml.tag! 'Expiry_Date', expdate(credit_card)
149
+ xml.tag! 'CardHoldersName', credit_card.name
150
+
151
+ if credit_card.verification_value?
152
+ xml.tag! 'CVD_Presence_Ind', '1'
153
+ xml.tag! 'VerificationStr2', credit_card.verification_value
154
+ end
155
+ end
156
+
157
+ def add_customer_data(xml, options)
158
+ xml.tag! 'Customer_Ref', options[:customer]
159
+ xml.tag! 'Client_IP', options[:ip]
160
+ xml.tag! 'Client_Email', options[:email]
161
+ end
162
+
163
+ def add_address(xml, options)
164
+ if address = options[:billing_address] || options[:address]
165
+ xml.tag! 'ZipCode', address[:zip]
166
+ end
167
+ end
168
+
169
+ def add_invoice(xml, options)
170
+ xml.tag! 'Reference_No', options[:order_id]
171
+ xml.tag! 'Reference_3', options[:description]
172
+ end
173
+
174
+ def expdate(credit_card)
175
+ "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
176
+ end
177
+
178
+ def commit(action, request)
179
+ data = ssl_post(URL, build_request(action, request), POST_HEADERS)
180
+
181
+ @response = parse(data)
182
+
183
+ success = @response[:transaction_approved] == SUCCESS
184
+
185
+ authorization = if @response[:authorization_num] && @response[:transaction_tag]
186
+ "#{response[:authorization_num]};#{response[:transaction_tag]}"
187
+ else
188
+ ''
189
+ end
190
+
191
+ Response.new(success, message_from(@response), @response,
192
+ :test => test?,
193
+ :authorization => authorization
194
+ )
195
+ end
196
+
197
+ def message_from(response)
198
+ if response[:faultcode] && response[:faultstring]
199
+ response[:faultstring]
200
+ elsif response[:error_number] != '0'
201
+ response[:error_description]
202
+ else
203
+ result = response[:exact_message] || ''
204
+ result << " - #{response[:bank_message]}" unless response[:bank_message].blank?
205
+ result
206
+ end
207
+ end
208
+
209
+ def parse(xml)
210
+ response = {}
211
+ xml = REXML::Document.new(xml)
212
+
213
+ if root = REXML::XPath.first(xml, "//types:TransactionResult")
214
+ parse_elements(response, root)
215
+ elsif root = REXML::XPath.first(xml, "//soap:Fault")
216
+ parse_elements(response, root)
217
+ end
218
+
219
+ response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) }
220
+ end
221
+
222
+ def parse_elements(response, root)
223
+ root.elements.to_a.each do |node|
224
+ response[node.name.gsub(/EXact/, 'Exact').underscore.to_sym] = (node.text || '').strip
225
+ end
226
+ end
227
+ end
228
+ end
229
+ end
230
+
@@ -1,27 +1,3 @@
1
- # Portions of the LinkPoint Gateway by Ryan Heneise
2
- #--
3
- # Copyright (c) 2005 Tobias Luetke
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining
6
- # a copy of this software and associated documentation files (the
7
- # "Software"), to deal in the Software without restriction, including
8
- # without limitation the rights to use, copy, modify, merge, publish,
9
- # distribute, sublicense, and/or sell copies of the Software, and to
10
- # permit persons to whom the Software is furnished to do so, subject to
11
- # the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be
14
- # included in all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- #++
24
-
25
1
  require 'rexml/document'
26
2
 
27
3
  module ActiveMerchant #:nodoc:
@@ -130,11 +106,12 @@ module ActiveMerchant #:nodoc:
130
106
 
131
107
  # We don't have the certificate to verify LinkPoint
132
108
  self.ssl_strict = false
109
+
110
+ self.supported_countries = ['US']
111
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
112
+ self.homepage_url = 'http://www.linkpoint.com/'
113
+ self.display_name = 'LinkPoint'
133
114
 
134
- # @options = {
135
- # :store_number => options[:login],
136
- # :result => test? ? "GOOD" : "LIVE"
137
- # }.update(options)
138
115
  def initialize(options = {})
139
116
  requires!(options, :login)
140
117
 
@@ -237,11 +214,7 @@ module ActiveMerchant #:nodoc:
237
214
  )
238
215
  commit(money, nil, options)
239
216
  end
240
-
241
- def self.supported_cardtypes
242
- [:visa, :master, :discover, :american_express]
243
- end
244
-
217
+
245
218
  def test?
246
219
  @options[:test] || Base.gateway_mode == :test
247
220
  end