activemerchant-nsp 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/CHANGELOG +952 -0
  2. data/CONTRIBUTORS +347 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +204 -0
  5. data/gem-public_cert.pem +20 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +9 -0
  8. data/lib/active_merchant/billing/avs_result.rb +98 -0
  9. data/lib/active_merchant/billing/base.rb +56 -0
  10. data/lib/active_merchant/billing/check.rb +68 -0
  11. data/lib/active_merchant/billing/credit_card.rb +274 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  15. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  16. data/lib/active_merchant/billing/gateway.rb +176 -0
  17. data/lib/active_merchant/billing/gateways.rb +18 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
  21. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
  22. data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
  23. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
  24. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  25. data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
  26. data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
  27. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  28. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
  30. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  31. data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
  32. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  33. data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
  35. data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
  36. data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
  37. data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
  38. data/lib/active_merchant/billing/gateways/epay.rb +276 -0
  39. data/lib/active_merchant/billing/gateways/eway.rb +287 -0
  40. data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
  41. data/lib/active_merchant/billing/gateways/exact.rb +227 -0
  42. data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
  43. data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
  44. data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
  45. data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
  46. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
  47. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
  48. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
  49. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
  50. data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
  51. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  52. data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
  53. data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
  54. data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
  55. data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
  56. data/lib/active_merchant/billing/gateways/litle.rb +290 -0
  57. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
  58. data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
  59. data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
  60. data/lib/active_merchant/billing/gateways/migs.rb +263 -0
  61. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  62. data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
  63. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
  64. data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
  65. data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
  66. data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
  67. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  68. data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
  69. data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
  71. data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
  72. data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
  73. data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
  74. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
  75. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
  76. data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
  77. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  78. data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
  79. data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
  80. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
  81. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  82. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  83. data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
  84. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  85. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  86. data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
  87. data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
  88. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
  89. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
  90. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
  91. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  92. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
  93. data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
  94. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  95. data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
  96. data/lib/active_merchant/billing/gateways/payway.rb +214 -0
  97. data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
  98. data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
  99. data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
  100. data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
  101. data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
  102. data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
  103. data/lib/active_merchant/billing/gateways/realex.rb +313 -0
  104. data/lib/active_merchant/billing/gateways/sage.rb +148 -0
  105. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  106. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  108. data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
  109. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  110. data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
  111. data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
  112. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  113. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
  114. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  115. data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
  116. data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
  117. data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
  118. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  119. data/lib/active_merchant/billing/gateways/transax.rb +23 -0
  120. data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
  121. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  122. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
  123. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
  124. data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
  125. data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
  126. data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
  127. data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
  128. data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
  129. data/lib/active_merchant/billing/integrations.rb +17 -0
  130. data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
  131. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
  132. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
  133. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
  134. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  135. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  136. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  137. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  138. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  139. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  140. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  141. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  142. data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
  143. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
  144. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
  145. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
  146. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
  147. data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
  148. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
  149. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
  150. data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
  151. data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
  152. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
  153. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
  154. data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
  155. data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
  156. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
  157. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
  158. data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
  159. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
  160. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
  161. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
  162. data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
  163. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
  164. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
  165. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
  166. data/lib/active_merchant/billing/integrations/epay.rb +21 -0
  167. data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
  168. data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
  169. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  170. data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
  171. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  172. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  173. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  174. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  175. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  176. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  177. data/lib/active_merchant/billing/integrations/helper.rb +117 -0
  178. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  179. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  180. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  181. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  182. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  183. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  184. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  185. data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
  186. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
  187. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
  188. data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
  189. data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
  190. data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
  191. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  192. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  193. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  194. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  195. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  196. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  197. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  198. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  199. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  200. data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
  201. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
  202. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
  203. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  204. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  205. data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
  206. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  207. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
  208. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
  209. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  210. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
  211. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  212. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  213. data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
  214. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
  215. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  216. data/lib/active_merchant/billing/integrations/return.rb +42 -0
  217. data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
  218. data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
  219. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
  220. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
  221. data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
  222. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
  223. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
  224. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
  225. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
  226. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
  227. data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
  228. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
  229. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
  230. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  231. data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
  232. data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
  233. data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
  234. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
  235. data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
  236. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
  237. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
  238. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
  239. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  240. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  241. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  242. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  243. data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
  244. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
  245. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
  246. data/lib/active_merchant/billing/response.rb +64 -0
  247. data/lib/active_merchant/version.rb +3 -0
  248. data/lib/activemerchant.rb +1 -0
  249. data/lib/support/gateway_support.rb +65 -0
  250. data/lib/support/outbound_hosts.rb +25 -0
  251. data/lib/support/ssl_verify.rb +93 -0
  252. metadata +482 -0
