merb_merchant 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. data/CHANGELOG +421 -0
  2. data/CONTRIBUTERS +90 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README +131 -0
  5. data/Rakefile +129 -0
  6. data/init.rb +3 -0
  7. data/lib/certs/cacert.pem +7815 -0
  8. data/lib/core_ext/delegating_attributes.rb +76 -0
  9. data/lib/core_ext/hash_ext.rb +35 -0
  10. data/lib/core_ext/inheritable_attributes.rb +145 -0
  11. data/lib/core_ext/time_dsl.rb +59 -0
  12. data/lib/merb_merchant.rb +96 -0
  13. data/lib/merb_merchant/billing/avs_result.rb +95 -0
  14. data/lib/merb_merchant/billing/base.rb +71 -0
  15. data/lib/merb_merchant/billing/check.rb +68 -0
  16. data/lib/merb_merchant/billing/credit_card.rb +157 -0
  17. data/lib/merb_merchant/billing/credit_card_formatting.rb +21 -0
  18. data/lib/merb_merchant/billing/credit_card_methods.rb +125 -0
  19. data/lib/merb_merchant/billing/cvv_result.rb +38 -0
  20. data/lib/merb_merchant/billing/expiry_date.rb +28 -0
  21. data/lib/merb_merchant/billing/gateway.rb +162 -0
  22. data/lib/merb_merchant/billing/gateways.rb +3 -0
  23. data/lib/merb_merchant/billing/gateways/authorize_net.rb +646 -0
  24. data/lib/merb_merchant/billing/gateways/authorize_net_cim.rb +702 -0
  25. data/lib/merb_merchant/billing/gateways/beanstream.rb +102 -0
  26. data/lib/merb_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
  27. data/lib/merb_merchant/billing/gateways/beanstream_interac.rb +54 -0
  28. data/lib/merb_merchant/billing/gateways/bogus.rb +98 -0
  29. data/lib/merb_merchant/billing/gateways/braintree.rb +222 -0
  30. data/lib/merb_merchant/billing/gateways/card_stream.rb +229 -0
  31. data/lib/merb_merchant/billing/gateways/cyber_source.rb +406 -0
  32. data/lib/merb_merchant/billing/gateways/data_cash.rb +595 -0
  33. data/lib/merb_merchant/billing/gateways/efsnet.rb +229 -0
  34. data/lib/merb_merchant/billing/gateways/eway.rb +272 -0
  35. data/lib/merb_merchant/billing/gateways/exact.rb +222 -0
  36. data/lib/merb_merchant/billing/gateways/linkpoint.rb +396 -0
  37. data/lib/merb_merchant/billing/gateways/modern_payments.rb +36 -0
  38. data/lib/merb_merchant/billing/gateways/modern_payments_cim.rb +214 -0
  39. data/lib/merb_merchant/billing/gateways/moneris.rb +205 -0
  40. data/lib/merb_merchant/billing/gateways/net_registry.rb +189 -0
  41. data/lib/merb_merchant/billing/gateways/netbilling.rb +168 -0
  42. data/lib/merb_merchant/billing/gateways/pay_junction.rb +392 -0
  43. data/lib/merb_merchant/billing/gateways/pay_secure.rb +120 -0
  44. data/lib/merb_merchant/billing/gateways/payflow.rb +236 -0
  45. data/lib/merb_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
  46. data/lib/merb_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  47. data/lib/merb_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  48. data/lib/merb_merchant/billing/gateways/payflow_express.rb +138 -0
  49. data/lib/merb_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  50. data/lib/merb_merchant/billing/gateways/payflow_uk.rb +21 -0
  51. data/lib/merb_merchant/billing/gateways/payment_express.rb +241 -0
  52. data/lib/merb_merchant/billing/gateways/paypal.rb +108 -0
  53. data/lib/merb_merchant/billing/gateways/paypal/paypal_common_api.rb +325 -0
  54. data/lib/merb_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
  55. data/lib/merb_merchant/billing/gateways/paypal_ca.rb +13 -0
  56. data/lib/merb_merchant/billing/gateways/paypal_express.rb +130 -0
  57. data/lib/merb_merchant/billing/gateways/paypal_express_common.rb +20 -0
  58. data/lib/merb_merchant/billing/gateways/plugnpay.rb +292 -0
  59. data/lib/merb_merchant/billing/gateways/protx.rb +284 -0
  60. data/lib/merb_merchant/billing/gateways/psigate.rb +214 -0
  61. data/lib/merb_merchant/billing/gateways/psl_card.rb +306 -0
  62. data/lib/merb_merchant/billing/gateways/quickpay.rb +213 -0
  63. data/lib/merb_merchant/billing/gateways/realex.rb +200 -0
  64. data/lib/merb_merchant/billing/gateways/sage.rb +146 -0
  65. data/lib/merb_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  66. data/lib/merb_merchant/billing/gateways/sage/sage_core.rb +110 -0
  67. data/lib/merb_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  68. data/lib/merb_merchant/billing/gateways/secure_pay.rb +31 -0
  69. data/lib/merb_merchant/billing/gateways/secure_pay_au.rb +157 -0
  70. data/lib/merb_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  71. data/lib/merb_merchant/billing/gateways/skip_jack.rb +439 -0
  72. data/lib/merb_merchant/billing/gateways/trans_first.rb +127 -0
  73. data/lib/merb_merchant/billing/gateways/trust_commerce.rb +418 -0
  74. data/lib/merb_merchant/billing/gateways/usa_epay.rb +194 -0
  75. data/lib/merb_merchant/billing/gateways/verifi.rb +228 -0
  76. data/lib/merb_merchant/billing/gateways/viaklix.rb +165 -0
  77. data/lib/merb_merchant/billing/gateways/wirecard.rb +305 -0
  78. data/lib/merb_merchant/billing/integrations.rb +22 -0
  79. data/lib/merb_merchant/billing/integrations/action_view_helper.rb +79 -0
  80. data/lib/merb_merchant/billing/integrations/bogus.rb +29 -0
  81. data/lib/merb_merchant/billing/integrations/bogus/helper.rb +17 -0
  82. data/lib/merb_merchant/billing/integrations/bogus/notification.rb +11 -0
  83. data/lib/merb_merchant/billing/integrations/bogus/return.rb +10 -0
  84. data/lib/merb_merchant/billing/integrations/chronopay.rb +29 -0
  85. data/lib/merb_merchant/billing/integrations/chronopay/helper.rb +81 -0
  86. data/lib/merb_merchant/billing/integrations/chronopay/notification.rb +156 -0
  87. data/lib/merb_merchant/billing/integrations/chronopay/return.rb +10 -0
  88. data/lib/merb_merchant/billing/integrations/gestpay.rb +32 -0
  89. data/lib/merb_merchant/billing/integrations/gestpay/common.rb +42 -0
  90. data/lib/merb_merchant/billing/integrations/gestpay/helper.rb +70 -0
  91. data/lib/merb_merchant/billing/integrations/gestpay/notification.rb +83 -0
  92. data/lib/merb_merchant/billing/integrations/gestpay/return.rb +10 -0
  93. data/lib/merb_merchant/billing/integrations/helper.rb +93 -0
  94. data/lib/merb_merchant/billing/integrations/hi_trust.rb +26 -0
  95. data/lib/merb_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  96. data/lib/merb_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  97. data/lib/merb_merchant/billing/integrations/hi_trust/return.rb +67 -0
  98. data/lib/merb_merchant/billing/integrations/nochex.rb +101 -0
  99. data/lib/merb_merchant/billing/integrations/nochex/helper.rb +68 -0
  100. data/lib/merb_merchant/billing/integrations/nochex/notification.rb +94 -0
  101. data/lib/merb_merchant/billing/integrations/nochex/return.rb +10 -0
  102. data/lib/merb_merchant/billing/integrations/notification.rb +62 -0
  103. data/lib/merb_merchant/billing/integrations/paypal.rb +54 -0
  104. data/lib/merb_merchant/billing/integrations/paypal/helper.rb +118 -0
  105. data/lib/merb_merchant/billing/integrations/paypal/notification.rb +154 -0
  106. data/lib/merb_merchant/billing/integrations/paypal/return.rb +10 -0
  107. data/lib/merb_merchant/billing/integrations/quickpay.rb +25 -0
  108. data/lib/merb_merchant/billing/integrations/quickpay/helper.rb +72 -0
  109. data/lib/merb_merchant/billing/integrations/quickpay/notification.rb +74 -0
  110. data/lib/merb_merchant/billing/integrations/return.rb +35 -0
  111. data/lib/merb_merchant/billing/integrations/two_checkout.rb +30 -0
  112. data/lib/merb_merchant/billing/integrations/two_checkout/helper.rb +59 -0
  113. data/lib/merb_merchant/billing/integrations/two_checkout/notification.rb +114 -0
  114. data/lib/merb_merchant/billing/integrations/two_checkout/return.rb +17 -0
  115. data/lib/merb_merchant/billing/response.rb +32 -0
  116. data/lib/merb_merchant/lib/country.rb +298 -0
  117. data/lib/merb_merchant/lib/error.rb +4 -0
  118. data/lib/merb_merchant/lib/inflector.rb +69 -0
  119. data/lib/merb_merchant/lib/post_data.rb +22 -0
  120. data/lib/merb_merchant/lib/posts_data.rb +109 -0
  121. data/lib/merb_merchant/lib/requires_parameters.rb +16 -0
  122. data/lib/merb_merchant/lib/utils.rb +18 -0
  123. data/lib/merb_merchant/lib/validateable.rb +76 -0
  124. data/lib/support/gateway_support.rb +57 -0
  125. data/lib/tasks/cia.rb +90 -0
  126. data/script/destroy +14 -0
  127. data/script/generate +14 -0
  128. data/test/extra/binding_of_caller.rb +80 -0
  129. data/test/extra/breakpoint.rb +547 -0
  130. data/test/fixtures.yml +317 -0
  131. data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
  132. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  133. data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
  134. data/test/remote/gateways/remote_beanstream_test.rb +150 -0
  135. data/test/remote/gateways/remote_braintree_test.rb +154 -0
  136. data/test/remote/gateways/remote_card_stream_test.rb +148 -0
  137. data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
  138. data/test/remote/gateways/remote_data_cash_test.rb +357 -0
  139. data/test/remote/gateways/remote_efsnet_test.rb +81 -0
  140. data/test/remote/gateways/remote_eway_test.rb +74 -0
  141. data/test/remote/gateways/remote_exact_test.rb +60 -0
  142. data/test/remote/gateways/remote_linkpoint_test.rb +112 -0
  143. data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
  144. data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
  145. data/test/remote/gateways/remote_moneris_test.rb +82 -0
  146. data/test/remote/gateways/remote_net_registry_test.rb +85 -0
  147. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  148. data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
  149. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  150. data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
  151. data/test/remote/gateways/remote_payflow_test.rb +237 -0
  152. data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
  153. data/test/remote/gateways/remote_payment_express_test.rb +126 -0
  154. data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
  155. data/test/remote/gateways/remote_paypal_test.rb +167 -0
  156. data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
  157. data/test/remote/gateways/remote_protx_test.rb +184 -0
  158. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  159. data/test/remote/gateways/remote_psl_card_test.rb +125 -0
  160. data/test/remote/gateways/remote_quickpay_test.rb +190 -0
  161. data/test/remote/gateways/remote_realex_test.rb +224 -0
  162. data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
  163. data/test/remote/gateways/remote_sage_test.rb +87 -0
  164. data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
  165. data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
  166. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  167. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  168. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  169. data/test/remote/gateways/remote_trans_first_test.rb +34 -0
  170. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  171. data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
  172. data/test/remote/gateways/remote_verifi_test.rb +107 -0
  173. data/test/remote/gateways/remote_viaklix_test.rb +43 -0
  174. data/test/remote/gateways/remote_wirecard_test.rb +77 -0
  175. data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
  176. data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
  177. data/test/test_helper.rb +208 -0
  178. data/test/unit/avs_result_test.rb +59 -0
  179. data/test/unit/base_test.rb +55 -0
  180. data/test/unit/check_test.rb +88 -0
  181. data/test/unit/country_code_test.rb +33 -0
  182. data/test/unit/country_test.rb +64 -0
  183. data/test/unit/credit_card_formatting_test.rb +19 -0
  184. data/test/unit/credit_card_methods_test.rb +170 -0
  185. data/test/unit/credit_card_test.rb +311 -0
  186. data/test/unit/cvv_result_test.rb +33 -0
  187. data/test/unit/expiry_date_test.rb +21 -0
  188. data/test/unit/gateways/authorize_net_cim_test.rb +638 -0
  189. data/test/unit/gateways/authorize_net_test.rb +290 -0
  190. data/test/unit/gateways/beanstream_interac_test.rb +51 -0
  191. data/test/unit/gateways/beanstream_test.rb +108 -0
  192. data/test/unit/gateways/bogus_test.rb +46 -0
  193. data/test/unit/gateways/braintree_test.rb +116 -0
  194. data/test/unit/gateways/card_stream_test.rb +91 -0
  195. data/test/unit/gateways/cyber_source_test.rb +188 -0
  196. data/test/unit/gateways/data_cash_test.rb +132 -0
  197. data/test/unit/gateways/efsnet_test.rb +124 -0
  198. data/test/unit/gateways/eway_test.rb +118 -0
  199. data/test/unit/gateways/exact_test.rb +156 -0
  200. data/test/unit/gateways/gateway_test.rb +48 -0
  201. data/test/unit/gateways/linkpoint_test.rb +167 -0
  202. data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
  203. data/test/unit/gateways/moneris_test.rb +158 -0
  204. data/test/unit/gateways/net_registry_test.rb +416 -0
  205. data/test/unit/gateways/netbilling_test.rb +54 -0
  206. data/test/unit/gateways/pay_junction_test.rb +123 -0
  207. data/test/unit/gateways/pay_secure_test.rb +71 -0
  208. data/test/unit/gateways/payflow_express_test.rb +173 -0
  209. data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
  210. data/test/unit/gateways/payflow_test.rb +305 -0
  211. data/test/unit/gateways/payflow_uk_test.rb +30 -0
  212. data/test/unit/gateways/payment_express_test.rb +195 -0
  213. data/test/unit/gateways/paypal_express_test.rb +382 -0
  214. data/test/unit/gateways/paypal_test.rb +520 -0
  215. data/test/unit/gateways/plugnpay_test.rb +86 -0
  216. data/test/unit/gateways/protx_test.rb +122 -0
  217. data/test/unit/gateways/psigate_test.rb +169 -0
  218. data/test/unit/gateways/psl_card_test.rb +64 -0
  219. data/test/unit/gateways/quickpay_test.rb +112 -0
  220. data/test/unit/gateways/realex_test.rb +151 -0
  221. data/test/unit/gateways/sage_bankcard_test.rb +162 -0
  222. data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
  223. data/test/unit/gateways/secure_pay_au_test.rb +207 -0
  224. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  225. data/test/unit/gateways/secure_pay_test.rb +87 -0
  226. data/test/unit/gateways/skip_jack_test.rb +133 -0
  227. data/test/unit/gateways/trans_first_test.rb +112 -0
  228. data/test/unit/gateways/trust_commerce_test.rb +90 -0
  229. data/test/unit/gateways/usa_epay_test.rb +128 -0
  230. data/test/unit/gateways/verifi_test.rb +96 -0
  231. data/test/unit/gateways/viaklix_test.rb +78 -0
  232. data/test/unit/gateways/wirecard_test.rb +232 -0
  233. data/test/unit/generators/test_gateway_generator.rb +46 -0
  234. data/test/unit/generators/test_generator_helper.rb +20 -0
  235. data/test/unit/generators/test_integration_generator.rb +53 -0
  236. data/test/unit/integrations/action_view_helper_test.rb +50 -0
  237. data/test/unit/integrations/bogus_module_test.rb +20 -0
  238. data/test/unit/integrations/chronopay_module_test.rb +13 -0
  239. data/test/unit/integrations/gestpay_module_test.rb +14 -0
  240. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  241. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  242. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  243. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  244. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  245. data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
  246. data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
  247. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  248. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  249. data/test/unit/integrations/nochex_module_test.rb +13 -0
  250. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  251. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  252. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
  253. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  254. data/test/unit/integrations/notifications/notification_test.rb +54 -0
  255. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  256. data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
  257. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  258. data/test/unit/integrations/paypal_module_test.rb +28 -0
  259. data/test/unit/integrations/quickpay_module_test.rb +9 -0
  260. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  261. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  262. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  263. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  264. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  265. data/test/unit/integrations/returns/return_test.rb +11 -0
  266. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  267. data/test/unit/integrations/two_checkout_module_test.rb +13 -0
  268. data/test/unit/post_data_test.rb +55 -0
  269. data/test/unit/posts_data_test.rb +100 -0
  270. data/test/unit/response_test.rb +28 -0
  271. data/test/unit/utils_test.rb +7 -0
  272. data/test/unit/validateable_test.rb +60 -0
  273. metadata +379 -0
