mattbauer-activemerchant 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. data/CHANGELOG +459 -0
  2. data/CONTRIBUTERS +118 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README +134 -0
  5. data/Rakefile +153 -0
  6. data/gem-public_cert.pem +20 -0
  7. data/init.rb +3 -0
  8. data/lib/active_merchant.rb +60 -0
  9. data/lib/active_merchant/billing/avs_result.rb +98 -0
  10. data/lib/active_merchant/billing/base.rb +57 -0
  11. data/lib/active_merchant/billing/check.rb +68 -0
  12. data/lib/active_merchant/billing/credit_card.rb +159 -0
  13. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  14. data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
  15. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  16. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  17. data/lib/active_merchant/billing/gateway.rb +158 -0
  18. data/lib/active_merchant/billing/gateways.rb +3 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net.rb +657 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +703 -0
  21. data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
  22. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
  23. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  24. data/lib/active_merchant/billing/gateways/bogus.rb +98 -0
  25. data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
  26. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  27. data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
  28. data/lib/active_merchant/billing/gateways/data_cash.rb +595 -0
  29. data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
  30. data/lib/active_merchant/billing/gateways/elavon.rb +106 -0
  31. data/lib/active_merchant/billing/gateways/eway.rb +277 -0
  32. data/lib/active_merchant/billing/gateways/exact.rb +222 -0
  33. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  34. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +396 -0
  36. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  37. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  38. data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
  39. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
  40. data/lib/active_merchant/billing/gateways/moneris.rb +295 -0
  41. data/lib/active_merchant/billing/gateways/moneris_usa.rb +258 -0
  42. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  43. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  44. data/lib/active_merchant/billing/gateways/ogone.rb +259 -0
  45. data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
  46. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  47. data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
  48. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
  49. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  50. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  51. data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
  52. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  53. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  54. data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
  55. data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
  56. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +325 -0
  57. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
  58. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  59. data/lib/active_merchant/billing/gateways/paypal_express.rb +130 -0
  60. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
  61. data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
  62. data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
  63. data/lib/active_merchant/billing/gateways/psl_card.rb +306 -0
  64. data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
  65. data/lib/active_merchant/billing/gateways/realex.rb +200 -0
  66. data/lib/active_merchant/billing/gateways/sage.rb +146 -0
  67. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  68. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
  69. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  70. data/lib/active_merchant/billing/gateways/sage_pay.rb +308 -0
  71. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  72. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
  73. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  74. data/lib/active_merchant/billing/gateways/skip_jack.rb +442 -0
  75. data/lib/active_merchant/billing/gateways/smart_ps.rb +254 -0
  76. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  77. data/lib/active_merchant/billing/gateways/transax.rb +26 -0
  78. data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
  79. data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
  80. data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
  81. data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
  82. data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
  83. data/lib/active_merchant/billing/integrations.rb +22 -0
  84. data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
  85. data/lib/active_merchant/billing/integrations/bogus.rb +22 -0
  86. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  87. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  88. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  89. data/lib/active_merchant/billing/integrations/chronopay.rb +22 -0
  90. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +81 -0
  91. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +156 -0
  92. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  93. data/lib/active_merchant/billing/integrations/gestpay.rb +26 -0
  94. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  95. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  96. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +83 -0
  97. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  98. data/lib/active_merchant/billing/integrations/helper.rb +93 -0
  99. data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
  100. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  101. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  102. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  103. data/lib/active_merchant/billing/integrations/nochex.rb +87 -0
  104. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  105. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  106. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  107. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  108. data/lib/active_merchant/billing/integrations/paypal.rb +40 -0
  109. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  110. data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
  111. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  112. data/lib/active_merchant/billing/integrations/quickpay.rb +18 -0
  113. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
  114. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  115. data/lib/active_merchant/billing/integrations/return.rb +35 -0
  116. data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
  117. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
  118. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
  119. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  120. data/lib/active_merchant/billing/response.rb +32 -0
  121. data/lib/active_merchant/lib/connection.rb +170 -0
  122. data/lib/active_merchant/lib/country.rb +319 -0
  123. data/lib/active_merchant/lib/error.rb +4 -0
  124. data/lib/active_merchant/lib/post_data.rb +22 -0
  125. data/lib/active_merchant/lib/posts_data.rb +47 -0
  126. data/lib/active_merchant/lib/requires_parameters.rb +16 -0
  127. data/lib/active_merchant/lib/utils.rb +18 -0
  128. data/lib/active_merchant/lib/validateable.rb +76 -0
  129. data/lib/certs/cacert.pem +7815 -0
  130. data/lib/support/gateway_support.rb +58 -0
  131. data/script/destroy +14 -0
  132. data/script/generate +14 -0
  133. data/test/fixtures.yml +353 -0
  134. data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
  135. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  136. data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
  137. data/test/remote/gateways/remote_beanstream_test.rb +150 -0
  138. data/test/remote/gateways/remote_braintree_test.rb +154 -0
  139. data/test/remote/gateways/remote_card_stream_test.rb +148 -0
  140. data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
  141. data/test/remote/gateways/remote_data_cash_test.rb +357 -0
  142. data/test/remote/gateways/remote_efsnet_test.rb +81 -0
  143. data/test/remote/gateways/remote_elavon_test.rb +66 -0
  144. data/test/remote/gateways/remote_eway_test.rb +74 -0
  145. data/test/remote/gateways/remote_exact_test.rb +60 -0
  146. data/test/remote/gateways/remote_first_pay_test.rb +87 -0
  147. data/test/remote/gateways/remote_instapay_test.rb +61 -0
  148. data/test/remote/gateways/remote_linkpoint_test.rb +112 -0
  149. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
  150. data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
  151. data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
  152. data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
  153. data/test/remote/gateways/remote_moneris_test.rb +118 -0
  154. data/test/remote/gateways/remote_moneris_usa_test.rb +115 -0
  155. data/test/remote/gateways/remote_net_registry_test.rb +85 -0
  156. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  157. data/test/remote/gateways/remote_ogone_test.rb +108 -0
  158. data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
  159. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  160. data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
  161. data/test/remote/gateways/remote_payflow_test.rb +237 -0
  162. data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
  163. data/test/remote/gateways/remote_payment_express_test.rb +136 -0
  164. data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
  165. data/test/remote/gateways/remote_paypal_test.rb +178 -0
  166. data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
  167. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  168. data/test/remote/gateways/remote_psl_card_test.rb +125 -0
  169. data/test/remote/gateways/remote_quickpay_test.rb +190 -0
  170. data/test/remote/gateways/remote_realex_test.rb +224 -0
  171. data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
  172. data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
  173. data/test/remote/gateways/remote_sage_test.rb +87 -0
  174. data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
  175. data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
  176. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  177. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  178. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  179. data/test/remote/gateways/remote_trans_first_test.rb +34 -0
  180. data/test/remote/gateways/remote_transax_test.rb +112 -0
  181. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  182. data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
  183. data/test/remote/gateways/remote_verifi_test.rb +107 -0
  184. data/test/remote/gateways/remote_viaklix_test.rb +43 -0
  185. data/test/remote/gateways/remote_wirecard_test.rb +111 -0
  186. data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
  187. data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
  188. data/test/test_helper.rb +182 -0
  189. data/test/unit/avs_result_test.rb +59 -0
  190. data/test/unit/base_test.rb +55 -0
  191. data/test/unit/check_test.rb +88 -0
  192. data/test/unit/connection_test.rb +129 -0
  193. data/test/unit/country_code_test.rb +33 -0
  194. data/test/unit/country_test.rb +64 -0
  195. data/test/unit/credit_card_formatting_test.rb +19 -0
  196. data/test/unit/credit_card_methods_test.rb +179 -0
  197. data/test/unit/credit_card_test.rb +318 -0
  198. data/test/unit/cvv_result_test.rb +33 -0
  199. data/test/unit/expiry_date_test.rb +32 -0
  200. data/test/unit/gateways/authorize_net_cim_test.rb +638 -0
  201. data/test/unit/gateways/authorize_net_test.rb +290 -0
  202. data/test/unit/gateways/beanstream_interac_test.rb +51 -0
  203. data/test/unit/gateways/beanstream_test.rb +108 -0
  204. data/test/unit/gateways/bogus_test.rb +46 -0
  205. data/test/unit/gateways/braintree_test.rb +126 -0
  206. data/test/unit/gateways/card_stream_test.rb +90 -0
  207. data/test/unit/gateways/cyber_source_test.rb +188 -0
  208. data/test/unit/gateways/data_cash_test.rb +133 -0
  209. data/test/unit/gateways/efsnet_test.rb +123 -0
  210. data/test/unit/gateways/elavon_test.rb +139 -0
  211. data/test/unit/gateways/eway_test.rb +118 -0
  212. data/test/unit/gateways/exact_test.rb +156 -0
  213. data/test/unit/gateways/first_pay_test.rb +125 -0
  214. data/test/unit/gateways/gateway_test.rb +48 -0
  215. data/test/unit/gateways/instapay_test.rb +102 -0
  216. data/test/unit/gateways/linkpoint_test.rb +167 -0
  217. data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
  218. data/test/unit/gateways/merchant_ware_test.rb +188 -0
  219. data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
  220. data/test/unit/gateways/moneris_test.rb +185 -0
  221. data/test/unit/gateways/moneris_usa_test.rb +183 -0
  222. data/test/unit/gateways/net_registry_test.rb +416 -0
  223. data/test/unit/gateways/netbilling_test.rb +54 -0
  224. data/test/unit/gateways/ogone_test.rb +256 -0
  225. data/test/unit/gateways/pay_junction_test.rb +123 -0
  226. data/test/unit/gateways/pay_secure_test.rb +71 -0
  227. data/test/unit/gateways/payflow_express_test.rb +173 -0
  228. data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
  229. data/test/unit/gateways/payflow_test.rb +305 -0
  230. data/test/unit/gateways/payflow_uk_test.rb +30 -0
  231. data/test/unit/gateways/payment_express_test.rb +195 -0
  232. data/test/unit/gateways/paypal_express_test.rb +382 -0
  233. data/test/unit/gateways/paypal_test.rb +569 -0
  234. data/test/unit/gateways/plugnpay_test.rb +86 -0
  235. data/test/unit/gateways/psigate_test.rb +169 -0
  236. data/test/unit/gateways/psl_card_test.rb +64 -0
  237. data/test/unit/gateways/quickpay_test.rb +112 -0
  238. data/test/unit/gateways/realex_test.rb +151 -0
  239. data/test/unit/gateways/sage_bankcard_test.rb +162 -0
  240. data/test/unit/gateways/sage_pay_test.rb +139 -0
  241. data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
  242. data/test/unit/gateways/secure_pay_au_test.rb +207 -0
  243. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  244. data/test/unit/gateways/secure_pay_test.rb +87 -0
  245. data/test/unit/gateways/skip_jack_test.rb +133 -0
  246. data/test/unit/gateways/trans_first_test.rb +112 -0
  247. data/test/unit/gateways/trust_commerce_test.rb +90 -0
  248. data/test/unit/gateways/usa_epay_test.rb +128 -0
  249. data/test/unit/gateways/verifi_test.rb +96 -0
  250. data/test/unit/gateways/viaklix_test.rb +78 -0
  251. data/test/unit/gateways/wirecard_test.rb +250 -0
  252. data/test/unit/generators/test_gateway_generator.rb +46 -0
  253. data/test/unit/generators/test_generator_helper.rb +20 -0
  254. data/test/unit/generators/test_integration_generator.rb +53 -0
  255. data/test/unit/integrations/action_view_helper_test.rb +50 -0
  256. data/test/unit/integrations/bogus_module_test.rb +20 -0
  257. data/test/unit/integrations/chronopay_module_test.rb +13 -0
  258. data/test/unit/integrations/gestpay_module_test.rb +14 -0
  259. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  260. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  261. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  262. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  263. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  264. data/test/unit/integrations/helpers/paypal_helper_test.rb +171 -0
  265. data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
  266. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  267. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  268. data/test/unit/integrations/nochex_module_test.rb +13 -0
  269. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  270. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  271. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
  272. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  273. data/test/unit/integrations/notifications/notification_test.rb +54 -0
  274. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  275. data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
  276. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  277. data/test/unit/integrations/paypal_module_test.rb +28 -0
  278. data/test/unit/integrations/quickpay_module_test.rb +9 -0
  279. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  280. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  281. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  282. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  283. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  284. data/test/unit/integrations/returns/return_test.rb +11 -0
  285. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  286. data/test/unit/integrations/two_checkout_module_test.rb +13 -0
  287. data/test/unit/post_data_test.rb +55 -0
  288. data/test/unit/posts_data_test.rb +48 -0
  289. data/test/unit/response_test.rb +28 -0
  290. data/test/unit/utils_test.rb +7 -0
  291. data/test/unit/validateable_test.rb +60 -0
  292. metadata +396 -0
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'lib/active_merchant'
4
+
5
+
6
+ class GatewaySupport #:nodoc:
7
+ ACTIONS = [:purchase, :authorize, :capture, :void, :credit, :recurring]
8
+
9
+ include ActiveMerchant::Billing
10
+
11
+ attr_reader :gateways
12
+
13
+ def initialize
14
+ @gateways = Gateway.implementations.sort_by(&:name)
15
+ @gateways.delete(ActiveMerchant::Billing::BogusGateway)
16
+ end
17
+
18
+ def each_gateway
19
+ @gateways.each{|g| yield g }
20
+ end
21
+
22
+ def features
23
+ width = 15
24
+
25
+ print "Name".center(width + 20)
26
+ ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" }
27
+ puts
28
+
29
+ each_gateway do |g|
30
+ print "#{g.display_name.ljust(width + 20)}"
31
+ ACTIONS.each do |f|
32
+ print "#{(g.instance_methods.include?(f.to_s) ? "Y" : "N").center(width)}"
33
+ end
34
+ puts
35
+ end
36
+ end
37
+
38
+ def to_rdoc
39
+ each_gateway do |g|
40
+ puts "* {#{g.display_name}}[#{g.homepage_url}] - #{g.supported_countries.join(', ')}"
41
+ end
42
+ end
43
+
44
+ def to_textile
45
+ each_gateway do |g|
46
+ puts %/ * "#{g.display_name}":#{g.homepage_url} [#{g.supported_countries.join(', ')}]/
47
+ end
48
+ end
49
+
50
+ def to_s
51
+ each_gateway do |g|
52
+ puts "#{g.display_name} - #{g.homepage_url} [#{g.supported_countries.join(', ')}]"
53
+ end
54
+ end
55
+ end
56
+
57
+
58
+
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:activemerchant, :rubygems, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:activemerchant, :rubygems, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/test/fixtures.yml ADDED
@@ -0,0 +1,353 @@
1
+ # This file has all of the ActiveMerchant test account credentials.
2
+ # Many gateways do not offer publicly available test accounts. In
3
+ # order to make testing the gateways easy you can copy this file to
4
+ # your home directory as the file ~/.active_merchant/fixtures.yml
5
+ # You can then place your own test account credentials in your local
6
+ # copy of the file.
7
+ #
8
+ # If the login is numeric, ensure that you place quotes around it.
9
+ # Leading zeros will be lost when YAML parses the file if you don't.
10
+ #
11
+ # Paste any required PEM certificates after the pem key.
12
+ #
13
+ authorize_net:
14
+ login: X
15
+ password: Y
16
+
17
+ beanstream:
18
+ login: merchant id
19
+ user: username
20
+ password: password
21
+
22
+ beanstream_interac:
23
+ login: merchant id
24
+ user: username
25
+ password: password
26
+
27
+ braintree:
28
+ login: demo
29
+ password: password
30
+
31
+ card_stream:
32
+ login: X
33
+ password: Y
34
+
35
+ cyber_source:
36
+ login: X
37
+ password: Y
38
+
39
+ data_cash:
40
+ login: X
41
+ password: Y
42
+
43
+ efsnet:
44
+ login: X
45
+ password: Y
46
+
47
+ elavon:
48
+ login: LOGIN
49
+ password: PASSWORD
50
+
51
+ # Working credentials, no need to replace
52
+ eway:
53
+ login: '87654321'
54
+
55
+ # Working credentials, no need to replace
56
+ exact:
57
+ login: "A00427-01"
58
+ password: testus
59
+
60
+ first_pay:
61
+ login:
62
+ password:
63
+
64
+ ideal_ing_postbank:
65
+ login: LOGIN
66
+ password: PASSWORD
67
+ pem: |--
68
+ PASTE YOUR PEM FILE HERE
69
+
70
+ instapay:
71
+ login: TEST0
72
+ password:
73
+
74
+ linkpoint:
75
+ login: STOREID
76
+ pem: |--
77
+ PASTE YOUR PEM FILE HERE
78
+
79
+ merchant_ware:
80
+ login:
81
+ password:
82
+ name:
83
+
84
+ modern_payments:
85
+ login: login
86
+ password: password
87
+
88
+ # Working credentials, no need to replace
89
+ moneris:
90
+ login: store1
91
+ password: yesguy
92
+
93
+ moneris_usa:
94
+ login: monusqa002
95
+ password: qatoken
96
+
97
+ # Working credentials, no need to replace
98
+ # Contact Netbilling for login info to the admin area
99
+ netbilling:
100
+ login: '104901072025'
101
+
102
+ net_registry:
103
+ login: X
104
+ password: Y
105
+
106
+ ogone:
107
+ login: LOGIN
108
+ user: USER
109
+ password: PASSWORD
110
+ signature: SIGNATURE
111
+
112
+ payflow:
113
+ login: LOGIN
114
+ password: PASSWORD
115
+ partner: PayPal
116
+
117
+ payflow_uk:
118
+ login: LOGIN
119
+ password: PASSWORD
120
+ partner: PayPalUk
121
+
122
+ # Working credentials, no need to replace
123
+ pay_junction:
124
+ login: 'pj-ql-01'
125
+ password: 'pj-ql-01p'
126
+
127
+ payment_express:
128
+ login: LOGIN
129
+ password: PASSWORD
130
+
131
+ # You can use either your API PEM file or API signature with PayPal.
132
+ paypal_certificate:
133
+ login: LOGIN
134
+ password: PASSWORD
135
+ subject:
136
+ pem: |--
137
+ PASTE YOUR PEM FILE HERE
138
+
139
+ paypal_signature:
140
+ login: LOGIN
141
+ password: PASSWORD
142
+ signature: SIGNATURE
143
+
144
+ pay_secure:
145
+ login: LOGIN
146
+ password: PASSWORD
147
+
148
+ plugnpay:
149
+ login: LOGIN
150
+ password: PASSWORD
151
+
152
+ sage_pay:
153
+ login: LOGIN
154
+
155
+ # Working credentials, no need to replace
156
+ psigate:
157
+ login: teststore
158
+ password: psigate1234
159
+
160
+ psl_card:
161
+ login: LOGIN
162
+
163
+ # PSL doesn't want the test data made public
164
+ psl_maestro:
165
+ number:
166
+ month:
167
+ year:
168
+ verification_value:
169
+ issue_number:
170
+
171
+ psl_maestro_address:
172
+ address1:
173
+ address2:
174
+ city:
175
+ state:
176
+ zip:
177
+
178
+ psl_solo:
179
+ number:
180
+ month:
181
+ year:
182
+ verification_value:
183
+ issue_number:
184
+
185
+ psl_solo_address:
186
+ address1:
187
+ city:
188
+ state:
189
+ zip:
190
+
191
+ psl_visa:
192
+ number:
193
+ month:
194
+ year:
195
+ verification_value:
196
+
197
+ psl_visa_address:
198
+ address1:
199
+ address2:
200
+ address3:
201
+ city:
202
+ zip:
203
+
204
+ psl_visa_debit:
205
+ first_name:
206
+ last_name:
207
+ number:
208
+ month:
209
+ year:
210
+ verification_value:
211
+
212
+ psl_visa_debit_address:
213
+ address1:
214
+ address2:
215
+ address3:
216
+ city:
217
+ state:
218
+ zip:
219
+
220
+ quickpay:
221
+ login: 89898989
222
+ password: "n5KrR5e2538awi9hUk6728LHTQ6E4uG1z4IFSb2pPN9j76DqJ2vA4698X315M1cd"
223
+
224
+ realex:
225
+ login: X
226
+ password: Y
227
+
228
+ realex_with_account:
229
+ login: X
230
+ password: Y
231
+ account: testaccount
232
+
233
+ # Realex doesn't provide public testing data
234
+ # Fill in the card numbers with the Realex test
235
+ # data.
236
+ realex_visa:
237
+ number:
238
+ month: '6'
239
+ year: '2020'
240
+ verification_value: '123'
241
+
242
+ realex_visa_declined:
243
+ number:
244
+ month: '6'
245
+ year: '2020'
246
+ verification_value: '123'
247
+
248
+ realex_visa_referral_a:
249
+ number:
250
+ month: '6'
251
+ year: '2020'
252
+ verification_value: '123'
253
+
254
+ realex_visa_referral_b:
255
+ number:
256
+ month: '6'
257
+ year: '2020'
258
+ verification_value: '123'
259
+
260
+ realex_visa_coms_error:
261
+ number:
262
+ month: '6'
263
+ year: '2020'
264
+ verification_value: '123'
265
+
266
+ realex_mastercard:
267
+ number:
268
+ month: '6'
269
+ year: '2020'
270
+ verification_value: '123'
271
+
272
+ realex_mastercard_declined:
273
+ number:
274
+ month: '6'
275
+ year: '2020'
276
+ verification_value: '123'
277
+
278
+ realex_mastercard_referral_a:
279
+ number:
280
+ month: '6'
281
+ year: '2020'
282
+ verification_value: '123'
283
+
284
+ realex_mastercard_referral_b:
285
+ number:
286
+ month: '6'
287
+ year: '2020'
288
+ verification_value: '123'
289
+
290
+ realex_mastercard_coms_error:
291
+ number:
292
+ month: '6'
293
+ year: '2020'
294
+ verification_value: '123'
295
+
296
+ sage:
297
+ login: login
298
+ password: password
299
+
300
+ secure_pay:
301
+ login: LOGIN
302
+ password: PASSWORD
303
+
304
+ secure_pay_tech:
305
+ login: TESTDIGISPL1
306
+ password: d557591484cb2cd12bba445aba420d2c69cd6a88
307
+
308
+ secure_pay_au:
309
+ login:
310
+ password:
311
+
312
+ # Replace with your serial numbers for the skipjack test environment
313
+ skipjack:
314
+ login: X
315
+ password: Y
316
+
317
+ trans_first:
318
+ login: LOGIN
319
+ password: PASSWORD
320
+
321
+ transax:
322
+ login: demo
323
+ password: password
324
+
325
+ # Working credentials, no need to replace
326
+ trust_commerce:
327
+ login: 'TestMerchant'
328
+ password: 'password'
329
+
330
+ # Working credentials, no need to replace
331
+ usa_epay:
332
+ login: 'yCaWGYQsSVR0S48B6AKMK07RQhaxHvGu'
333
+
334
+ # Working credentials, no need to replace
335
+ verify:
336
+ login: 'demo'
337
+ password: 'password'
338
+
339
+ viaklix:
340
+ login: LOGIN
341
+ password: PASSWORD
342
+ user: USER
343
+
344
+ # Working test credentials, no need to replace
345
+ wirecard:
346
+ login: 56500
347
+ password: TestXAPTER
348
+
349
+ # replace with your Merchant eSolutions developer profile credentials
350
+ merchant_esolutions:
351
+ login: "profile_id"
352
+ password: "profile_key"
353
+
@@ -0,0 +1,459 @@
1
+ require 'test_helper'
2
+ require 'pp'
3
+
4
+ class AuthorizeNetCimTest < Test::Unit::TestCase
5
+ def setup
6
+ Base.mode = :test
7
+
8
+ @gateway = AuthorizeNetCimGateway.new(fixtures(:authorize_net))
9
+ @amount = 100
10
+ @credit_card = credit_card('4242424242424242')
11
+ @payment = {
12
+ :credit_card => @credit_card
13
+ }
14
+ @profile = {
15
+ :merchant_customer_id => 'Up to 20 chars', # Optional
16
+ :description => 'Up to 255 Characters', # Optional
17
+ :email => 'Up to 255 Characters', # Optional
18
+ :payment_profiles => { # Optional
19
+ :customer_type => 'individual', # Optional
20
+ :bill_to => @address,
21
+ :payment => @payment
22
+ },
23
+ :ship_to_list => {
24
+ :first_name => 'John',
25
+ :last_name => 'Doe',
26
+ :company => 'Widgets, Inc',
27
+ :address1 => '1234 Fake Street',
28
+ :city => 'Anytown',
29
+ :state => 'MD',
30
+ :zip => '12345',
31
+ :country => 'USA',
32
+ :phone_number => '(123)123-1234', # Optional - Up to 25 digits (no letters)
33
+ :fax_number => '(123)123-1234' # Optional - Up to 25 digits (no letters)
34
+ }
35
+ }
36
+ @options = {
37
+ :ref_id => '1234', # Optional
38
+ :profile => @profile
39
+ }
40
+ end
41
+
42
+ def teardown
43
+ if @customer_profile_id
44
+ assert response = @gateway.delete_customer_profile(:customer_profile_id => @customer_profile_id)
45
+ assert_success response
46
+ @customer_profile_id = nil
47
+ end
48
+ end
49
+
50
+ def test_successful_profile_create_get_update_and_delete
51
+ assert response = @gateway.create_customer_profile(@options)
52
+ @customer_profile_id = response.authorization
53
+
54
+ assert_success response
55
+ assert response.test?
56
+
57
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
58
+ assert response.test?
59
+ assert_success response
60
+ assert_equal @customer_profile_id, response.authorization
61
+ assert_equal 'Successful.', response.message
62
+ assert response.params['profile']['payment_profiles']['customer_payment_profile_id'] =~ /\d+/, 'The customer_payment_profile_id should be a number'
63
+ assert_equal "XXXX#{@credit_card.last_digits}", response.params['profile']['payment_profiles']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in #{@credit_card.last_digits}"
64
+ assert_equal @profile[:merchant_customer_id], response.params['profile']['merchant_customer_id']
65
+ assert_equal @profile[:description], response.params['profile']['description']
66
+ assert_equal @profile[:email], response.params['profile']['email']
67
+ assert_equal @profile[:payment_profiles][:customer_type], response.params['profile']['payment_profiles']['customer_type']
68
+ assert_equal @profile[:ship_to_list][:phone_number], response.params['profile']['ship_to_list']['phone_number']
69
+ assert_equal @profile[:ship_to_list][:company], response.params['profile']['ship_to_list']['company']
70
+
71
+ assert response = @gateway.update_customer_profile(:profile => {:customer_profile_id => @customer_profile_id, :email => 'new email address'})
72
+ assert response.test?
73
+ assert_success response
74
+ assert_nil response.authorization
75
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
76
+ assert_nil response.params['profile']['merchant_customer_id']
77
+ assert_nil response.params['profile']['description']
78
+ assert_equal 'new email address', response.params['profile']['email']
79
+ end
80
+
81
+ def test_successful_create_customer_profile_transaction_auth_only_and_then_capture_only_requests
82
+ assert response = @gateway.create_customer_profile(@options)
83
+ @customer_profile_id = response.authorization
84
+
85
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
86
+ @customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
87
+
88
+ assert response = @gateway.create_customer_profile_transaction(
89
+ :transaction => {
90
+ :customer_profile_id => @customer_profile_id,
91
+ :customer_payment_profile_id => @customer_payment_profile_id,
92
+ :type => :auth_only,
93
+ :amount => @amount
94
+ }
95
+ )
96
+
97
+ assert response.test?
98
+ assert_success response
99
+ assert_nil response.authorization
100
+ assert_equal "This transaction has been approved.", response.params['direct_response']['message']
101
+ assert response.params['direct_response']['approval_code'] =~ /\w{6}/
102
+ assert_equal "auth_only", response.params['direct_response']['transaction_type']
103
+ assert_equal "100.00", response.params['direct_response']['amount']
104
+
105
+ approval_code = response.params['direct_response']['approval_code']
106
+
107
+ # Capture the previously authorized funds
108
+
109
+ assert response = @gateway.create_customer_profile_transaction(
110
+ :transaction => {
111
+ :customer_profile_id => @customer_profile_id,
112
+ :customer_payment_profile_id => @customer_payment_profile_id,
113
+ :type => :capture_only,
114
+ :amount => @amount,
115
+ :approval_code => approval_code
116
+ }
117
+ )
118
+
119
+ assert response.test?
120
+ assert_success response
121
+ assert_nil response.authorization
122
+ assert_equal "This transaction has been approved.", response.params['direct_response']['message']
123
+ assert_equal approval_code, response.params['direct_response']['approval_code']
124
+ assert_equal "capture_only", response.params['direct_response']['transaction_type']
125
+ assert_equal "100.00", response.params['direct_response']['amount']
126
+ end
127
+
128
+ def test_successful_create_customer_profile_transaction_auth_capture_request
129
+ assert response = @gateway.create_customer_profile(@options)
130
+ @customer_profile_id = response.authorization
131
+
132
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
133
+ @customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
134
+
135
+ assert response = @gateway.create_customer_profile_transaction(
136
+ :transaction => {
137
+ :customer_profile_id => @customer_profile_id,
138
+ :customer_payment_profile_id => @customer_payment_profile_id,
139
+ :type => :auth_capture,
140
+ :order => {
141
+ :invoice_number => '1234',
142
+ :description => 'Test Order Description',
143
+ :purchase_order_number => '4321'
144
+ },
145
+ :amount => @amount
146
+ }
147
+ )
148
+
149
+ assert response.test?
150
+ assert_success response
151
+ assert_nil response.authorization
152
+ assert_equal "This transaction has been approved.", response.params['direct_response']['message']
153
+ assert response.params['direct_response']['approval_code'] =~ /\w{6}/
154
+ assert_equal "auth_capture", response.params['direct_response']['transaction_type']
155
+ assert_equal "100.00", response.params['direct_response']['amount']
156
+ assert_equal response.params['direct_response']['invoice_number'], '1234'
157
+ assert_equal response.params['direct_response']['order_description'], 'Test Order Description'
158
+ assert_equal response.params['direct_response']['purchase_order_number'], '4321'
159
+ end
160
+
161
+ def test_successful_create_customer_payment_profile_request
162
+ payment_profile = @options[:profile].delete(:payment_profiles)
163
+ assert response = @gateway.create_customer_profile(@options)
164
+ @customer_profile_id = response.authorization
165
+
166
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
167
+ assert_nil response.params['profile']['payment_profiles']
168
+
169
+ assert response = @gateway.create_customer_payment_profile(
170
+ :customer_profile_id => @customer_profile_id,
171
+ :payment_profile => payment_profile
172
+ )
173
+
174
+ assert response.test?
175
+ assert_success response
176
+ assert_nil response.authorization
177
+ assert customer_payment_profile_id = response.params['customer_payment_profile_id']
178
+ assert customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{customer_payment_profile_id}"
179
+ end
180
+
181
+ def test_successful_create_customer_payment_profile_request_with_bank_account
182
+ payment_profile = @options[:profile].delete(:payment_profiles)
183
+ assert response = @gateway.create_customer_profile(@options)
184
+ @customer_profile_id = response.authorization
185
+
186
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
187
+ assert_nil response.params['profile']['payment_profiles']
188
+
189
+ assert response = @gateway.create_customer_payment_profile(
190
+ :customer_profile_id => @customer_profile_id,
191
+ :payment_profile => {
192
+ :customer_type => 'individual', # Optional
193
+ :bill_to => @address,
194
+ :payment => {
195
+ :bank_account => {
196
+ :account_type => :checking,
197
+ :name_on_account => 'John Doe',
198
+ :echeck_type => :ccd,
199
+ :bank_name => 'Bank of America',
200
+ :routing_number => '123456789',
201
+ :account_number => '12345'
202
+ }
203
+ },
204
+ :drivers_license => {
205
+ :state => 'MD',
206
+ :number => '12345',
207
+ :date_of_birth => '1981-3-31'
208
+ },
209
+ :tax_id => '123456789'
210
+ }
211
+ )
212
+
213
+ assert response.test?
214
+ assert_success response
215
+ assert_nil response.authorization
216
+ assert customer_payment_profile_id = response.params['customer_payment_profile_id']
217
+ assert customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{customer_payment_profile_id}"
218
+ end
219
+
220
+ def test_successful_create_customer_shipping_address_request
221
+ shipping_address = @options[:profile].delete(:ship_to_list)
222
+ assert response = @gateway.create_customer_profile(@options)
223
+ @customer_profile_id = response.authorization
224
+
225
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
226
+ assert_nil response.params['profile']['ship_to_list']
227
+
228
+ assert response = @gateway.create_customer_shipping_address(
229
+ :customer_profile_id => @customer_profile_id,
230
+ :address => shipping_address
231
+ )
232
+
233
+ assert response.test?
234
+ assert_success response
235
+ assert_nil response.authorization
236
+ assert customer_address_id = response.params['customer_address_id']
237
+ assert customer_address_id =~ /\d+/, "The customerAddressId should be numeric. It was #{customer_address_id}"
238
+ end
239
+
240
+ def test_successful_get_customer_profile_with_multiple_payment_profiles
241
+ second_payment_profile = {
242
+ :customer_type => 'individual',
243
+ :bill_to => @address,
244
+ :payment => {
245
+ :credit_card => credit_card('1234123412341234')
246
+ }
247
+ }
248
+ assert response = @gateway.create_customer_profile(@options)
249
+ @customer_profile_id = response.authorization
250
+
251
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
252
+
253
+ assert response = @gateway.create_customer_payment_profile(
254
+ :customer_profile_id => @customer_profile_id,
255
+ :payment_profile => second_payment_profile
256
+ )
257
+
258
+ assert response.test?
259
+ assert_success response
260
+ assert_nil response.authorization
261
+ assert customer_payment_profile_id = response.params['customer_payment_profile_id']
262
+ assert customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{customer_payment_profile_id}"
263
+
264
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
265
+ assert_equal 2, response.params['profile']['payment_profiles'].size
266
+ assert_equal 'XXXX4242', response.params['profile']['payment_profiles'][0]['payment']['credit_card']['card_number']
267
+ assert_equal 'XXXX1234', response.params['profile']['payment_profiles'][1]['payment']['credit_card']['card_number']
268
+ end
269
+
270
+ def test_successful_delete_customer_payment_profile_request
271
+ assert response = @gateway.create_customer_profile(@options)
272
+ @customer_profile_id = response.authorization
273
+
274
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
275
+ assert customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
276
+
277
+ assert response = @gateway.delete_customer_payment_profile(
278
+ :customer_profile_id => @customer_profile_id,
279
+ :customer_payment_profile_id => customer_payment_profile_id
280
+ )
281
+
282
+ assert response.test?
283
+ assert_success response
284
+ assert_nil response.authorization
285
+
286
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
287
+ assert_nil response.params['profile']['payment_profiles']
288
+ end
289
+
290
+ def test_successful_delete_customer_shipping_address_request
291
+ assert response = @gateway.create_customer_profile(@options)
292
+ @customer_profile_id = response.authorization
293
+
294
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
295
+ assert customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
296
+
297
+ assert response = @gateway.delete_customer_shipping_address(
298
+ :customer_profile_id => @customer_profile_id,
299
+ :customer_address_id => customer_address_id
300
+ )
301
+
302
+ assert response.test?
303
+ assert_success response
304
+ assert_nil response.authorization
305
+
306
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
307
+ assert_nil response.params['profile']['ship_to_list']
308
+ end
309
+
310
+ def test_successful_get_customer_payment_profile_request
311
+ assert response = @gateway.create_customer_profile(@options)
312
+ @customer_profile_id = response.authorization
313
+
314
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
315
+ assert customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
316
+
317
+ assert response = @gateway.get_customer_payment_profile(
318
+ :customer_profile_id => @customer_profile_id,
319
+ :customer_payment_profile_id => customer_payment_profile_id
320
+ )
321
+
322
+ assert response.test?
323
+ assert_success response
324
+ assert_nil response.authorization
325
+ assert response.params['payment_profile']['customer_payment_profile_id'] =~ /\d+/, 'The customer_payment_profile_id should be a number'
326
+ assert_equal "XXXX#{@credit_card.last_digits}", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in #{@credit_card.last_digits}"
327
+ assert_equal @profile[:payment_profiles][:customer_type], response.params['payment_profile']['customer_type']
328
+ end
329
+
330
+ def test_successful_get_customer_shipping_address_request
331
+ assert response = @gateway.create_customer_profile(@options)
332
+ @customer_profile_id = response.authorization
333
+
334
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
335
+ assert customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
336
+
337
+ assert response = @gateway.get_customer_shipping_address(
338
+ :customer_profile_id => @customer_profile_id,
339
+ :customer_address_id => customer_address_id
340
+ )
341
+
342
+ assert response.test?
343
+ assert_success response
344
+ assert_nil response.authorization
345
+ assert response.params['address']['customer_address_id'] =~ /\d+/, 'The customer_address_id should be a number'
346
+ assert_equal @profile[:ship_to_list][:city], response.params['address']['city']
347
+ end
348
+
349
+ def test_successful_update_customer_payment_profile_request
350
+ # Create a new Customer Profile with Payment Profile
351
+ assert response = @gateway.create_customer_profile(@options)
352
+ @customer_profile_id = response.authorization
353
+
354
+ # Get the customerPaymentProfileId
355
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
356
+ assert customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
357
+
358
+ # Get the customerPaymentProfile
359
+ assert response = @gateway.get_customer_payment_profile(
360
+ :customer_profile_id => @customer_profile_id,
361
+ :customer_payment_profile_id => customer_payment_profile_id
362
+ )
363
+
364
+ # The value before updating
365
+ assert_equal "XXXX4242", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in 4242"
366
+
367
+ #Update the payment profile
368
+ assert response = @gateway.update_customer_payment_profile(
369
+ :customer_profile_id => @customer_profile_id,
370
+ :payment_profile => {
371
+ :customer_payment_profile_id => customer_payment_profile_id,
372
+ :payment => {
373
+ :credit_card => credit_card('1234123412341234')
374
+ }
375
+ }
376
+ )
377
+ assert response.test?
378
+ assert_success response
379
+ assert_nil response.authorization
380
+
381
+ # Get the updated payment profile
382
+ assert response = @gateway.get_customer_payment_profile(
383
+ :customer_profile_id => @customer_profile_id,
384
+ :customer_payment_profile_id => customer_payment_profile_id
385
+ )
386
+
387
+ # Show that the payment profile was updated
388
+ assert_equal "XXXX1234", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in: 1234"
389
+ # Show that fields that were left out of the update were cleared
390
+ assert_nil response.params['payment_profile']['customer_type']
391
+ end
392
+
393
+ def test_successful_update_customer_shipping_address_request
394
+ # Create a new Customer Profile with Shipping Address
395
+ assert response = @gateway.create_customer_profile(@options)
396
+ @customer_profile_id = response.authorization
397
+
398
+ # Get the customerAddressId
399
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
400
+ assert customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
401
+
402
+ # Get the customerShippingAddress
403
+ assert response = @gateway.get_customer_shipping_address(
404
+ :customer_profile_id => @customer_profile_id,
405
+ :customer_address_id => customer_address_id
406
+ )
407
+
408
+ assert address = response.params['address']
409
+ # The value before updating
410
+ assert_equal "1234 Fake Street", address['address']
411
+
412
+ # Update the address and remove the phone_number
413
+ new_address = address.symbolize_keys.merge!(
414
+ :address => '5678 Fake Street'
415
+ )
416
+ new_address.delete(:phone_number)
417
+
418
+ #Update the shipping address
419
+ assert response = @gateway.update_customer_shipping_address(
420
+ :customer_profile_id => @customer_profile_id,
421
+ :address => new_address
422
+ )
423
+ assert response.test?
424
+ assert_success response
425
+ assert_nil response.authorization
426
+
427
+ # Get the updated shipping address
428
+ assert response = @gateway.get_customer_shipping_address(
429
+ :customer_profile_id => @customer_profile_id,
430
+ :customer_address_id => customer_address_id
431
+ )
432
+
433
+ # Show that the shipping address was updated
434
+ assert_equal "5678 Fake Street", response.params['address']['address']
435
+ # Show that fields that were left out of the update were cleared
436
+ assert_nil response.params['address']['phone_number']
437
+ end
438
+
439
+ def test_successful_validate_customer_payment_profile_request
440
+ assert response = @gateway.create_customer_profile(@options)
441
+ @customer_profile_id = response.authorization
442
+
443
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
444
+ assert @customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
445
+ assert @customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
446
+
447
+ assert response = @gateway.validate_customer_payment_profile(
448
+ :customer_profile_id => @customer_profile_id,
449
+ :customer_payment_profile_id => @customer_payment_profile_id,
450
+ :customer_address_id => @customer_address_id,
451
+ :validation_mode => :live
452
+ )
453
+
454
+ assert response.test?
455
+ assert_success response
456
+ assert_nil response.authorization
457
+ assert_equal "This transaction has been approved.", response.params['direct_response']['message']
458
+ end
459
+ end