activemerchant 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +78 -0
  3. data/{CONTRIBUTERS → CONTRIBUTORS} +44 -0
  4. data/{README → README.rdoc} +4 -1
  5. data/Rakefile +7 -13
  6. data/lib/active_merchant.rb +11 -21
  7. data/lib/active_merchant/billing/avs_result.rb +13 -10
  8. data/lib/active_merchant/billing/base.rb +2 -2
  9. data/lib/active_merchant/billing/check.rb +1 -1
  10. data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
  11. data/lib/active_merchant/billing/expiry_date.rb +10 -4
  12. data/lib/active_merchant/billing/gateway.rb +7 -6
  13. data/lib/active_merchant/billing/gateways.rb +18 -3
  14. data/lib/active_merchant/billing/gateways/authorize_net.rb +20 -12
  15. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +40 -6
  16. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig +736 -0
  17. data/lib/active_merchant/billing/gateways/braintree.rb +6 -211
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +5 -7
  19. data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +7 -2
  21. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  22. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  23. data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
  24. data/lib/active_merchant/billing/gateways/linkpoint.rb +65 -12
  25. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  26. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  27. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +12 -6
  28. data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
  29. data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
  30. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +20 -32
  34. data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  36. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/psl_card.rb +4 -6
  38. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +7 -1
  39. data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +60 -35
  40. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  41. data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
  42. data/lib/active_merchant/billing/gateways/skip_jack.rb +23 -10
  43. data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
  44. data/lib/active_merchant/billing/gateways/transax.rb +25 -0
  45. data/lib/active_merchant/billing/gateways/viaklix.rb +38 -14
  46. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -2
  47. data/lib/active_merchant/billing/integrations.rb +18 -11
  48. data/lib/active_merchant/billing/integrations/bogus.rb +4 -3
  49. data/lib/active_merchant/billing/integrations/chronopay.rb +4 -3
  50. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +3 -1
  51. data/lib/active_merchant/billing/integrations/gestpay.rb +4 -5
  52. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +3 -1
  53. data/lib/active_merchant/billing/integrations/hi_trust.rb +4 -3
  54. data/lib/active_merchant/billing/integrations/nochex.rb +4 -3
  55. data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
  56. data/lib/active_merchant/billing/integrations/paypal.rb +3 -4
  57. data/lib/active_merchant/billing/integrations/paypal/helper.rb +9 -8
  58. data/lib/active_merchant/billing/integrations/quickpay.rb +2 -3
  59. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +1 -1
  60. data/lib/active_merchant/billing/integrations/two_checkout.rb +3 -3
  61. data/lib/active_merchant/lib/connection.rb +170 -0
  62. data/lib/active_merchant/lib/country.rb +4 -1
  63. data/lib/active_merchant/lib/posts_data.rb +22 -84
  64. data/test/fixtures.yml +39 -1
  65. data/test/remote/gateways/remote_authorize_net_cim_test.rb +2 -1
  66. data/test/remote/gateways/remote_authorize_net_test.rb +1 -1
  67. data/test/remote/gateways/remote_beanstream_interac_test.rb +1 -1
  68. data/test/remote/gateways/remote_beanstream_test.rb +1 -1
  69. data/test/remote/gateways/remote_braintree_test.rb +2 -9
  70. data/test/remote/gateways/remote_card_stream_test.rb +1 -1
  71. data/test/remote/gateways/remote_cyber_source_test.rb +1 -1
  72. data/test/remote/gateways/remote_data_cash_test.rb +1 -2
  73. data/test/remote/gateways/remote_efsnet_test.rb +1 -1
  74. data/test/remote/gateways/remote_elavon_test.rb +66 -0
  75. data/test/remote/gateways/remote_eway_test.rb +1 -1
  76. data/test/remote/gateways/remote_exact_test.rb +1 -1
  77. data/test/remote/gateways/remote_first_pay_test.rb +87 -0
  78. data/test/remote/gateways/remote_instapay_test.rb +61 -0
  79. data/test/remote/gateways/remote_jetpay_test.rb +103 -0
  80. data/test/remote/gateways/remote_linkpoint_test.rb +11 -2
  81. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
  82. data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
  83. data/test/remote/gateways/remote_modern_payments_cim_test.rb +1 -1
  84. data/test/remote/gateways/remote_modern_payments_test.rb +23 -9
  85. data/test/remote/gateways/remote_moneris_test.rb +1 -1
  86. data/test/remote/gateways/remote_net_registry_test.rb +1 -1
  87. data/test/remote/gateways/remote_netbilling_test.rb +1 -1
  88. data/test/remote/gateways/remote_ogone_test.rb +115 -0
  89. data/test/remote/gateways/remote_pay_junction_test.rb +1 -1
  90. data/test/remote/gateways/remote_pay_secure_test.rb +1 -1
  91. data/test/remote/gateways/remote_payflow_express_test.rb +1 -1
  92. data/test/remote/gateways/remote_payflow_test.rb +1 -1
  93. data/test/remote/gateways/remote_payflow_uk_test.rb +1 -1
  94. data/test/remote/gateways/remote_payment_express_test.rb +17 -7
  95. data/test/remote/gateways/remote_paypal_express_test.rb +1 -1
  96. data/test/remote/gateways/remote_paypal_test.rb +26 -2
  97. data/test/remote/gateways/remote_plugnpay_test.rb +1 -1
  98. data/test/remote/gateways/remote_psigate_test.rb +1 -1
  99. data/test/remote/gateways/remote_psl_card_test.rb +1 -3
  100. data/test/remote/gateways/remote_quickpay_test.rb +1 -1
  101. data/test/remote/gateways/remote_realex_test.rb +1 -1
  102. data/test/remote/gateways/remote_sage_bankcard_test.rb +1 -1
  103. data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
  104. data/test/remote/gateways/remote_sage_test.rb +1 -1
  105. data/test/remote/gateways/remote_sage_virtual_check_test.rb +1 -1
  106. data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
  107. data/test/remote/gateways/remote_secure_pay_au_test.rb +1 -1
  108. data/test/remote/gateways/remote_secure_pay_tech_test.rb +1 -1
  109. data/test/remote/gateways/remote_secure_pay_test.rb +2 -2
  110. data/test/remote/gateways/remote_skipjack_test.rb +1 -1
  111. data/test/remote/gateways/remote_trans_first_test.rb +1 -1
  112. data/test/remote/gateways/remote_transax_test.rb +112 -0
  113. data/test/remote/gateways/remote_trust_commerce_test.rb +1 -1
  114. data/test/remote/gateways/remote_usa_epay_test.rb +1 -1
  115. data/test/remote/gateways/remote_verifi_test.rb +1 -1
  116. data/test/remote/gateways/remote_viaklix_test.rb +1 -1
  117. data/test/remote/gateways/remote_wirecard_test.rb +34 -0
  118. data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
  119. data/test/remote/integrations/remote_paypal_integration_test.rb +1 -1
  120. data/test/test_helper.rb +81 -89
  121. data/test/unit/avs_result_test.rb +1 -1
  122. data/test/unit/base_test.rb +1 -2
  123. data/test/unit/check_test.rb +1 -1
  124. data/test/unit/connection_test.rb +129 -0
  125. data/test/unit/country_code_test.rb +1 -1
  126. data/test/unit/country_test.rb +1 -1
  127. data/test/unit/credit_card_formatting_test.rb +1 -1
  128. data/test/unit/credit_card_methods_test.rb +10 -1
  129. data/test/unit/credit_card_test.rb +1 -1
  130. data/test/unit/cvv_result_test.rb +1 -1
  131. data/test/unit/expiry_date_test.rb +13 -2
  132. data/test/unit/gateways/authorize_net_cim_test.rb +39 -1
  133. data/test/unit/gateways/authorize_net_test.rb +1 -1
  134. data/test/unit/gateways/beanstream_interac_test.rb +1 -1
  135. data/test/unit/gateways/beanstream_test.rb +1 -1
  136. data/test/unit/gateways/bogus_test.rb +1 -1
  137. data/test/unit/gateways/braintree_test.rb +16 -14
  138. data/test/unit/gateways/card_stream_test.rb +1 -1
  139. data/test/unit/gateways/cyber_source_test.rb +1 -1
  140. data/test/unit/gateways/data_cash_test.rb +2 -1
  141. data/test/unit/gateways/efsnet_test.rb +1 -1
  142. data/test/unit/gateways/elavon_test.rb +139 -0
  143. data/test/unit/gateways/eway_test.rb +1 -1
  144. data/test/unit/gateways/exact_test.rb +1 -1
  145. data/test/unit/gateways/first_pay_test.rb +125 -0
  146. data/test/unit/gateways/gateway_test.rb +1 -1
  147. data/test/unit/gateways/instapay_test.rb +102 -0
  148. data/test/unit/gateways/jetpay_test.rb +185 -0
  149. data/test/unit/gateways/linkpoint_test.rb +37 -7
  150. data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
  151. data/test/unit/gateways/merchant_ware_test.rb +188 -0
  152. data/test/unit/gateways/modern_payments_cim_test.rb +25 -34
  153. data/test/unit/gateways/moneris_test.rb +1 -1
  154. data/test/unit/gateways/net_registry_test.rb +1 -1
  155. data/test/unit/gateways/netbilling_test.rb +1 -1
  156. data/test/unit/gateways/ogone_test.rb +319 -0
  157. data/test/unit/gateways/pay_junction_test.rb +1 -1
  158. data/test/unit/gateways/pay_secure_test.rb +1 -1
  159. data/test/unit/gateways/payflow_express_test.rb +2 -2
  160. data/test/unit/gateways/payflow_express_uk_test.rb +73 -1
  161. data/test/unit/gateways/payflow_test.rb +1 -1
  162. data/test/unit/gateways/payflow_uk_test.rb +1 -1
  163. data/test/unit/gateways/payment_express_test.rb +3 -3
  164. data/test/unit/gateways/paypal_express_test.rb +1 -1
  165. data/test/unit/gateways/paypal_test.rb +50 -1
  166. data/test/unit/gateways/plugnpay_test.rb +1 -1
  167. data/test/unit/gateways/psigate_test.rb +1 -1
  168. data/test/unit/gateways/psl_card_test.rb +1 -1
  169. data/test/unit/gateways/quickpay_test.rb +1 -1
  170. data/test/unit/gateways/realex_test.rb +1 -1
  171. data/test/unit/gateways/sage_bankcard_test.rb +36 -2
  172. data/test/unit/gateways/{protx_test.rb → sage_pay_test.rb} +49 -32
  173. data/test/unit/gateways/sage_virtual_check_test.rb +1 -1
  174. data/test/unit/gateways/sallie_mae_test.rb +53 -0
  175. data/test/unit/gateways/secure_pay_au_test.rb +1 -1
  176. data/test/unit/gateways/secure_pay_tech_test.rb +1 -1
  177. data/test/unit/gateways/secure_pay_test.rb +24 -10
  178. data/test/unit/gateways/skip_jack_test.rb +81 -1
  179. data/test/unit/gateways/trans_first_test.rb +1 -1
  180. data/test/unit/gateways/trust_commerce_test.rb +1 -1
  181. data/test/unit/gateways/usa_epay_test.rb +1 -1
  182. data/test/unit/gateways/verifi_test.rb +1 -1
  183. data/test/unit/gateways/viaklix_test.rb +1 -1
  184. data/test/unit/gateways/wirecard_test.rb +19 -1
  185. data/test/unit/generators/test_generator_helper.rb +1 -1
  186. data/test/unit/integrations/action_view_helper_test.rb +1 -1
  187. data/test/unit/integrations/bogus_module_test.rb +1 -1
  188. data/test/unit/integrations/chronopay_module_test.rb +1 -1
  189. data/test/unit/integrations/gestpay_module_test.rb +1 -1
  190. data/test/unit/integrations/helpers/bogus_helper_test.rb +1 -1
  191. data/test/unit/integrations/helpers/chronopay_helper_test.rb +1 -1
  192. data/test/unit/integrations/helpers/gestpay_helper_test.rb +1 -1
  193. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +1 -1
  194. data/test/unit/integrations/helpers/nochex_helper_test.rb +1 -1
  195. data/test/unit/integrations/helpers/paypal_helper_test.rb +11 -2
  196. data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
  197. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +1 -1
  198. data/test/unit/integrations/hi_trust_module_test.rb +1 -1
  199. data/test/unit/integrations/nochex_module_test.rb +1 -1
  200. data/test/unit/integrations/notifications/chronopay_notification_test.rb +1 -1
  201. data/test/unit/integrations/notifications/gestpay_notification_test.rb +1 -1
  202. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +1 -1
  203. data/test/unit/integrations/notifications/nochex_notification_test.rb +2 -2
  204. data/test/unit/integrations/notifications/notification_test.rb +1 -1
  205. data/test/unit/integrations/notifications/paypal_notification_test.rb +1 -1
  206. data/test/unit/integrations/notifications/quickpay_notification_test.rb +1 -1
  207. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +1 -1
  208. data/test/unit/integrations/paypal_module_test.rb +1 -1
  209. data/test/unit/integrations/quickpay_module_test.rb +1 -1
  210. data/test/unit/integrations/returns/chronopay_return_test.rb +1 -1
  211. data/test/unit/integrations/returns/gestpay_return_test.rb +1 -1
  212. data/test/unit/integrations/returns/hi_trust_return_test.rb +1 -1
  213. data/test/unit/integrations/returns/nochex_return_test.rb +1 -1
  214. data/test/unit/integrations/returns/paypal_return_test.rb +1 -1
  215. data/test/unit/integrations/returns/return_test.rb +1 -1
  216. data/test/unit/integrations/returns/two_checkout_return_test.rb +1 -1
  217. data/test/unit/integrations/two_checkout_module_test.rb +1 -1
  218. data/test/unit/post_data_test.rb +1 -1
  219. data/test/unit/posts_data_test.rb +14 -66
  220. data/test/unit/response_test.rb +1 -1
  221. data/test/unit/utils_test.rb +1 -1
  222. data/test/unit/validateable_test.rb +1 -1
  223. metadata +41 -45
  224. metadata.gz.sig +0 -0
  225. data/test/extra/binding_of_caller.rb +0 -80
  226. data/test/extra/breakpoint.rb +0 -547
  227. data/test/remote/gateways/remote_protx_test.rb +0 -184
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
  base.cattr_accessor :signature
