tomriley-active_merchant 1.4.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. data/CHANGELOG +442 -0
  2. data/CONTRIBUTERS +102 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README +134 -0
  5. data/Rakefile +153 -0
  6. data/active_merchant.gemspec +15 -0
  7. data/gem-public_cert.pem +20 -0
  8. data/init.rb +4 -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 +28 -0
  17. data/lib/active_merchant/billing/gateway.rb +158 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +646 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +702 -0
  20. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
  21. data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
  22. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  23. data/lib/active_merchant/billing/gateways/bogus.rb +98 -0
  24. data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
  25. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  26. data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
  27. data/lib/active_merchant/billing/gateways/data_cash.rb +595 -0
  28. data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
  29. data/lib/active_merchant/billing/gateways/eway.rb +272 -0
  30. data/lib/active_merchant/billing/gateways/exact.rb +222 -0
  31. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  32. data/lib/active_merchant/billing/gateways/linkpoint.rb +396 -0
  33. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  34. data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
  35. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
  36. data/lib/active_merchant/billing/gateways/moneris.rb +205 -0
  37. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  38. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  39. data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
  40. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  41. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
  42. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  43. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  44. data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
  45. data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
  46. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  47. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  48. data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
  49. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +325 -0
  50. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
  51. data/lib/active_merchant/billing/gateways/paypal.rb +108 -0
  52. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  53. data/lib/active_merchant/billing/gateways/paypal_express.rb +130 -0
  54. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
  55. data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
  56. data/lib/active_merchant/billing/gateways/protx.rb +349 -0
  57. data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
  58. data/lib/active_merchant/billing/gateways/psl_card.rb +306 -0
  59. data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
  60. data/lib/active_merchant/billing/gateways/realex.rb +200 -0
  61. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  62. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
  63. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  64. data/lib/active_merchant/billing/gateways/sage.rb +146 -0
  65. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  66. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
  67. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  68. data/lib/active_merchant/billing/gateways/skip_jack.rb +442 -0
  69. data/lib/active_merchant/billing/gateways/smart_ps.rb +254 -0
  70. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  71. data/lib/active_merchant/billing/gateways/transax.rb +26 -0
  72. data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
  73. data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
  74. data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
  75. data/lib/active_merchant/billing/gateways/viaklix.rb +165 -0
  76. data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
  77. data/lib/active_merchant/billing/gateways.rb +3 -0
  78. data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
  79. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  80. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  81. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  82. data/lib/active_merchant/billing/integrations/bogus.rb +22 -0
  83. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +81 -0
  84. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +156 -0
  85. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  86. data/lib/active_merchant/billing/integrations/chronopay.rb +22 -0
  87. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  88. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  89. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +83 -0
  90. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  91. data/lib/active_merchant/billing/integrations/gestpay.rb +26 -0
  92. data/lib/active_merchant/billing/integrations/helper.rb +93 -0
  93. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  94. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  95. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  96. data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
  97. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  98. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  99. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  100. data/lib/active_merchant/billing/integrations/nochex.rb +87 -0
  101. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  102. data/lib/active_merchant/billing/integrations/paypal/helper.rb +118 -0
  103. data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
  104. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  105. data/lib/active_merchant/billing/integrations/paypal.rb +40 -0
  106. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
  107. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  108. data/lib/active_merchant/billing/integrations/quickpay.rb +18 -0
  109. data/lib/active_merchant/billing/integrations/return.rb +35 -0
  110. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
  111. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
  112. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  113. data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
  114. data/lib/active_merchant/billing/integrations.rb +22 -0
  115. data/lib/active_merchant/billing/response.rb +32 -0
  116. data/lib/active_merchant/lib/connection.rb +170 -0
  117. data/lib/active_merchant/lib/country.rb +319 -0
  118. data/lib/active_merchant/lib/error.rb +4 -0
  119. data/lib/active_merchant/lib/post_data.rb +22 -0
  120. data/lib/active_merchant/lib/posts_data.rb +47 -0
  121. data/lib/active_merchant/lib/requires_parameters.rb +16 -0
  122. data/lib/active_merchant/lib/utils.rb +18 -0
  123. data/lib/active_merchant/lib/validateable.rb +76 -0
  124. data/lib/active_merchant.rb +60 -0
  125. data/lib/certs/cacert.pem +7815 -0
  126. data/lib/support/gateway_support.rb +58 -0
  127. data/script/destroy +14 -0
  128. data/script/generate +14 -0
  129. data/test/fixtures.yml +330 -0
  130. data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
  131. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  132. data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
  133. data/test/remote/gateways/remote_beanstream_test.rb +150 -0
  134. data/test/remote/gateways/remote_braintree_test.rb +154 -0
  135. data/test/remote/gateways/remote_card_stream_test.rb +148 -0
  136. data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
  137. data/test/remote/gateways/remote_data_cash_test.rb +357 -0
  138. data/test/remote/gateways/remote_efsnet_test.rb +81 -0
  139. data/test/remote/gateways/remote_eway_test.rb +74 -0
  140. data/test/remote/gateways/remote_exact_test.rb +60 -0
  141. data/test/remote/gateways/remote_instapay_test.rb +61 -0
  142. data/test/remote/gateways/remote_linkpoint_test.rb +112 -0
  143. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
  144. data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
  145. data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
  146. data/test/remote/gateways/remote_moneris_test.rb +82 -0
  147. data/test/remote/gateways/remote_net_registry_test.rb +85 -0
  148. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  149. data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
  150. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  151. data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
  152. data/test/remote/gateways/remote_payflow_test.rb +237 -0
  153. data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
  154. data/test/remote/gateways/remote_payment_express_test.rb +136 -0
  155. data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
  156. data/test/remote/gateways/remote_paypal_test.rb +167 -0
  157. data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
  158. data/test/remote/gateways/remote_protx_test.rb +219 -0
  159. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  160. data/test/remote/gateways/remote_psl_card_test.rb +125 -0
  161. data/test/remote/gateways/remote_quickpay_test.rb +190 -0
  162. data/test/remote/gateways/remote_realex_test.rb +224 -0
  163. data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
  164. data/test/remote/gateways/remote_sage_test.rb +87 -0
  165. data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
  166. data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
  167. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  168. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  169. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  170. data/test/remote/gateways/remote_trans_first_test.rb +34 -0
  171. data/test/remote/gateways/remote_transax_test.rb +112 -0
  172. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  173. data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
  174. data/test/remote/gateways/remote_verifi_test.rb +107 -0
  175. data/test/remote/gateways/remote_viaklix_test.rb +43 -0
  176. data/test/remote/gateways/remote_wirecard_test.rb +111 -0
  177. data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
  178. data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
  179. data/test/test_helper.rb +182 -0
  180. data/test/unit/avs_result_test.rb +59 -0
  181. data/test/unit/base_test.rb +55 -0
  182. data/test/unit/check_test.rb +88 -0
  183. data/test/unit/connection_test.rb +129 -0
  184. data/test/unit/country_code_test.rb +33 -0
  185. data/test/unit/country_test.rb +64 -0
  186. data/test/unit/credit_card_formatting_test.rb +19 -0
  187. data/test/unit/credit_card_methods_test.rb +170 -0
  188. data/test/unit/credit_card_test.rb +318 -0
  189. data/test/unit/cvv_result_test.rb +33 -0
  190. data/test/unit/expiry_date_test.rb +21 -0
  191. data/test/unit/gateways/authorize_net_cim_test.rb +638 -0
  192. data/test/unit/gateways/authorize_net_test.rb +290 -0
  193. data/test/unit/gateways/beanstream_interac_test.rb +51 -0
  194. data/test/unit/gateways/beanstream_test.rb +108 -0
  195. data/test/unit/gateways/bogus_test.rb +46 -0
  196. data/test/unit/gateways/braintree_test.rb +126 -0
  197. data/test/unit/gateways/card_stream_test.rb +90 -0
  198. data/test/unit/gateways/cyber_source_test.rb +188 -0
  199. data/test/unit/gateways/data_cash_test.rb +133 -0
  200. data/test/unit/gateways/efsnet_test.rb +123 -0
  201. data/test/unit/gateways/eway_test.rb +118 -0
  202. data/test/unit/gateways/exact_test.rb +156 -0
  203. data/test/unit/gateways/gateway_test.rb +48 -0
  204. data/test/unit/gateways/instapay_test.rb +102 -0
  205. data/test/unit/gateways/linkpoint_test.rb +167 -0
  206. data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
  207. data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
  208. data/test/unit/gateways/moneris_test.rb +158 -0
  209. data/test/unit/gateways/net_registry_test.rb +416 -0
  210. data/test/unit/gateways/netbilling_test.rb +54 -0
  211. data/test/unit/gateways/pay_junction_test.rb +123 -0
  212. data/test/unit/gateways/pay_secure_test.rb +71 -0
  213. data/test/unit/gateways/payflow_express_test.rb +173 -0
  214. data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
  215. data/test/unit/gateways/payflow_test.rb +305 -0
  216. data/test/unit/gateways/payflow_uk_test.rb +30 -0
  217. data/test/unit/gateways/payment_express_test.rb +195 -0
  218. data/test/unit/gateways/paypal_express_test.rb +382 -0
  219. data/test/unit/gateways/paypal_test.rb +520 -0
  220. data/test/unit/gateways/plugnpay_test.rb +86 -0
  221. data/test/unit/gateways/protx_test.rb +139 -0
  222. data/test/unit/gateways/psigate_test.rb +169 -0
  223. data/test/unit/gateways/psl_card_test.rb +64 -0
  224. data/test/unit/gateways/quickpay_test.rb +112 -0
  225. data/test/unit/gateways/realex_test.rb +151 -0
  226. data/test/unit/gateways/sage_bankcard_test.rb +162 -0
  227. data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
  228. data/test/unit/gateways/secure_pay_au_test.rb +207 -0
  229. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  230. data/test/unit/gateways/secure_pay_test.rb +87 -0
  231. data/test/unit/gateways/skip_jack_test.rb +133 -0
  232. data/test/unit/gateways/trans_first_test.rb +112 -0
  233. data/test/unit/gateways/trust_commerce_test.rb +90 -0
  234. data/test/unit/gateways/usa_epay_test.rb +128 -0
  235. data/test/unit/gateways/verifi_test.rb +96 -0
  236. data/test/unit/gateways/viaklix_test.rb +78 -0
  237. data/test/unit/gateways/wirecard_test.rb +250 -0
  238. data/test/unit/generators/test_gateway_generator.rb +46 -0
  239. data/test/unit/generators/test_generator_helper.rb +20 -0
  240. data/test/unit/generators/test_integration_generator.rb +53 -0
  241. data/test/unit/integrations/action_view_helper_test.rb +50 -0
  242. data/test/unit/integrations/bogus_module_test.rb +20 -0
  243. data/test/unit/integrations/chronopay_module_test.rb +13 -0
  244. data/test/unit/integrations/gestpay_module_test.rb +14 -0
  245. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  246. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  247. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  248. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  249. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  250. data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
  251. data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
  252. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  253. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  254. data/test/unit/integrations/nochex_module_test.rb +13 -0
  255. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  256. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  257. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
  258. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  259. data/test/unit/integrations/notifications/notification_test.rb +54 -0
  260. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  261. data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
  262. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  263. data/test/unit/integrations/paypal_module_test.rb +28 -0
  264. data/test/unit/integrations/quickpay_module_test.rb +9 -0
  265. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  266. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  267. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  268. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  269. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  270. data/test/unit/integrations/returns/return_test.rb +11 -0
  271. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  272. data/test/unit/integrations/two_checkout_module_test.rb +13 -0
  273. data/test/unit/post_data_test.rb +55 -0
  274. data/test/unit/posts_data_test.rb +48 -0
  275. data/test/unit/response_test.rb +28 -0
  276. data/test/unit/utils_test.rb +7 -0
  277. data/test/unit/validateable_test.rb +60 -0
  278. metadata +364 -0