@@ -0,0 +1,76 @@
1
+ #--
2
+ # Copyright (c) 2005 David Heinemeier Hansson
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ # These class attributes behave something like the class
25
+ # inheritable accessors. But instead of copying the hash over at
26
+ # the time the subclass is first defined, the accessors simply
27
+ # delegate to their superclass unless they have been given a
28
+ # specific value. This stops the strange situation where values
29
+ # set after class definition don't get applied to subclasses.
30
+ class Class
31
+ unless respond_to? :superclass_delegating_reader
32
+ def superclass_delegating_reader(*names)
33
+ class_name_to_stop_searching_on = self.superclass.name.blank? ? "Object" : self.superclass.name
34
+ names.each do |name|
35
+ class_eval <<-EOS
36
+ def self.#{name} # def self.only_reader
37
+ if defined?(@#{name}) # if defined?(@only_reader)
38
+ @#{name} # @only_reader
39
+ elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object &&
40
+ superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader)
41
+ superclass.#{name} # superclass.only_reader
42
+ end # end
43
+ end # end
44
+ def #{name} # def only_reader
45
+ self.class.#{name} # self.class.only_reader
46
+ end # end
47
+ def self.#{name}? # def self.only_reader?
48
+ !!#{name} # !!only_reader
49
+ end # end
50
+ def #{name}? # def only_reader?
51
+ !!#{name} # !!only_reader
52
+ end # end
53
+ EOS
54
+ end
55
+ end
56
+ end
57
+
58
+ unless respond_to? :superclass_delegating_writer
59
+ def superclass_delegating_writer(*names)
60
+ names.each do |name|
61
+ class_eval <<-EOS
62
+ def self.#{name}=(value) # def self.only_writer=(value)
63
+ @#{name} = value # @only_writer = value
64
+ end # end
65
+ EOS
66
+ end
67
+ end
68
+ end
69
+
70
+ unless respond_to? :superclass_delegating_accessor
71
+ def superclass_delegating_accessor(*names)
72
+ superclass_delegating_reader(*names)
73
+ superclass_delegating_writer(*names)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,35 @@
1
+ class Hash
2
+
3
+ # Return a new hash with all keys converted to strings.
4
+ def stringify_keys
5
+ inject({}) do |options, (key, value)|
6
+ options[key.to_s] = value
7
+ options
8
+ end
9
+ end
10
+
11
+ # Destructively convert all keys to strings.
12
+ def stringify_keys!
13
+ keys.each do |key|
14
+ self[key.to_s] = delete(key)
15
+ end
16
+ self
17
+ end
18
+
19
+ # Return a new hash with all keys converted to symbols.
20
+ def symbolize_keys
21
+ inject({}) do |options, (key, value)|
22
+ options[(key.to_sym rescue key) || key] = value
23
+ options
24
+ end
25
+ end
26
+
27
+ # Destructively convert all keys to symbols.
28
+ def symbolize_keys!
29
+ self.replace(self.symbolize_keys)
30
+ end
31
+
32
+ alias_method :to_options, :symbolize_keys
33
+ alias_method :to_options!, :symbolize_keys!
34
+
35
+ end
@@ -0,0 +1,145 @@
1
+ # Allows attributes to be shared within an inheritance hierarchy, but where each descendant gets a copy of
2
+ # their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
3
+ # to, for example, an array without those additions being shared with either their parent, siblings, or
4
+ # children, which is unlike the regular class-level attributes that are shared across the entire hierarchy.
5
+ class Class # :nodoc:
6
+ def class_inheritable_reader(*syms)
7
+ syms.each do |sym|
8
+ next if sym.is_a?(Hash)
9
+ class_eval <<-EOS
10
+ def self.#{sym} # def self.before_add_for_comments
11
+ read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:before_add_for_comments)
12
+ end # end
13
+ #
14
+ def #{sym} # def before_add_for_comments
15
+ self.class.#{sym} # self.class.before_add_for_comments
16
+ end # end
17
+ EOS
18
+ end
19
+ end
20
+
21
+ def class_inheritable_writer(*syms)
22
+ options = syms.last.is_a?(::Hash) ? syms.pop : {}
23
+ syms.each do |sym|
24
+ class_eval <<-EOS
25
+ def self.#{sym}=(obj) # def self.color=(obj)
26
+ write_inheritable_attribute(:#{sym}, obj) # write_inheritable_attribute(:color, obj)
27
+ end # end
28
+ #
29
+ #{" #
30
+ def #{sym}=(obj) # def color=(obj)
31
+ self.class.#{sym} = obj # self.class.color = obj
32
+ end # end
33
+ " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
34
+ EOS
35
+ end
36
+ end
37
+
38
+ def class_inheritable_array_writer(*syms)
39
+ options = syms.last.is_a?(::Hash) ? syms.pop : {}
40
+ syms.each do |sym|
41
+ class_eval <<-EOS
42
+ def self.#{sym}=(obj) # def self.levels=(obj)
43
+ write_inheritable_array(:#{sym}, obj) # write_inheritable_array(:levels, obj)
44
+ end # end
45
+ #
46
+ #{" #
47
+ def #{sym}=(obj) # def levels=(obj)
48
+ self.class.#{sym} = obj # self.class.levels = obj
49
+ end # end
50
+ " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
51
+ EOS
52
+ end
53
+ end
54
+
55
+ def class_inheritable_hash_writer(*syms)
56
+ options = syms.last.is_a?(::Hash) ? syms.pop : {}
57
+ syms.each do |sym|
58
+ class_eval <<-EOS
59
+ def self.#{sym}=(obj) # def self.nicknames=(obj)
60
+ write_inheritable_hash(:#{sym}, obj) # write_inheritable_hash(:nicknames, obj)
61
+ end # end
62
+ #
63
+ #{" #
64
+ def #{sym}=(obj) # def nicknames=(obj)
65
+ self.class.#{sym} = obj # self.class.nicknames = obj
66
+ end # end
67
+ " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
68
+ EOS
69
+ end
70
+ end
71
+
72
+ def class_inheritable_accessor(*syms)
73
+ class_inheritable_reader(*syms)
74
+ class_inheritable_writer(*syms)
75
+ end
76
+
77
+ def class_inheritable_array(*syms)
78
+ class_inheritable_reader(*syms)
79
+ class_inheritable_array_writer(*syms)
80
+ end
81
+
82
+ def class_inheritable_hash(*syms)
83
+ class_inheritable_reader(*syms)
84
+ class_inheritable_hash_writer(*syms)
85
+ end
86
+
87
+ def inheritable_attributes
88
+ @inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES
89
+ end
90
+
91
+ def write_inheritable_attribute(key, value)
92
+ if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
93
+ @inheritable_attributes = {}
94
+ end
95
+ inheritable_attributes[key] = value
96
+ end
97
+
98
+ def write_inheritable_array(key, elements)
99
+ write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil?
100
+ write_inheritable_attribute(key, read_inheritable_attribute(key) + elements)
101
+ end
102
+
103
+ def write_inheritable_hash(key, hash)
104
+ write_inheritable_attribute(key, {}) if read_inheritable_attribute(key).nil?
105
+ write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash))
106
+ end
107
+
108
+ def read_inheritable_attribute(key)
109
+ inheritable_attributes[key]
110
+ end
111
+
112
+ def reset_inheritable_attributes
113
+ @inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
114
+ end
115
+
116
+ private
117
+ # Prevent this constant from being created multiple times
118
+ EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze unless const_defined?(:EMPTY_INHERITABLE_ATTRIBUTES)
119
+
120
+ def inherited_with_inheritable_attributes(child)
121
+ inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)
122
+
123
+ if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
124
+ new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
125
+ else
126
+ new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)|
127
+ memo.update(key => is_duplicable?(value) ? value.dup : value)
128
+ end
129
+ end
130
+
131
+ child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)
132
+ end
133
+
134
+ def is_duplicable?(val)
135
+ case val.class
136
+ when NilClass, FalseClass, TrueClass, Symbol, Numeric, Class
137
+ false
138
+ else
139
+ true
140
+ end
141
+ end
142
+
143
+ alias inherited_without_inheritable_attributes inherited
144
+ alias inherited inherited_with_inheritable_attributes
145
+ end
@@ -0,0 +1,59 @@
1
+ # Provides a a simple way of calling time units and to see the elapsed time between 2 moments
2
+ # ==== Examples
3
+ # 142.minutes => returns a value in seconds
4
+ # 7.days => returns a value in seconds
5
+ # 1.week => returns a value in seconds
6
+ # 2.weeks.ago => returns a date
7
+ # 1.year.since(time) => returns a date
8
+ # 5.months.since(2.weeks.from_now) => returns a date
9
+ module TimeDSL
10
+
11
+ def second
12
+ self * 1
13
+ end
14
+ alias_method :seconds, :second
15
+
16
+ def minute
17
+ self * 60
18
+ end
19
+ alias_method :minutes, :minute
20
+
21
+ def hour
22
+ self * 3600
23
+ end
24
+ alias_method :hours, :hour
25
+
26
+ def day
27
+ self * 86400
28
+ end
29
+ alias_method :days, :day
30
+
31
+ def week
32
+ self * 604800
33
+ end
34
+ alias_method :weeks, :week
35
+
36
+ def month
37
+ self * 2592000
38
+ end
39
+ alias_method :months, :month
40
+
41
+ def year
42
+ self * 31471200
43
+ end
44
+ alias_method :years, :year
45
+
46
+ # Reads best without arguments: 10.minutes.ago
47
+ def ago(time = ::Time.now)
48
+ time - self
49
+ end
50
+ alias :until :ago
51
+
52
+ # Reads best with argument: 10.minutes.since(time)
53
+ def since(time = ::Time.now)
54
+ time + self
55
+ end
56
+ alias :from_now :since
57
+ end
58
+
59
+ Numeric.send :include, TimeDSL
@@ -0,0 +1,96 @@
1
+ #--
2
+ # Copyright (c) 2005-2007 Tobias Luetke
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift(File.dirname(__FILE__))
25
+
26
+ # Include rails' active support for all the core extensions we love
27
+ # begin
28
+ # require 'active_support'
29
+ # rescue LoadError
30
+ # require 'rubygems'
31
+ #
32
+ # if respond_to? :gem
33
+ # gem 'activesupport', ">=2.0.0"
34
+ # require 'active_support'
35
+ # else
36
+ # require_gem 'activesupport'
37
+ # end
38
+ # end
39
+
40
+ # Include extlib for a better memory footprint
41
+ begin
42
+ require 'extlib'
43
+ rescue LoadError
44
+ require 'rubygems'
45
+
46
+ if respond_to? :gem
47
+ gem 'extlib', ">= 0.9.10"
48
+ require 'extlib'
49
+ else
50
+ require_gem 'extlib'
51
+ end
52
+ end
53
+
54
+ require 'core_ext/delegating_attributes'
55
+ require 'core_ext/inheritable_attributes'
56
+ require 'core_ext/hash_ext'
57
+ require 'core_ext/time_dsl'
58
+
59
+ begin
60
+ require 'builder'
61
+ rescue LoadError
62
+ require 'rubygems'
63
+ require 'builder'
64
+ end
65
+
66
+ require 'cgi'
67
+
68
+ require 'merb_merchant/lib/utils'
69
+ require 'merb_merchant/lib/error'
70
+ require 'merb_merchant/lib/inflector'
71
+ require 'merb_merchant/lib/validateable'
72
+ require 'merb_merchant/lib/posts_data'
73
+ require 'merb_merchant/lib/post_data'
74
+ require 'merb_merchant/lib/requires_parameters'
75
+
76
+ # Require the country class
77
+ require 'merb_merchant/lib/country'
78
+
79
+ # Address Verification
80
+ require 'merb_merchant/billing/avs_result'
81
+
82
+ # Card Verfication Code
83
+ require 'merb_merchant/billing/cvv_result'
84
+
85
+ # CreditCard Utility class.
86
+ require 'merb_merchant/billing/credit_card_methods'
87
+ require 'merb_merchant/billing/credit_card_formatting'
88
+ require 'merb_merchant/billing/credit_card'
89
+
90
+ require 'merb_merchant/billing/base'
91
+
92
+ # Require the supported gateways
93
+ require 'merb_merchant/billing/gateways'
94
+
95
+ # Require the supported integrations
96
+ require 'merb_merchant/billing/integrations'
@@ -0,0 +1,95 @@
1
+ module MerbMerchant
2
+ module Billing
3
+ # Implements the Address Verification System
4
+ # https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf
5
+ # http://en.wikipedia.org/wiki/Address_Verification_System
6
+ # http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_IG/html/app_avs_cvn_codes.htm#app_AVS_CVN_codes_7891_48375
7
+ # http://imgserver.skipjack.com/imgServer/5293710/AVS%20and%20CVV2.pdf
8
+ # http://www.emsecommerce.net/avs_cvv2_response_codes.htm
9
+ class AVSResult
10
+ MESSAGES = {
11
+ 'A' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
12
+ 'B' => 'Street address matches, but postal code not verified.',
13
+ 'C' => 'Street address and postal code do not match.',
14
+ 'D' => 'Street address and postal code match.',
15
+ 'E' => 'AVS data is invalid or AVS is not allowed for this card type.',
16
+ 'F' => 'Card member’s name does not match, but billing postal code matches.',
17
+ 'G' => 'Non-U.S. issuing bank does not support AVS.',
18
+ 'H' => 'Card member’s name does not match. Street address and postal code match.',
19
+ 'I' => 'Address not verified.',
20
+ 'J' => 'Card member’s name, billing address, and postal code match. Shipping information verified and chargeback protection guaranteed through the Fraud Protection Program.',
21
+ 'K' => 'Card member’s name matches but billing address and billing postal code do not match.',
22
+ 'L' => 'Card member’s name and billing postal code match, but billing address does not match.',
23
+ 'M' => 'Street address and postal code match.',
24
+ 'N' => 'Street address and postal code do not match.',
25
+ 'O' => 'Card member’s name and billing address match, but billing postal code does not match.',
26
+ 'P' => 'Postal code matches, but street address not verified.',
27
+ 'Q' => 'Card member’s name, billing address, and postal code match. Shipping information verified but chargeback protection not guaranteed.',
28
+ 'R' => 'System unavailable.',
29
+ 'S' => 'U.S.-issuing bank does not support AVS.',
30
+ 'T' => 'Card member’s name does not match, but street address matches.',
31
+ 'U' => 'Address information unavailable.',
32
+ 'V' => 'Card member’s name, billing address, and billing postal code match.',
33
+ 'W' => 'Street address does not match, but 9-digit postal code matches.',
34
+ 'X' => 'Street address and 9-digit postal code match.',
35
+ 'Y' => 'Street address and 5-digit postal code match.',
36
+ 'Z' => 'Street address does not match, but 5-digit postal code matches.'
37
+ }
38
+
39
+ # Map vendor's AVS result code to a postal match code
40
+ POSTAL_MATCH_CODE = {
41
+ 'Y' => %w( D H F H J L M P Q V W X Y Z ),
42
+ 'N' => %w( A C K N O ),
43
+ 'X' => %w( G S ),
44
+ nil => %w( B E I R T U )
45
+ }.inject({}) do |map, (type, codes)|
46
+ codes.each { |code| map[code] = type }
47
+ map
48
+ end
49
+
50
+ # Map vendor's AVS result code to a street match code
51
+ STREET_MATCH_CODE = {
52
+ 'Y' => %w( A B D H J M O Q T V X Y ),
53
+ 'N' => %w( C K L N P W Z ),
54
+ 'X' => %w( G S ),
55
+ nil => %w( E F I R U )
56
+ }.inject({}) do |map, (type, codes)|
57
+ codes.each { |code| map[code] = type }
58
+ map
59
+ end
60
+
61
+ attr_reader :code, :message, :street_match, :postal_match
62
+
63
+ def self.messages
64
+ MESSAGES
65
+ end
66
+
67
+ def initialize(attrs)
68
+ attrs ||= {}
69
+
70
+ @code = attrs[:code].upcase unless attrs[:code].blank?
71
+ @message = self.class.messages[code]
72
+
73
+ if attrs[:street_match].blank?
74
+ @street_match = STREET_MATCH_CODE[code]
75
+ else
76
+ @street_match = attrs[:street_match].upcase
77
+ end
78
+
79
+ if attrs[:postal_match].blank?
80
+ @postal_match = POSTAL_MATCH_CODE[code]
81
+ else
82
+ @postal_match = attrs[:postal_match].upcase
83
+ end
84
+ end
85
+
86
+ def to_hash
87
+ { 'code' => code,
88
+ 'message' => message,
89
+ 'street_match' => street_match,
90
+ 'postal_match' => postal_match
91
+ }
92
+ end
93
+ end
94
+ end
95
+ end