9
9
  end
10
10
 
11
- API_VERSION = '52.0'
11
+ API_VERSION = '59.0'
12
12
 
13
13
  URLS = {
14
14
  :test => { :certificate => 'https://api.sandbox.paypal.com/2.0/',
@@ -133,6 +133,7 @@ module ActiveMerchant #:nodoc:
133
133
  xml.tag! 'AuthorizationID', authorization
134
134
  xml.tag! 'Amount', amount(money), 'currencyID' => options[:currency] || currency(money)
135
135
  xml.tag! 'CompleteType', 'Complete'
136
+ xml.tag! 'InvoiceID', options[:order_id] unless options[:order_id].blank?
136
137
  xml.tag! 'Note', options[:description]
137
138
  end
138
139
  end
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  # The PayPal gateway for PayPal Website Payments Pro Canada only supports Visa and MasterCard
6
6
  class PaypalCaGateway < PaypalGateway
7
- self.supported_cardtypes = [:visa, :master]
7
+ self.supported_cardtypes = [:visa, :master, :american_express]
8
8
  self.supported_countries = ['CA']
9
9
  self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside'
10
10
  self.display_name = 'PayPal Website Payments Pro (CA)'
@@ -1,5 +1,3 @@
1
- # Author:: MoneySpyder, http://moneyspyder.co.uk
2
-
3
1
  module ActiveMerchant
4
2
  module Billing
5
3
  #
@@ -99,7 +97,7 @@ module ActiveMerchant
99
97
  # Purchase the item straight away
100
98
  #
101
99
  # Parameters:
102
- # -money: Money object for the total to be charged
100
+ # -money: Amount to be charged as an Integer value in cents
103
101
  # -authorization: the PSL cross reference from the previous authorization
104
102
  # -options:
105
103
  #
@@ -127,7 +125,7 @@ module ActiveMerchant
127
125
  # is available and only 'reserves' the nominal amount (currently a pound and a penny)
128
126
  #
129
127
  # Parameters:
130
- # -money: Money object for the total to be charged
128
+ # -money: Amount to be charged as an Integer value in cents
131
129
  # -authorization: the PSL cross reference from the previous authorization
132
130
  # -options:
133
131
  #
@@ -151,7 +149,7 @@ module ActiveMerchant
151
149
  # Captures the funds from an authorized transaction.
152
150
  #
153
151
  # Parameters:
154
- # -money: Money object for the total to be charged
152
+ # -money: Amount to be charged as an Integer value in cents
155
153
  # -authorization: The PSL Cross Reference
156
154
  # -options:
157
155
  #
@@ -230,7 +228,7 @@ module ActiveMerchant
230
228
  # however PSL requires the ISO 4217:2001 Numeric code.
231
229
  #
232
230
  # Parameters:
233
- # -money: Money object with the amount and currency
231
+ # -money: Integer value in cents
234
232
  #
235
233
  # Returns:
236
234
  # -the ISO 4217:2001 Numberic currency code
@@ -55,7 +55,13 @@ module ActiveMerchant #:nodoc:
55
55
 
56
56
  post[:C_address] = billing_address[:address1]
57
57
  post[:C_city] = billing_address[:city]
58
- post[:C_state] = billing_address[:state]
58
+
59
+ if ['US', 'CA'].include?(billing_address[:country])
60
+ post[:C_state] = billing_address[:state]
61
+ else
62
+ post[:C_state] = "Outside of United States"
63
+ end
64
+
59
65
  post[:C_zip] = billing_address[:zip]
60
66
  post[:C_country] = billing_address[:country]
61
67
  post[:C_telephone] = billing_address[:phone]
@@ -1,13 +1,13 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
- class ProtxGateway < Gateway
3
+ class SagePayGateway < Gateway
4
4
  cattr_accessor :simulate
5
5
  self.simulate = false
6
6
 
7
- TEST_URL = 'https://ukvpstest.protx.com/vspgateway/service'
8
- LIVE_URL = 'https://ukvps.protx.com/vspgateway/service'
9
- SIMULATOR_URL = 'https://ukvpstest.protx.com/VSPSimulator'
10
-
7
+ TEST_URL = 'https://test.sagepay.com/gateway/service'
8
+ LIVE_URL = 'https://live.sagepay.com/gateway/service'
9
+ SIMULATOR_URL = 'https://test.sagepay.com/Simulator'
10
+
11
11
  APPROVED = 'OK'
12
12
 
13
13
  TRANSACTIONS = {
@@ -15,7 +15,8 @@ module ActiveMerchant #:nodoc:
15
15
  :credit => 'REFUND',
16
16
  :authorization => 'DEFERRED',
17
17
  :capture => 'RELEASE',
18
- :void => 'VOID'
18
+ :void => 'VOID',
19
+ :abort => 'ABORT'
19
20
  }
20
21
 
21
22
  CREDIT_CARDS = {
@@ -44,8 +45,8 @@ module ActiveMerchant #:nodoc:
44
45
  self.supported_countries = ['GB']
45
46
  self.default_currency = 'GBP'
46
47
 
47
- self.homepage_url = 'http://www.protx.com'
48
- self.display_name = 'Protx'
48
+ self.homepage_url = 'http://www.sagepay.com'
49
+ self.display_name = 'SagePay'
49
50
 
50
51
  def initialize(options = {})
51
52
  requires!(options, :login)
@@ -99,9 +100,11 @@ module ActiveMerchant #:nodoc:
99
100
  post = {}
100
101
 
101
102
  add_reference(post, identification)
102
- commit(:void, post)
103
+ action = abort_or_void_from(identification)
104
+
105
+ commit(action, post)
103
106
  end
104
-
107
+
105
108
  # Crediting requires a new order_id to passed in, as well as a description
106
109
  def credit(money, identification, options = {})
107
110
  requires!(options, :order_id, :description)
@@ -145,29 +148,35 @@ module ActiveMerchant #:nodoc:
145
148
  end
146
149
 
147
150
  def add_customer_data(post, options)
148
- add_pair(post, :BillingEmail, options[:email][0,255]) unless options[:email].blank?
149
- add_pair(post, :ContactNumber, options[:phone].gsub(/[^0-9+]/, '')[0,20]) unless options[:phone].blank?
150
- add_pair(post, :ContactFax, options[:fax].gsub(/[^0-9+]/, '')[0,20]) unless options[:fax].blank?
151
+ add_pair(post, :CustomerEMail, options[:email][0,255]) unless options[:email].blank?
152
+ add_pair(post, :BillingPhone, options[:phone].gsub(/[^0-9+]/, '')[0,20]) unless options[:phone].blank?
151
153
  add_pair(post, :ClientIPAddress, options[:ip])
152
154
  end
153
155
 
154
156
  def add_address(post, options)
155
- address = options[:billing_address] || options[:address]
156
- shipping_address = options[:shipping_address] || ''
157
+ if billing_address = options[:billing_address] || options[:address]
158
+ first_name, last_name = parse_first_and_last_name(billing_address[:name])
159
+ add_pair(post, :BillingSurname, last_name)
160
+ add_pair(post, :BillingFirstnames, first_name)
161
+ add_pair(post, :BillingAddress1, billing_address[:address1])
162
+ add_pair(post, :BillingAddress2, billing_address[:address2])
163
+ add_pair(post, :BillingCity, billing_address[:city])
164
+ add_pair(post, :BillingState, billing_address[:state]) if billing_address[:country] == 'US'
165
+ add_pair(post, :BillingCountry, billing_address[:country])
166
+ add_pair(post, :BillingPostCode, billing_address[:zip])
167
+ end
157
168
 
158
- return if address.blank?
159
-
160
- billing = "#{address[:address1]}\n#{address[:address2]}\n#{address[:city]}\n#{address[:state]}"
161
-
162
- add_pair(post, :BillingAddress, billing)
163
- add_pair(post, :BillingPostcode, address[:zip])
164
-
165
- return if shipping_address.blank?
166
-
167
- shipping = "#{shipping_address[:address1]}\n#{shipping_address[:address2]}\n#{shipping_address[:city]}\n#{shipping_address[:state]}"
168
-
169
- add_pair(post, :DeliveryAddress, shipping)
170
- add_pair(post, :DeliveryPostcode, shipping_address[:zip])
169
+ if shipping_address = options[:shipping_address] || billing_address
170
+ first_name, last_name = parse_first_and_last_name(shipping_address[:name])
171
+ add_pair(post, :DeliverySurname, last_name)
172
+ add_pair(post, :DeliveryFirstnames, first_name)
173
+ add_pair(post, :DeliveryAddress1, shipping_address[:address1])
174
+ add_pair(post, :DeliveryAddress2, shipping_address[:address2])
175
+ add_pair(post, :DeliveryCity, shipping_address[:city])
176
+ add_pair(post, :DeliveryState, shipping_address[:state]) if shipping_address[:country] == 'US'
177
+ add_pair(post, :DeliveryCountry, shipping_address[:country])
178
+ add_pair(post, :DeliveryPostCode, shipping_address[:zip])
179
+ end
171
180
  end
172
181
 
173
182
  def add_invoice(post, options)
@@ -222,7 +231,7 @@ module ActiveMerchant #:nodoc:
222
231
 
223
232
  Response.new(response["Status"] == APPROVED, message_from(response), response,
224
233
  :test => test?,
225
- :authorization => authorization_from(response, parameters),
234
+ :authorization => authorization_from(response, parameters, action),
226
235
  :avs_result => {
227
236
  :street_match => AVS_CVV_CODE[ response["AddressResult"] ],
228
237
  :postal_match => AVS_CVV_CODE[ response["PostCodeResult"] ],
@@ -231,13 +240,19 @@ module ActiveMerchant #:nodoc:
231
240
  )
232
241
  end
233
242
 
234
- def authorization_from(response, params)
243
+ def authorization_from(response, params, action)
235
244
  [ params[:VendorTxCode],
236
245
  response["VPSTxId"],
237
246
  response["TxAuthNo"],
238
- response["SecurityKey"] ].join(";")
247
+ response["SecurityKey"],
248
+ action ].join(";")
239
249
  end
240
-
250
+
251
+ def abort_or_void_from(identification)
252
+ original_transaction = identification.split(';').last
253
+ original_transaction == 'authorization' ? :abort : :void
254
+ end
255
+
241
256
  def url_for(action)
242
257
  simulate ? build_simulator_url(action) : build_url(action)
243
258
  end
@@ -260,24 +275,34 @@ module ActiveMerchant #:nodoc:
260
275
  parameters.update(
261
276
  :Vendor => @options[:login],
262
277
  :TxType => TRANSACTIONS[action],
263
- :VPSProtocol => "2.22"
278
+ :VPSProtocol => "2.23"
264
279
  )
265
280
 
266
281
  parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
267
282
  end
268
283
 
269
- # Protx returns data in the following format
284
+ # SagePay returns data in the following format
270
285
  # Key1=value1
271
286
  # Key2=value2
272
287
  def parse(body)
273
288
  result = {}
274
- body.to_a.each { |pair| result[$1] = $2 if pair.strip =~ /\A([^=]+)=(.+)\Z/im }
289
+ body.to_s.each_line do |pair|
290
+ result[$1] = $2 if pair.strip =~ /\A([^=]+)=(.+)\Z/im
291
+ end
275
292
  result
276
293
  end
277
294
 
278
295
  def add_pair(post, key, value, options = {})
279
296
  post[key] = value if !value.blank? || options[:required]
280
297
  end
298
+
299
+ def parse_first_and_last_name(value)
300
+ name = value.to_s.split(' ')
301
+
302
+ last_name = name.pop || ''
303
+ first_name = name.join(' ')
304
+ [ first_name[0,20], last_name[0,20] ]
305
+ end
281
306
  end
282
307
  end
283
308
  end
@@ -0,0 +1,144 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class SallieMaeGateway < Gateway
4
+ URL = 'https://trans.salliemae.com/cgi-bin/process.cgi'
5
+
6
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
7
+ self.supported_countries = ['US']
8
+
9
+ # The card types supported by the payment gateway
10
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
11
+
12
+ # The homepage URL of the gateway
13
+ self.homepage_url = 'http://www.salliemae.com/'
14
+
15
+ # The name of the gateway
16
+ self.display_name = 'Sallie Mae'
17
+
18
+ def initialize(options = {})
19
+ requires!(options, :login)
20
+ @options = options
21
+ super
22
+ end
23
+
24
+ def test?
25
+ @options[:login] == "TEST0"
26
+ end
27
+
28
+ def authorize(money, creditcard, options = {})
29
+ post = PostData.new
30
+ add_invoice(post, options)
31
+ add_creditcard(post, creditcard)
32
+ add_address(post, creditcard, options)
33
+ add_customer_data(post, options)
34
+
35
+ commit(:authonly, money, post)
36
+ end
37
+
38
+ def purchase(money, creditcard, options = {})
39
+ post = PostData.new
40
+ add_invoice(post, options)
41
+ add_creditcard(post, creditcard)
42
+ add_address(post, creditcard, options)
43
+ add_customer_data(post, options)
44
+
45
+ commit(:sale, money, post)
46
+ end
47
+
48
+ def capture(money, authorization, options = {})
49
+ post = PostData.new
50
+ post[:postonly] = authorization
51
+ commit(:capture, money, post)
52
+ end
53
+
54
+ private
55
+
56
+ def add_customer_data(post, options)
57
+ if address = options[:billing_address] || options[:shipping_address] || options[:address]
58
+ post[:ci_phone] = address[:phone].to_s
59
+ end
60
+
61
+ post[:ci_email] = options[:email].to_s unless options[:email].blank?
62
+ post[:ci_IP] = options[:ip].to_s unless options[:ip].blank?
63
+ end
64
+
65
+ def add_address(post, creditcard, options)
66
+ if address = options[:billing_address] || options[:address]
67
+ post[:ci_billaddr1] = address[:address1].to_s
68
+ post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank?
69
+ post[:ci_billcity] = address[:city].to_s
70
+ post[:ci_billstate] = address[:state].to_s
71
+ post[:ci_billzip] = address[:zip].to_s
72
+ end
73
+
74
+ if shipping_address = options[:shipping_address] || options[:address]
75
+ post[:ci_shipaddr1] = shipping_address[:address1].to_s
76
+ post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank?
77
+ post[:ci_shipcity] = shipping_address[:city].to_s
78
+ post[:ci_shipstate] = shipping_address[:state].to_s
79
+ post[:ci_shipzip] = shipping_address[:zip].to_s
80
+ end
81
+ end
82
+
83
+ def add_invoice(post, options)
84
+ memo = "OrderID: #{options[:order_id]}\nDescription: #{options[:description]}"
85
+ post[:ci_memo] = memo
86
+ end
87
+
88
+ def add_creditcard(post, creditcard)
89
+ post[:ccnum] = creditcard.number.to_s
90
+ post[:ccname] = creditcard.name.to_s
91
+ post[:cvv2] = creditcard.verification_value.to_s if creditcard.verification_value?
92
+ post[:expmon] = creditcard.month.to_s
93
+ post[:expyear] = creditcard.year.to_s
94
+ end
95
+
96
+ def parse(body)
97
+ h = {}
98
+ body.gsub!("<html><body><plaintext>", "")
99
+ body.
100
+ split("\r\n").
101
+ map do |i|
102
+ a = i.split("=")
103
+ h[a.first] = a.last unless a.first.nil?
104
+ end
105
+ h
106
+ end
107
+
108
+ def commit(action, money, parameters)
109
+ parameters[:acctid] = @options[:login].to_s
110
+ parameters[:subid] = @options[:sub_id].to_s unless @options[:sub_id].blank?
111
+ parameters[:amount] = amount(money)
112
+
113
+ case action
114
+ when :sale
115
+ parameters[:action] = "ns_quicksale_cc"
116
+ when :authonly
117
+ parameters[:action] = "ns_quicksale_cc"
118
+ parameters[:authonly] = 1
119
+ when :capture
120
+ parameters[:action] = "ns_quicksale_cc"
121
+ end
122
+
123
+ response = parse(ssl_post(URL, parameters.to_post_data) || "")
124
+ Response.new(successful?(response), message_from(response), response,
125
+ :test => test?,
126
+ :authorization => response["refcode"]
127
+ )
128
+ end
129
+
130
+ def successful?(response)
131
+ response["Status"] == "Accepted"
132
+ end
133
+
134
+ def message_from(response)
135
+ if successful?(response)
136
+ "Accepted"
137
+ else
138
+ response["Reason"].split(":")[2].capitalize unless response["Reason"].nil?
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+
@@ -23,7 +23,7 @@ module ActiveMerchant #:nodoc:
23
23
 
24
24
  private
25
25
  def split(response)
26
- response.split('%')
26
+ response.split(',')
27
27
  end
28
28
  end
29
29
  end
@@ -1,10 +1,17 @@
1
+ #!ruby19
2
+ # encoding: utf-8
3
+
1
4
  module ActiveMerchant #:nodoc:
2
5
  module Billing #:nodoc:
3
6
  class SkipJackGateway < Gateway
4
7
  API_VERSION = '?.?'
5
- LIVE_URL = "https://www.skipjackic.com/scripts/evolvcc.dll"
6
- TEST_URL = "https://developer.skipjackic.com/scripts/evolvcc.dll"
7
-
8
+
9
+ LIVE_HOST = "https://www.skipjackic.com"
10
+ TEST_HOST = "https://developer.skipjackic.com"
11
+
12
+ BASIC_PATH = "/scripts/evolvcc.dll"
13
+ ADVANCED_PATH = "/evolvcc/evolvcc.aspx"
14
+
8
15
  ACTIONS = {
9
16
  :authorization => 'AuthorizeAPI',
10
17
  :change_status => 'SJAPI_TransactionChangeStatusRequest',
@@ -127,9 +134,9 @@ module ActiveMerchant #:nodoc:
127
134
  '-88' => 'Point of Sale check account number missing or invalid Point of Sale check account number is invalid or empty.',
128
135
  '-89' => 'Point of Sale check MICR missing or invalid Point of Sale check MICR invalid or empty.',
129
136
  '-90' => 'Point of Sale check number missing or invalid Point of Sale check number invalid or empty.',
130
- '-91' => 'CVV2 Invalid or empty Make CVV a required field feature enabled (New feature 01 April 2006) in the Merchant Account Setup interface but no CVV code was sent in the transaction data.',
137
+ '-91' => 'CVV2 Invalid or empty "Make CVV a required field feature" enabled (New feature 01 April 2006) in the Merchant Account Setup interface but no CVV code was sent in the transaction data.',
131
138
  '-92' => 'Approval Code Invalid Approval Code Invalid. Approval Code is a 6 digit code.',
132
- '-93' => 'Blind Credits Request Refused Allow Blind Credits option must be enabled on the Skipjack Merchant Account.',
139
+ '-93' => 'Blind Credits Request Refused "Allow Blind Credits" option must be enabled on the Skipjack Merchant Account.',
133
140
  '-94' => 'Blind Credits Failed',
134
141
  '-95' => 'Voice Authorization Request Refused Voice Authorization option must be enabled on the Skipjack Merchant Account.',
135
142
  '-96' => 'Voice Authorizations Failed',
@@ -170,6 +177,8 @@ module ActiveMerchant #:nodoc:
170
177
  # * <tt>:login</tt> -- The SkipJack Merchant Serial Number.
171
178
  # * <tt>:password</tt> -- The SkipJack Developer Serial Number.
172
179
  # * <tt>:test => +true+ or +false+</tt> -- Use the test or live SkipJack url.
180
+ # * <tt>:advanced => +true+ or +false+</tt> -- Set to true if you're using an advanced processor
181
+ # See the SkipJack Integration Guide for details. (default: +false+)
173
182
  def initialize(options = {})
174
183
  requires!(options, :login, :password)
175
184
  @options = options
@@ -236,12 +245,15 @@ module ActiveMerchant #:nodoc:
236
245
  end
237
246
 
238
247
  def status(order_id)
239
- post = { }
240
- post[:szOrderNumber] = :order_id
241
- commit(:get_status, nil, post)
248
+ commit(:get_status, nil, :szOrderNumber => order_id)
242
249
  end
243
-
250
+
244
251
  private
252
+
253
+ def advanced?
254
+ @options[:advanced]
255
+ end
256
+
245
257
  def add_forced_settlement(post, options)
246
258
  post[:szForceSettlement] = options[:force_settlment] ? 1 : 0
247
259
  end
@@ -263,7 +275,8 @@ module ActiveMerchant #:nodoc:
263
275
  end
264
276
 
265
277
  def url_for(action)
266
- result = test? ? TEST_URL : LIVE_URL
278
+ result = test? ? TEST_HOST : LIVE_HOST
279
+ result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH
267
280
  result += "?#{ACTIONS[action]}"
268
281
  end
269
282