@@ -0,0 +1,396 @@
1
+ require 'rexml/document'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+
6
+ # Initialization Options
7
+ # :login Your store number
8
+ # :pem The text of your linkpoint PEM file. Note
9
+ # this is not the path to file, but its
10
+ # contents. If you are only using one PEM
11
+ # file on your site you can declare it
12
+ # globally and then you won't need to
13
+ # include this option
14
+ #
15
+ #
16
+ # A valid store number is required. Unfortunately, with LinkPoint
17
+ # YOU CAN'T JUST USE ANY OLD STORE NUMBER. Also, you can't just
18
+ # generate your own PEM file. You'll need to use a special PEM file
19
+ # provided by LinkPoint.
20
+ #
21
+ # Go to http://www.linkpoint.com/support/sup_teststore.asp to set up
22
+ # a test account and obtain your PEM file.
23
+ #
24
+ # Declaring PEM file Globally
25
+ # ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' )
26
+ #
27
+ #
28
+ # Valid Order Options
29
+ # :result =>
30
+ # LIVE Production mode
31
+ # GOOD Approved response in test mode
32
+ # DECLINE Declined response in test mode
33
+ # DUPLICATE Duplicate response in test mode
34
+ #
35
+ # :ponumber Order number
36
+ #
37
+ # :transactionorigin => Source of the transaction
38
+ # ECI Email or Internet
39
+ # MAIL Mail order
40
+ # MOTO Mail order/Telephone
41
+ # TELEPHONE Telephone
42
+ # RETAIL Face-to-face
43
+ #
44
+ # :ordertype =>
45
+ # SALE Real live sale
46
+ # PREAUTH Authorize only
47
+ # POSTAUTH Forced Ticket or Ticket Only transaction
48
+ # VOID
49
+ # CREDIT
50
+ # CALCSHIPPING For shipping charges calculations
51
+ # CALCTAX For sales tax calculations
52
+ #
53
+ # Recurring Options
54
+ # :action =>
55
+ # SUBMIT
56
+ # MODIFY
57
+ # CANCEL
58
+ #
59
+ # :installments Identifies how many recurring payments to charge the customer
60
+ # :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or "immediate"
61
+ # :periodicity =>
62
+ # MONTHLY
63
+ # BIMONTHLY
64
+ # WEEKLY
65
+ # BIWEEKLY
66
+ # YEARLY
67
+ # DAILY
68
+ # :threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant.
69
+ # :comments Uh... comments
70
+ #
71
+ #
72
+ # For reference:
73
+ #
74
+ # https://www.linkpointcentral.com/lpc/docs/Help/APIHelp/lpintguide.htm
75
+ #
76
+ # Entities = {
77
+ # :payment => [:subtotal, :tax, :vattax, :shipping, :chargetotal],
78
+ # :billing => [:name, :address1, :address2, :city, :state, :zip, :country, :email, :phone, :fax, :addrnum],
79
+ # :shipping => [:name, :address1, :address2, :city, :state, :zip, :country, :weight, :items, :carrier, :total],
80
+ # :creditcard => [:cardnumber, :cardexpmonth, :cardexpyear, :cvmvalue, :track],
81
+ # :telecheck => [:routing, :account, :checknumber, :bankname, :bankstate, :dl, :dlstate, :void, :accounttype, :ssn],
82
+ # :transactiondetails => [:transactionorigin, :oid, :ponumber, :taxexempt, :terminaltype, :ip, :reference_number, :recurring, :tdate],
83
+ # :periodic => [:action, :installments, :threshold, :startdate, :periodicity, :comments],
84
+ # :notes => [:comments, :referred]
85
+ # }
86
+ #
87
+ #
88
+ # IMPORTANT NOTICE:
89
+ #
90
+ # LinkPoint's Items entity is not yet supported in this module.
91
+ #
92
+ class LinkpointGateway < Gateway
93
+ # Your global PEM file. This will be assigned to you by linkpoint
94
+ #
95
+ # Example:
96
+ #
97
+ # ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' )
98
+ #
99
+ cattr_accessor :pem_file
100
+
101
+ TEST_URL = 'https://staging.linkpt.net:1129/'
102
+ LIVE_URL = 'https://secure.linkpt.net:1129/'
103
+
104
+ # We don't have the certificate to verify LinkPoint
105
+ self.ssl_strict = false
106
+
107
+ self.supported_countries = ['US']
108
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
109
+ self.homepage_url = 'http://www.linkpoint.com/'
110
+ self.display_name = 'LinkPoint'
111
+
112
+ def initialize(options = {})
113
+ requires!(options, :login)
114
+
115
+ @options = {
116
+ :result => 'LIVE',
117
+ :pem => LinkpointGateway.pem_file
118
+ }.update(options)
119
+
120
+ raise ArgumentError, "You need to pass in your pem file using the :pem parameter or set it globally using ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' ) or similar" if @options[:pem].blank?
121
+ end
122
+
123
+ # Send a purchase request with periodic options
124
+ # Recurring Options
125
+ # :action =>
126
+ # SUBMIT
127
+ # MODIFY
128
+ # CANCEL
129
+ #
130
+ # :installments Identifies how many recurring payments to charge the customer
131
+ # :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or "immediate"
132
+ # :periodicity =>
133
+ # :monthly
134
+ # :bimonthly
135
+ # :weekly
136
+ # :biweekly
137
+ # :yearly
138
+ # :daily
139
+ # :threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant.
140
+ # :comments Uh... comments
141
+ #
142
+ def recurring(money, creditcard, options={})
143
+ requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id )
144
+
145
+ options.update(
146
+ :ordertype => "SALE",
147
+ :action => options[:action] || "SUBMIT",
148
+ :installments => options[:installments] || 12,
149
+ :startdate => options[:startdate] || "immediate",
150
+ :periodicity => options[:periodicity].to_s || "monthly",
151
+ :comments => options[:comments] || nil,
152
+ :threshold => options[:threshold] || 3
153
+ )
154
+ commit(money, creditcard, options)
155
+ end
156
+
157
+ # Buy the thing
158
+ def purchase(money, creditcard, options={})
159
+ requires!(options, :order_id)
160
+ options.update(
161
+ :ordertype => "SALE"
162
+ )
163
+ commit(money, creditcard, options)
164
+ end
165
+
166
+ #
167
+ # Authorize the transaction
168
+ #
169
+ # Reserves the funds on the customer's credit card, but does not charge the card.
170
+ #
171
+ def authorize(money, creditcard, options = {})
172
+ requires!(options, :order_id)
173
+ options.update(
174
+ :ordertype => "PREAUTH"
175
+ )
176
+ commit(money, creditcard, options)
177
+ end
178
+
179
+ #
180
+ # Post an authorization.
181
+ #
182
+ # Captures the funds from an authorized transaction.
183
+ # Order_id must be a valid order id from a prior authorized transaction.
184
+ #
185
+ def capture(money, authorization, options = {})
186
+ options.update(
187
+ :order_id => authorization,
188
+ :ordertype => "POSTAUTH"
189
+ )
190
+ commit(money, nil, options)
191
+ end
192
+
193
+ # Void a previous transaction
194
+ def void(identification, options = {})
195
+ options.update(
196
+ :order_id => identification,
197
+ :ordertype => "VOID"
198
+ )
199
+ commit(nil, nil, options)
200
+ end
201
+
202
+ #
203
+ # Refund an order
204
+ #
205
+ # identification must be a valid order id previously submitted by SALE
206
+ #
207
+ def credit(money, identification, options = {})
208
+ options.update(
209
+ :ordertype => "CREDIT",
210
+ :order_id => identification
211
+ )
212
+ commit(money, nil, options)
213
+ end
214
+
215
+ def test?
216
+ @options[:test] || super
217
+ end
218
+
219
+ private
220
+ # Commit the transaction by posting the XML file to the LinkPoint server
221
+ def commit(money, creditcard, options = {})
222
+ response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(money, creditcard, options)))
223
+
224
+ Response.new(successful?(response), response[:message], response,
225
+ :test => test?,
226
+ :authorization => response[:ordernum],
227
+ :avs_result => { :code => response[:avs].to_s[2,1] },
228
+ :cvv_result => response[:avs].to_s[3,1]
229
+ )
230
+ end
231
+
232
+ def successful?(response)
233
+ response[:approved] == "APPROVED"
234
+ end
235
+
236
+ # Build the XML file
237
+ def post_data(money, creditcard, options)
238
+ params = parameters(money, creditcard, options)
239
+
240
+ xml = REXML::Document.new
241
+ order = xml.add_element("order")
242
+
243
+ # Merchant Info
244
+ merchantinfo = order.add_element("merchantinfo")
245
+ merchantinfo.add_element("configfile").text = @options[:login]
246
+
247
+ # Loop over the params hash to construct the XML string
248
+ for key, value in params
249
+ elem = order.add_element(key.to_s)
250
+ for k, v in params[key]
251
+ elem.add_element(k.to_s).text = params[key][k].to_s if params[key][k]
252
+ end
253
+ # Linkpoint doesn't understand empty elements:
254
+ order.delete(elem) if elem.size == 0
255
+ end
256
+
257
+ return xml.to_s
258
+ end
259
+
260
+ # Set up the parameters hash just once so we don't have to do it
261
+ # for every action.
262
+ def parameters(money, creditcard, options = {})
263
+
264
+ params = {
265
+ :payment => {
266
+ :subtotal => amount(options[:subtotal]),
267
+ :tax => amount(options[:tax]),
268
+ :vattax => amount(options[:vattax]),
269
+ :shipping => amount(options[:shipping]),
270
+ :chargetotal => amount(money)
271
+ },
272
+ :transactiondetails => {
273
+ :transactionorigin => options[:transactionorigin] || "ECI",
274
+ :oid => options[:order_id],
275
+ :ponumber => options[:ponumber],
276
+ :taxexempt => options[:taxexempt],
277
+ :terminaltype => options[:terminaltype],
278
+ :ip => options[:ip],
279
+ :reference_number => options[:reference_number],
280
+ :recurring => options[:recurring] || "NO", #DO NOT USE if you are using the periodic billing option.
281
+ :tdate => options[:tdate]
282
+ },
283
+ :orderoptions => {
284
+ :ordertype => options[:ordertype],
285
+ :result => @options[:result]
286
+ },
287
+ :periodic => {
288
+ :action => options[:action],
289
+ :installments => options[:installments],
290
+ :threshold => options[:threshold],
291
+ :startdate => options[:startdate],
292
+ :periodicity => options[:periodicity],
293
+ :comments => options[:comments]
294
+ },
295
+ :telecheck => {
296
+ :routing => options[:telecheck_routing],
297
+ :account => options[:telecheck_account],
298
+ :checknumber => options[:telecheck_checknumber],
299
+ :bankname => options[:telecheck_bankname],
300
+ :dl => options[:telecheck_dl],
301
+ :dlstate => options[:telecheck_dlstate],
302
+ :void => options[:telecheck_void],
303
+ :accounttype => options[:telecheck_accounttype],
304
+ :ssn => options[:telecheck_ssn],
305
+ }
306
+ }
307
+
308
+ if creditcard
309
+ params[:creditcard] = {
310
+ :cardnumber => creditcard.number,
311
+ :cardexpmonth => creditcard.month,
312
+ :cardexpyear => format_creditcard_expiry_year(creditcard.year),
313
+ :track => nil
314
+ }
315
+
316
+ if creditcard.verification_value?
317
+ params[:creditcard][:cvmvalue] = creditcard.verification_value
318
+ params[:creditcard][:cvmindicator] = 'provided'
319
+ else
320
+ params[:creditcard][:cvmindicator] = 'not_provided'
321
+ end
322
+ end
323
+
324
+ if billing_address = options[:billing_address] || options[:address]
325
+
326
+ params[:billing] = {}
327
+ params[:billing][:name] = billing_address[:name] || creditcard ? creditcard.name : nil
328
+ params[:billing][:address1] = billing_address[:address1] unless billing_address[:address1].blank?
329
+ params[:billing][:address2] = billing_address[:address2] unless billing_address[:address2].blank?
330
+ params[:billing][:city] = billing_address[:city] unless billing_address[:city].blank?
331
+ params[:billing][:state] = billing_address[:state] unless billing_address[:state].blank?
332
+ params[:billing][:zip] = billing_address[:zip] unless billing_address[:zip].blank?
333
+ params[:billing][:country] = billing_address[:country] unless billing_address[:country].blank?
334
+ params[:billing][:company] = billing_address[:company] unless billing_address[:company].blank?
335
+ params[:billing][:phone] = billing_address[:phone] unless billing_address[:phone].blank?
336
+ params[:billing][:email] = options[:email] unless options[:email].blank?
337
+ end
338
+
339
+ if shipping_address = options[:shipping_address]
340
+
341
+ params[:shipping] = {}
342
+ params[:shipping][:name] = shipping_address[:name] || creditcard ? creditcard.name : nil
343
+ params[:shipping][:address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
344
+ params[:shipping][:address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
345
+ params[:shipping][:city] = shipping_address[:city] unless shipping_address[:city].blank?
346
+ params[:shipping][:state] = shipping_address[:state] unless shipping_address[:state].blank?
347
+ params[:shipping][:zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
348
+ params[:shipping][:country] = shipping_address[:country] unless shipping_address[:country].blank?
349
+ end
350
+
351
+ return params
352
+ end
353
+
354
+ def parse(xml)
355
+
356
+ # For reference, a typical response...
357
+ # <r_csp></r_csp>
358
+ # <r_time></r_time>
359
+ # <r_ref></r_ref>
360
+ # <r_error></r_error>
361
+ # <r_ordernum></r_ordernum>
362
+ # <r_message>This is a test transaction and will not show up in the Reports</r_message>
363
+ # <r_code></r_code>
364
+ # <r_tdate>Thu Feb 2 15:40:21 2006</r_tdate>
365
+ # <r_score></r_score>
366
+ # <r_authresponse></r_authresponse>
367
+ # <r_approved>APPROVED</r_approved>
368
+ # <r_avs></r_avs>
369
+
370
+ response = {:message => "Global Error Receipt", :complete => false}
371
+
372
+ xml = REXML::Document.new("<response>#{xml}</response>")
373
+ xml.root.elements.each do |node|
374
+ response[node.name.downcase.sub(/^r_/, '').to_sym] = normalize(node.text)
375
+ end unless xml.root.nil?
376
+
377
+ response
378
+ end
379
+
380
+ # Make a ruby type out of the response string
381
+ def normalize(field)
382
+ case field
383
+ when "true" then true
384
+ when "false" then false
385
+ when "" then nil
386
+ when "null" then nil
387
+ else field
388
+ end
389
+ end
390
+
391
+ def format_creditcard_expiry_year(year)
392
+ sprintf("%.4i", year)[-2..-1]
393
+ end
394
+ end
395
+ end
396
+ end
@@ -0,0 +1,154 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class MerchantESolutionsGateway < Gateway
4
+
5
+ TEST_URL = 'https://test.merchante-solutions.com/mes-api/tridentApi'
6
+ LIVE_URL = 'https://api.merchante-solutions.com/mes-api/tridentApi'
7
+
8
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
9
+ self.supported_countries = ['US']
10
+
11
+ # The card types supported by the payment gateway
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb]
13
+
14
+ # The homepage URL of the gateway
15
+ self.homepage_url = 'http://www.merchante-solutions.com/'
16
+
17
+ # The name of the gateway
18
+ self.display_name = 'Merchant e-Solutions'
19
+
20
+ def initialize(options = {})
21
+ requires!(options, :login, :password)
22
+ @options = options
23
+ super
24
+ end
25
+
26
+ def authorize(money, creditcard_or_card_id, options = {})
27
+ post = {}
28
+ add_invoice(post, options)
29
+ add_payment_source(post, creditcard_or_card_id, options)
30
+ add_address(post, options)
31
+ commit('P', money, post)
32
+ end
33
+
34
+ def purchase(money, creditcard_or_card_id, options = {})
35
+ post = {}
36
+ add_invoice(post, options)
37
+ add_payment_source(post, creditcard_or_card_id, options)
38
+ add_address(post, options)
39
+ commit('D', money, post)
40
+ end
41
+
42
+ def capture(money, transaction_id, options = {})
43
+ post ={}
44
+ post[:transaction_id] = transaction_id
45
+ commit('S', money, post)
46
+ end
47
+
48
+ def store(creditcard, options = {})
49
+ post = {}
50
+ add_creditcard(post, creditcard, options)
51
+ commit('T', nil, post)
52
+ end
53
+
54
+ def unstore(card_id)
55
+ post = {}
56
+ post[:card_id] = card_id
57
+ commit('X', nil, post)
58
+ end
59
+
60
+ def credit(money, creditcard_or_card_id, options = {})
61
+ post ={}
62
+ add_payment_source(post, creditcard_or_card_id, options)
63
+ commit('C', money, post)
64
+ end
65
+
66
+ def void(transaction_id)
67
+ post = {}
68
+ post[:transaction_id] = transaction_id
69
+ commit('V', nil, post)
70
+ end
71
+
72
+ private
73
+
74
+ def add_address(post, options)
75
+ if address = options[:billing_address] || options[:address]
76
+ post[:cardholder_street_address] = address[:address1].to_s.gsub(/[^\w.]/, '+')
77
+ post[:cardholder_zip] = address[:zip].to_s
78
+ end
79
+ end
80
+
81
+ def add_invoice(post, options)
82
+ if options.has_key? :order_id
83
+ post[:invoice_number] = options[:order_id].to_s.gsub(/[^\w.]/, '')
84
+ end
85
+ end
86
+
87
+ def add_payment_source(post, creditcard_or_card_id, options)
88
+ if creditcard_or_card_id.is_a?(String)
89
+ # using stored card
90
+ post[:card_id] = creditcard_or_card_id
91
+ else
92
+ # card info is provided
93
+ add_creditcard(post, creditcard_or_card_id, options)
94
+ end
95
+ end
96
+
97
+ def add_creditcard(post, creditcard, options)
98
+ post[:card_number] = creditcard.number
99
+ post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
100
+ post[:card_exp_date] = expdate(creditcard)
101
+ end
102
+
103
+ def parse(body)
104
+ results = {}
105
+ body.split(/&/).each do |pair|
106
+ key,val = pair.split(/=/)
107
+ results[key] = val
108
+ end
109
+ results
110
+ end
111
+
112
+ def commit(action, money, parameters)
113
+
114
+ url = test? ? TEST_URL : LIVE_URL
115
+ parameters[:transaction_amount] = amount(money) if money unless action == 'V'
116
+
117
+ response = parse( ssl_post(url, post_data(action,parameters)) )
118
+
119
+ Response.new(response["error_code"] == "000", message_from(response), response,
120
+ :authorization => response["transaction_id"],
121
+ :test => test?,
122
+ :cvv_result => response["cvv2_result"],
123
+ :avs_result => { :code => response["avs_result"] }
124
+ )
125
+
126
+ end
127
+
128
+ def expdate(creditcard)
129
+ year = sprintf("%.4i", creditcard.year)
130
+ month = sprintf("%.2i", creditcard.month)
131
+ "#{month}#{year[-2..-1]}"
132
+ end
133
+
134
+ def message_from(response)
135
+ if response["error_code"] == "000"
136
+ "This transaction has been approved"
137
+ else
138
+ response["auth_response_text"]
139
+ end
140
+ end
141
+
142
+ def post_data(action, parameters = {})
143
+ post = {}
144
+ post[:profile_id] = @options[:login]
145
+ post[:profile_key] = @options[:password]
146
+ post[:transaction_type] = action if action
147
+
148
+ request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
149
+ request
150
+ end
151
+ end
152
+ end
153
+ end
154
+
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/modern_payments_cim'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class ModernPaymentsGateway < Gateway
6
+ self.supported_countries = ModernPaymentsCimGateway.supported_countries
7
+ self.supported_cardtypes = ModernPaymentsCimGateway.supported_cardtypes
8
+ self.homepage_url = ModernPaymentsCimGateway.homepage_url
9
+ self.display_name = ModernPaymentsCimGateway.display_name
10
+
11
+ def initialize(options = {})
12
+ requires!(options, :login, :password)
13
+ @options = options
14
+ super
15
+ end
16
+
17
+ def purchase(money, credit_card, options = {})
18
+ customer_response = cim.create_customer(options)
19
+ return customer_response unless customer_response.success?
20
+
21
+ customer_id = customer_response.params["create_customer_result"]
22
+
23
+ card_response = cim.modify_customer_credit_card(customer_id, credit_card)
24
+ return card_response unless card_response.success?
25
+
26
+ cim.authorize_credit_card_payment(customer_id, money)
27
+ end
28
+
29
+ private
30
+ def cim
31
+ @cim ||= ModernPaymentsCimGateway.new(@options)
32
+ end
33
+ end
34
+ end
35
+ end
36
+