@@ -0,0 +1,340 @@
1
+ require 'net/http'
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ module Integrations #:nodoc:
5
+
6
+ # # Example:
7
+ # parser = AuthorizeNetSim::Notification.new(request.raw_post)
8
+ # passed = parser.complete?
9
+ #
10
+ # order = Order.find_by_order_number(parser.invoice_num)
11
+ #
12
+ # unless order
13
+ # @message = 'Error--unable to find your transaction! Please contact us directly.'
14
+ # return render :partial => 'authorize_net_sim_payment_response'
15
+ # end
16
+ #
17
+ # if order.total != parser.gross.to_f
18
+ # logger.error "Authorize.Net sim said they paid for #{parser.gross} and it should have been #{order.total}!"
19
+ # passed = false
20
+ # end
21
+ #
22
+ # # Theoretically, Authorize.net will *never* pass us the same transaction
23
+ # # ID twice, but we can double check that... by using
24
+ # # parser.transaction_id, and checking against previous orders' transaction
25
+ # # id's (which you can save when the order is completed)....
26
+ # unless parser.acknowledge MD5_HASH_SET_IN_AUTHORIZE_NET, AUTHORIZE_LOGIN
27
+ # passed = false
28
+ # logger.error "ALERT POSSIBLE FRAUD ATTEMPT either that or you haven't setup your md5 hash setting right in #{__FILE__}
29
+ # because a transaction came back from Authorize.Net with the wrong hash value--rejecting!"
30
+ # end
31
+ #
32
+ # unless parser.cavv_matches? and parser.avs_code_matches?
33
+ # logger.error 'Warning--non matching CC!' + params.inspect
34
+ # # Could fail them here, as well (recommended)...
35
+ # end
36
+ #
37
+ # if passed
38
+ # # Set up your session, and render something that will redirect them to
39
+ # # your site, most likely.
40
+ # else
41
+ # # Render failure or redirect them to your site where you will render failure
42
+ # end
43
+
44
+ module AuthorizeNetSim
45
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
46
+
47
+ def unescape(val) #:nodoc:
48
+ if val
49
+ CGI::unescape val
50
+ else
51
+ val
52
+ end
53
+ end
54
+
55
+ # Passes a hash of the address the user entered in at Authorize.Net
56
+ def billing_address
57
+ all = {}
58
+ [:fax, :city, :company, :last_name, :country, :zip, :first_name, :address, :email, :state].each do |key_out|
59
+ all[key_out] = unescape params['x_' + key_out.to_s]
60
+ end
61
+ all
62
+ end
63
+
64
+ def customer_id
65
+ unescape params['x_cust_id']
66
+ end
67
+
68
+ def auth_code
69
+ unescape params['x_auth_code']
70
+ end
71
+
72
+ def po_num
73
+ unescape params['x_po_num']
74
+ end
75
+
76
+ def ship_to_address
77
+ all = {}
78
+ [:city, :last_name, :first_name, :country, :zip, :address].each do |key_out|
79
+ all[key_out] = unescape params['x_ship_to_' + key_out.to_s]
80
+ end
81
+ all
82
+ end
83
+
84
+ # Tax amount we sent them.
85
+ def tax
86
+ unescape params['x_tax']
87
+ end
88
+
89
+ # Transaction type (probably going to be auth_capture, since that's
90
+ # all we set it as).
91
+ def transaction_type
92
+ unescape params['x_type']
93
+ end
94
+
95
+ # Payment method used--almost always CC (for credit card).
96
+ def method
97
+ unescape params['x_method']
98
+ end
99
+
100
+ # Ff our payment method is available. Almost always "true".
101
+ def method_available
102
+ params['x_method_available']
103
+ end
104
+
105
+ # Invoice num we passed in as invoice_num to them.
106
+ def invoice_num
107
+ item_id
108
+ end
109
+
110
+ # If you pass any values to authorize that aren't its expected, it
111
+ # will pass them back to you verbatim, returned by this method.
112
+ # custom values:
113
+ def all_custom_values_passed_in_and_now_passed_back_to_us
114
+ all = {}
115
+ params.each do |key, value|
116
+ if key[0..1] != 'x_'
117
+ all[key] = unescape value
118
+ end
119
+ end
120
+ all
121
+ end
122
+
123
+ def duty
124
+ unescape params['x_duty']
125
+ end
126
+
127
+ # Shipping we sent them.
128
+ def freight
129
+ unescape params['x_freight']
130
+ end
131
+ alias_method :shipping, :freight
132
+
133
+ def description
134
+ unescape params['x_description']
135
+ end
136
+
137
+ # Returns the response code as a symbol.
138
+ # {'1' => :approved, '2' => :declined, '3' => :error, '4' => :held_for_review}
139
+ def response_code_as_ruby_symbol
140
+ map = {'1' => :approved, '2' => :declined, '3' => :error, '4' => :held_for_review}
141
+ map[params['x_response_code']]
142
+ end
143
+
144
+ def response_reason_text
145
+ unescape params['x_response_reason_text']
146
+ end
147
+
148
+ # The response reason text's numeric id [equivalent--just a number]
149
+ def response_reason_code
150
+ unescape params['x_response_reason_code']
151
+ end
152
+
153
+ # 'used internally by their gateway'
154
+ def response_subcode
155
+ params['x_response_subcode']
156
+ end
157
+
158
+ # They pass back a tax_exempt value.
159
+ def tax_exempt
160
+ params['x_tax_exempt']
161
+ end
162
+
163
+ # avs [address verification] code
164
+ # A = Address (Street)
165
+ # matches, ZIP does not
166
+ # B = Address information
167
+ # not provided for AVS
168
+ # check
169
+ # E = AVS error
170
+ # G = Non-U.S. Card Issuing
171
+ # Bank
172
+ # N = No Match on Address
173
+ # (Street) or ZIP
174
+ # P = AVS not applicable for
175
+ # this transaction
176
+ # R = Retry – System
177
+ # unavailable or timed out
178
+ # S = Service not supported
179
+ # by issuer
180
+ # U = Address information is
181
+ # unavailable
182
+ # W = Nine digit ZIP
183
+ # matches, Address (Street)
184
+ # does not
185
+ # X = Address (Street) and
186
+ # nine digit ZIP match
187
+ # Y = Address (Street) and
188
+ # five digit ZIP match
189
+ # Z = Five digit ZIP matches
190
+ # Address (Street) does not
191
+ def avs_code
192
+ params['x_avs_code']
193
+ end
194
+
195
+ # Returns true if their address completely matched [Y or X, P from
196
+ # #avs_code, which mean 'add+zip match', 'address + 9-zip match', and
197
+ # not applicable, respectively].
198
+ def avs_code_matches?
199
+ return ['Y', 'X', 'P'].include? params['x_avs_code']
200
+ end
201
+
202
+ # cvv2 response
203
+ # M = Match
204
+ # N = No Match
205
+ # P = Not Processed
206
+ # S = Should have been
207
+ # present
208
+ # U = Issuer unable to
209
+ # process request
210
+ def cvv2_resp_code
211
+ params['x_cvv2_resp_code']
212
+ end
213
+
214
+ # check if #cvv2_resp_code == 'm' for Match. otherwise false
215
+ def cvv2_resp_code_matches?
216
+ return ['M'].include? cvv2_resp_code
217
+ end
218
+
219
+ # cavv_response--'cardholder authentication verification response code'--most likely not use for SIM
220
+ # Blank or not present =
221
+ # CAVV not validated
222
+ # 0 = CAVV not validated
223
+ # because erroneous data
224
+ # was submitted
225
+ # 1 = CAVV failed validation
226
+ # 2 = CAVV passed
227
+ # validation
228
+ # 3 = CAVV validation could
229
+ # not be performed; issuer
230
+ # attempt incomplete
231
+ # 4 = CAVV validation could
232
+ # not be performed; issuer
233
+ # system error
234
+ # 5 = Reserved for future
235
+ # use
236
+ # 6 = Reserved for future
237
+ # use
238
+ # 7 = CAVV attempt – failed
239
+ # validation – issuer
240
+ # available (U.S.-issued
241
+ # card/non-U.S acquirer)
242
+ # 8 = CAVV attempt –
243
+ # passed validation – issuer
244
+ # available (U.S.-issued
245
+ # card/non-U.S. acquirer)
246
+ # 9 = CAVV attempt – failed
247
+ # validation – issuer
248
+ def cavv_response
249
+ params['x_cavv_response']
250
+ end
251
+
252
+ # Check if #cavv_response == '', '2', '8' one of those [non failing]
253
+ # [blank means no validated, 2 is passed, 8 is passed issuer
254
+ # available]
255
+ def cavv_matches?
256
+ ['','2','8'].include? cavv_response
257
+ end
258
+
259
+ # Payment is complete -- returns true if x_response_code == '1'
260
+ def complete?
261
+ params["x_response_code"] == '1'
262
+ end
263
+
264
+ # Alias for invoice number--this is the only id they pass back to us
265
+ # that we passed to them, except customer id is also passed back.
266
+ def item_id
267
+ unescape params['x_invoice_num']
268
+ end
269
+
270
+ # They return this number to us [it's unique to Authorize.net].
271
+ def transaction_id
272
+ params['x_trans_id']
273
+ end
274
+
275
+ # When was this payment was received by the client. --unimplemented --
276
+ # always returns nil
277
+ def received_at
278
+ nil
279
+ end
280
+
281
+ # End-user's email
282
+ def payer_email
283
+ unescape params['x_email']
284
+ end
285
+
286
+ # They don't pass merchant email back to us -- unimplemented -- always
287
+ # returns nil
288
+ def receiver_email
289
+ nil
290
+ end
291
+
292
+ # md5 hash used internally
293
+ def security_key
294
+ params['x_MD5_Hash']
295
+ end
296
+
297
+ # The money amount we received in X.2 decimal. Returns a string
298
+ def gross
299
+ unescape params['x_amount']
300
+ end
301
+
302
+ # Was this a test transaction?
303
+ def test?
304
+ params['x_test_request'] == 'true'
305
+ end
306
+
307
+ # #method_available alias
308
+ def status
309
+ complete?
310
+ end
311
+
312
+ # Called to request back and check if it was a valid request.
313
+ # Authorize.net passes us back a hash that includes a hash of our
314
+ # 'unique' MD5 value that we set within their system.
315
+ #
316
+ # Example:
317
+ # acknowledge('my secret md5 hash that I set within Authorize.Net', 'authorize_login')
318
+ #
319
+ # Note this is somewhat unsafe unless you actually set that md5 hash
320
+ # to something (defaults to '' in their system).
321
+ def acknowledge(md5_hash_set_in_authorize_net, authorize_net_login_name)
322
+ Digest::MD5.hexdigest(md5_hash_set_in_authorize_net + authorize_net_login_name + params['x_trans_id'] + gross) == params['x_MD5_Hash'].downcase
323
+ end
324
+
325
+ private
326
+
327
+ # Take the posted data and move the relevant data into a hash.
328
+ def parse(post)
329
+ @raw = post
330
+ post.split('&').each do |line|
331
+ key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
332
+ params[key] = value
333
+ end
334
+ end
335
+
336
+ end
337
+ end
338
+ end
339
+ end
340
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ module Integrations #:nodoc:
5
+ module Bogus
6
+ autoload :Return, 'active_merchant/billing/integrations/bogus/return.rb'
7
+ autoload :Helper, 'active_merchant/billing/integrations/bogus/helper.rb'
8
+ autoload :Notification, 'active_merchant/billing/integrations/bogus/notification.rb'
9
+
10
+ mattr_accessor :service_url
11
+ self.service_url = 'http://www.bogus.com'
12
+
13
+ def self.notification(post, options = {})
14
+ Notification.new(post)
15
+ end
16
+
17
+ def self.return(query_string, options = {})
18
+ Return.new(query_string)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Bogus
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ mapping :account, 'account'
7
+ mapping :order, 'order'
8
+ mapping :amount, 'amount'
9
+ mapping :currency, 'currency'
10
+ mapping :customer, :first_name => 'first_name',
11
+ :last_name => 'last_name'
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Bogus
5
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
6
+
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Bogus
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ module Integrations #:nodoc:
5
+ module Chronopay
6
+ autoload :Return, 'active_merchant/billing/integrations/chronopay/return.rb'
7
+ autoload :Helper, 'active_merchant/billing/integrations/chronopay/helper.rb'
8
+ autoload :Notification, 'active_merchant/billing/integrations/chronopay/notification.rb'
9
+
10
+ mattr_accessor :service_url
11
+ self.service_url = 'https://secure.chronopay.com/index_shop.cgi'
12
+
13
+ def self.notification(post, options = {})
14
+ Notification.new(post)
15
+ end
16
+
17
+ def self.return(query_string, options = {})
18
+ Return.new(query_string)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,120 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Chronopay
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ # All currently supported checkout languages:
7
+ # es (Spanish)
8
+ # en (English)
9
+ # de (German)
10
+ # pt (Portuguese)
11
+ # lv (Latvian)
12
+ # cn1 (Chinese Version 1)
13
+ # cn2 (Chinese version 2)
14
+ # nl (Dutch)
15
+ # ru (Russian)
16
+ COUNTRIES_FOR_LANG = {
17
+ 'ES' => %w( AR BO CL CO CR CU DO EC SV GQ GT HN MX NI PA PY PE ES UY VE),
18
+ 'DE' => %w( DE AT CH LI ),
19
+ 'PT' => %w( AO BR CV GW MZ PT ST TL),
20
+ 'RU' => %w( BY KG KZ RU ),
21
+ 'LV' => %w( LV ),
22
+ 'CN1' => %w( CN ),
23
+ 'NL' => %w( NL )
24
+ }
25
+
26
+ LANG_FOR_COUNTRY = COUNTRIES_FOR_LANG.inject(Hash.new("EN")) do |memo, (lang, countries)|
27
+ countries.each do |code|
28
+ memo[code] = lang
29
+ end
30
+ memo
31
+ end
32
+
33
+
34
+ self.country_format = :alpha3
35
+
36
+ def initialize(order, account, options = {})
37
+ super
38
+ add_field('cb_type', 'p')
39
+ end
40
+
41
+ # product_id
42
+ mapping :account, 'product_id'
43
+ # product_name
44
+ mapping :invoice, 'product_name'
45
+ # product_price
46
+ mapping :amount, 'product_price'
47
+ # product_price_currency
48
+ mapping :currency, 'product_price_currency'
49
+
50
+ # f_name
51
+ # s_name
52
+ # email
53
+ mapping :customer, :first_name => 'f_name',
54
+ :last_name => 's_name',
55
+ :phone => 'phone',
56
+ :email => 'email'
57
+
58
+ # city
59
+ # street
60
+ # state
61
+ # zip
62
+ # country - The country must be a 3 digit country code
63
+ # phone
64
+
65
+ mapping :billing_address, :city => 'city',
66
+ :address1 => 'street',
67
+ :state => 'state',
68
+ :zip => 'zip',
69
+ :country => 'country'
70
+
71
+ def billing_address(mapping = {})
72
+ # Gets the country code in the appropriate format or returns what we were given
73
+ # The appropriate format for Chronopay is the alpha 3 country code
74
+ country_code = lookup_country_code(mapping.delete(:country))
75
+ add_field(mappings[:billing_address][:country], country_code)
76
+
77
+ countries_with_supported_states = ['USA', 'CAN']
78
+ if !countries_with_supported_states.include?(country_code)
79
+ mapping.delete(:state)
80
+ add_field(mappings[:billing_address][:state], 'XX')
81
+ end
82
+ mapping.each do |k, v|
83
+ field = mappings[:billing_address][k]
84
+ add_field(field, v) unless field.nil?
85
+ end
86
+ add_field('language', checkout_language_from_country(country_code))
87
+ end
88
+
89
+ # card_no
90
+ # exp_month
91
+ # exp_year
92
+ mapping :credit_card, :number => 'card_no',
93
+ :expiry_month => 'exp_month',
94
+ :expiry_year => 'exp_year'
95
+
96
+ # cb_url
97
+ mapping :notify_url, 'cb_url'
98
+
99
+ # cs1
100
+ mapping :order, 'cs1'
101
+
102
+ # cs2
103
+ # cs3
104
+ # decline_url
105
+
106
+
107
+ private
108
+
109
+ def checkout_language_from_country(country_code)
110
+ country = Country.find(country_code)
111
+ short_code = country.code(:alpha2).to_s
112
+ LANG_FOR_COUNTRY[short_code]
113
+ rescue InvalidCountryCodeError
114
+ 'EN'
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end