swiss-activemerchant 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +4033 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +249 -0
  6. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +48 -0
  9. data/lib/active_merchant/billing/check.rb +112 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +451 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +332 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
  17. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  18. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  19. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  23. data/lib/active_merchant/billing/gateways/axcessms.rb +243 -0
  24. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  25. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  26. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  27. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  28. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  29. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  30. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  31. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
  33. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  34. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  35. data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
  36. data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
  37. data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
  38. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  39. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
  40. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  41. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
  43. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  44. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  45. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  46. data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
  52. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  53. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  54. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  59. data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
  60. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  61. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  62. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  63. data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
  64. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  65. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  66. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  67. data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
  68. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  69. data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
  70. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  71. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  72. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  73. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  74. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  75. data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
  76. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
  78. data/lib/active_merchant/billing/gateways/element.rb +406 -0
  79. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  80. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  81. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  82. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  83. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  84. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  85. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  86. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  87. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  88. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  89. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  90. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  91. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  92. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  93. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  94. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  95. data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
  96. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  97. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  98. data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
  99. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  100. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  101. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  102. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  103. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  104. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  105. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  106. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  107. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  108. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  109. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
  111. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  112. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  113. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  114. data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
  115. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  116. data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
  117. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  118. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  119. data/lib/active_merchant/billing/gateways/litle.rb +643 -0
  120. data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
  121. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  122. data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
  123. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
  124. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  125. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  126. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  127. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  128. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  129. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  130. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  131. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  132. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  133. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  134. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  135. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  136. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  137. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  138. data/lib/active_merchant/billing/gateways/monei.rb +424 -0
  139. data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
  140. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  141. data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
  142. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  143. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  144. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  145. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  146. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  147. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  148. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  149. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  150. data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
  151. data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
  152. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  153. data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
  154. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  155. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  156. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  157. data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
  158. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  160. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  161. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  162. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  163. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  164. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  165. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  166. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  167. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  168. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  169. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  170. data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
  171. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  172. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  173. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  174. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  175. data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
  176. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  177. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  178. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  179. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  180. data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
  181. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  182. data/lib/active_merchant/billing/gateways/paynetworx.rb +227 -0
  183. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  184. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
  185. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  186. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  187. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  188. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  189. data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
  190. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  191. data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
  192. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  193. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  194. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  195. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  196. data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
  197. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  198. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  199. data/lib/active_merchant/billing/gateways/pin.rb +273 -0
  200. data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
  201. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  202. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  203. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  204. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  205. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  206. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  207. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  208. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  210. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  211. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  212. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  213. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  214. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  215. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  216. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  217. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  218. data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
  219. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  220. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  221. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  222. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  223. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  224. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  225. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  226. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  227. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  228. data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
  229. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  230. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  231. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  232. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  233. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  234. data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
  235. data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
  236. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
  237. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  238. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  239. data/lib/active_merchant/billing/gateways/tns.rb +23 -0
  240. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  241. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  242. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  243. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  244. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  245. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  246. data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
  247. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  248. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  249. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
  250. data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
  251. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  252. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  253. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  254. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  255. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  256. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  257. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  258. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  259. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  260. data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
  261. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  262. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  263. data/lib/active_merchant/billing/gateways.rb +14 -0
  264. data/lib/active_merchant/billing/model.rb +30 -0
  265. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  266. data/lib/active_merchant/billing/payment_token.rb +21 -0
  267. data/lib/active_merchant/billing/rails.rb +3 -0
  268. data/lib/active_merchant/billing/response.rb +120 -0
  269. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  270. data/lib/active_merchant/billing.rb +16 -0
  271. data/lib/active_merchant/connection.rb +194 -0
  272. data/lib/active_merchant/country.rb +338 -0
  273. data/lib/active_merchant/empty.rb +20 -0
  274. data/lib/active_merchant/errors.rb +38 -0
  275. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  276. data/lib/active_merchant/network_connection_retries.rb +78 -0
  277. data/lib/active_merchant/post_data.rb +26 -0
  278. data/lib/active_merchant/posts_data.rb +92 -0
  279. data/lib/active_merchant/version.rb +3 -0
  280. data/lib/active_merchant.rb +63 -0
  281. data/lib/activemerchant.rb +1 -0
  282. data/lib/certs/cacert.pem +3214 -0
  283. data/lib/support/gateway_support.rb +69 -0
  284. data/lib/support/outbound_hosts.rb +28 -0
  285. data/lib/support/ssl_verify.rb +88 -0
  286. data/lib/support/ssl_version.rb +86 -0
  287. metadata +506 -0
data/README.md ADDED
@@ -0,0 +1,249 @@
1
+ # Active Merchant
2
+ [![Build Status](https://github.com/activemerchant/active_merchant/workflows/CI/badge.svg?branch=master)](https://github.com/activemerchant/active_merchant/actions?query=workflow%3ACI)
3
+ [![Code Climate](https://codeclimate.com/github/activemerchant/active_merchant.svg)](https://codeclimate.com/github/activemerchant/active_merchant)
4
+
5
+ Active Merchant is an extraction from the ecommerce system [Shopify](http://www.shopify.com).
6
+ Shopify's requirements for a simple and unified API to access dozens of different payment
7
+ gateways with very different internal APIs was the chief principle in designing the library.
8
+
9
+ It was developed for usage in Ruby on Rails web applications and integrates seamlessly
10
+ as a Rails plugin, but it also works excellently as a stand alone Ruby library.
11
+
12
+ Active Merchant has been in production use since June 2006 and is now used in most modern
13
+ Ruby applications which deal with financial transactions. It is maintained by the
14
+ [Shopify](http://www.shopify.com) and [Spreedly](https://spreedly.com) teams, with much help
15
+ from an ever-growing set of contributors.
16
+
17
+ See [GettingStarted.md](GettingStarted.md) if you want to learn more about using Active Merchant in your
18
+ applications.
19
+
20
+ If you'd like to contribute to Active Merchant, please start with our [Contribution Guide](https://github.com/activemerchant/active_merchant/wiki/Contributing).
21
+
22
+ ## Installation
23
+
24
+ ### From Git
25
+
26
+ You can check out the latest source from git:
27
+
28
+ git clone git://github.com/activemerchant/active_merchant.git
29
+
30
+ ### From RubyGems
31
+
32
+ Installation from RubyGems:
33
+
34
+ ```console
35
+ gem install activemerchant
36
+ ```
37
+
38
+ Or, if you're using Bundler, just add the following to your Gemfile:
39
+
40
+ ```ruby
41
+ gem 'activemerchant'
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ This simple example demonstrates how a purchase can be made using a person's
47
+ credit card details.
48
+
49
+ ```ruby
50
+ require 'active_merchant'
51
+
52
+ # Use the TrustCommerce test servers
53
+ ActiveMerchant::Billing::Base.mode = :test
54
+
55
+ gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
56
+ :login => 'TestMerchant',
57
+ :password => 'password')
58
+
59
+ # ActiveMerchant accepts all amounts as Integer values in cents
60
+ amount = 1000 # $10.00
61
+
62
+ # The card verification value is also known as CVV2, CVC2, or CID
63
+ credit_card = ActiveMerchant::Billing::CreditCard.new(
64
+ :first_name => 'Bob',
65
+ :last_name => 'Bobsen',
66
+ :number => '4242424242424242',
67
+ :month => '8',
68
+ :year => Time.now.year+1,
69
+ :verification_value => '000')
70
+
71
+ # Validating the card automatically detects the card type
72
+ if credit_card.validate.empty?
73
+ # Capture $10 from the credit card
74
+ response = gateway.purchase(amount, credit_card)
75
+
76
+ if response.success?
77
+ puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
78
+ else
79
+ raise StandardError, response.message
80
+ end
81
+ end
82
+ ```
83
+
84
+ ## Contributing
85
+
86
+ For more in-depth documentation and tutorials, see [GettingStarted.md](GettingStarted.md) and the
87
+ [API documentation](http://www.rubydoc.info/github/activemerchant/active_merchant/).
88
+
89
+ Emerging ActiveMerchant 3DS conventions are documented in the [Contributing](https://github.com/activemerchant/active_merchant/wiki/Contributing#3ds-options)
90
+ guide and [Standardized 3DS Fields](https://github.com/activemerchant/active_merchant/wiki/Standardized-3DS-Fields) guide of the wiki.
91
+
92
+ ## Supported Payment Gateways
93
+
94
+ The [ActiveMerchant Wiki](https://github.com/activemerchant/active_merchant/wikis) contains a [table of features supported by each gateway](https://github.com/activemerchant/active_merchant/wiki/Gateway-Feature-Matrix).
95
+
96
+ * [Adyen](https://www.adyen.com/) - US, AT, AU, BE, BG, BR, CH, CY, CZ, DE, DK, EE, ES, FI, FR, GB, GI, GR, HK, HU, IE, IS, IT, LI, LT, LU, LV, MC, MT, MX, NL, NO, PL, PT, RO, SE, SG, SK, SI
97
+ * [Authorize.Net CIM](http://www.authorize.net/) - US
98
+ * [Authorize.Net](http://www.authorize.net/) - AU, CA, US
99
+ * [Axcess MS](http://www.axcessms.com/) - AD, AT, BE, BG, BR, CA, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HR, HU, IE, IL, IM, IS, IT, LI, LT, LU, LV, MC, MT, MX, NL, NO, PL, PT, RO, RU, SE, SI, SK, TR, US, VA
100
+ * [Balanced](https://www.balancedpayments.com/) - US
101
+ * [Bambora Asia-Pacific](http://www.bambora.com/) - AU, NZ
102
+ * [Bank Frick](http://www.bankfrickacquiring.com/) - LI, US
103
+ * [Banwire](http://www.banwire.com/) - MX
104
+ * [Barclays ePDQ Extra Plus](http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/) - GB
105
+ * [Be2Bill](http://www.be2bill.com/) - FR
106
+ * [Beanstream.com](http://www.beanstream.com/) - CA, US
107
+ * [BluePay](http://www.bluepay.com/) - US
108
+ * [Borgun](https://www.borgun.is/) - IS
109
+ * [Braintree](https://www.braintreepayments.com) - US, CA, AU, AD, AT, BE, BG, CY, CZ, DK, EE, FI, FR, GI, DE, GR, HU, IS, IM, IE, IT, LV, LI, LT, LU, MT, MC, NL, NO, PL, PT, RO, SM, SK, SI, ES, SE, CH, TR, GB
110
+ * [BridgePay](http://www.bridgepaynetwork.com/) - CA, US
111
+ * [Cardknox](https://www.cardknox.com/) - US, CA, GB
112
+ * [CardSave](http://www.cardsave.net/) - GB
113
+ * [CardStream](http://www.cardstream.com/) - GB
114
+ * [Cashnet](http://www.higherone.com/) - US
115
+ * [Cecabank](http://www.ceca.es/es/) - ES
116
+ * [Cenpos](https://www.cenpos.com/) - AD, AI, AG, AR, AU, AT, BS, BB, BE, BZ, BM, BR, BN, BG, CA, HR, CY, CZ, DK, DM, EE, FI, FR, DE, GR, GD, GY, HK, HU, IS, IN, IL, IT, JP, LV, LI, LT, LU, MY, MT, MX, MC, MS, NL, PA, PL, PT, KN, LC, MF, VC, SM, SG, SK, SI, ZA, ES, SR, SE, CH, TR, GB, US, UY
117
+ * [CAMS: Central Account Management System](https://www.centralams.com/) - US
118
+ * [Checkout.com](https://www.checkout.com/) - AD, AE, AR, AT, AU, BE, BG, BH, BR, CH, CL, CN, CO, CY, CZ, DE, DK, EE, EG, ES, FI, FR, GB, GR, HK, HR, HU, IE, IS, IT, JO, JP, KW, LI, LT, LU, LV, MC, MT, MX, MY, NL, NO, NZ, OM, PE, PL, PT, QA, RO, SA, SE, SG, SI, SK, SM, TR, US
119
+ * [Clearhaus](https://www.clearhaus.com) - AD, AT, BE, BG, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GL, GR, HR, HU, IE, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE, SI, SK
120
+ * [Commercegate](http://www.commercegate.com/) - AD, AT, AX, BE, BG, CH, CY, CZ, DE, DK, ES, FI, FR, GB, GG, GI, GR, HR, HU, IE, IM, IS, IT, JE, LI, LT, LU, LV, MC, MT, NL, NO, PL, PT, RO, SE, SI, SK, VA
121
+ * [Conekta](https://conekta.io) - MX
122
+ * [CyberSource](http://www.cybersource.com) - US, BR, CA, CN, DK, FI, FR, DE, JP, MX, NO, SE, GB, SG
123
+ * [DIBS](http://www.dibspayment.com/) - US, FI, NO, SE, GB
124
+ * [DataCash](http://www.datacash.com/) - GB
125
+ * [Efsnet](http://www.concordefsnet.com/) - US
126
+ * [Elavon MyVirtualMerchant](http://www.elavon.com/) - US, CA
127
+ * [ePay](http://epay.dk/) - DK, SE, NO
128
+ * [EVO Canada](http://www.evocanada.com/) - CA
129
+ * [eWAY](http://www.eway.com.au/) - AU, NZ, GB
130
+ * [eWAY Rapid](http://www.eway.com.au/) - AU, NZ, GB, SG
131
+ * [E-xact](http://www.e-xact.com) - CA, US
132
+ * [Ezic](http://www.ezic.com/) - AU, CA, CN, FR, DE, GI, IL, MT, MU, MX, NL, NZ, PA, PH, RU, SG, KR, ES, KN, GB
133
+ * [Fat Zebra](https://www.fatzebra.com.au/) - AU
134
+ * [Federated Canada](http://www.federatedcanada.com/) - CA
135
+ * [Finansbank WebPOS](https://www.fbwebpos.com/) - US, TR
136
+ * [Flo2Cash](http://www.flo2cash.co.nz/) - NZ
137
+ * [1stPayGateway.Net](http://1stpaygateway.net/) - US
138
+ * [FirstData Global Gateway e4](http://www.firstdata.com) - CA, US
139
+ * [FirstGiving](http://www.firstgiving.com/) - US
140
+ * [Garanti Sanal POS](https://sanalposweb.garanti.com.tr) - US, TR
141
+ * [Global Transport](https://www.globalpaymentsinc.com) - CA, PR, US
142
+ * [HDFC](http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i) - IN
143
+ * [Heartland Payment Systems](http://developer.heartlandpaymentsystems.com/SecureSubmit/) - US
144
+ * [iATS Payments](http://home.iatspayments.com/) - AU, BR, CA, CH, DE, DK, ES, FI, FR, GR, HK, IE, IT, NL, NO, PT, SE, SG, TR, UK, US
145
+ * [Inspire Commerce](http://www.inspiregateway.com) - US
146
+ * [InstaPay](http://www.instapayllc.com) - US
147
+ * [IPP](http://www.ippayments.com.au/) - AU
148
+ * [Iridium](http://www.iridiumcorp.co.uk/) - GB, ES
149
+ * [iTransact](http://www.itransact.com/) - US
150
+ * [JetPay](http://www.jetpay.com/) - US
151
+ * [Komoju](http://www.komoju.com/) - JP
152
+ * [LinkPoint](http://www.linkpoint.com/) - US
153
+ * [Litle & Co.](http://www.litle.com/) - US
154
+ * [maxiPago!](http://www.maxipago.com/) - BR
155
+ * [Merchant e-Solutions](http://www.merchante-solutions.com/) - US
156
+ * [Merchant One Gateway](http://merchantone.com/) - US
157
+ * [MerchantWARE](http://merchantwarehouse.com/merchantware) - US
158
+ * [MerchantWarrior](http://www.merchantwarrior.com/) - AU
159
+ * [Mercury](http://www.mercurypay.com) - US, CA
160
+ * [Metrics Global](http://www.metricsglobal.com) - US
161
+ * [MasterCard Internet Gateway Service (MiGS)](http://mastercard.com/mastercardsps) - AU, AE, BD, BN, EG, HK, ID, IN, JO, KW, LB, LK, MU, MV, MY, NZ, OM, PH, QA, SA, SG, TT, VN
162
+ * [Modern Payments](http://www.modpay.com) - US
163
+ * [MONEI](http://www.monei.com/) - AD, AT, BE, BG, CA, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HU, IE, IL, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE, SI, SK, TR, US, VA
164
+ * [Moneris](http://www.moneris.com/) - CA
165
+ * [MoneyMovers](http://mmoa.us/) - US
166
+ * [NAB Transact](http://transact.nab.com.au) - AU
167
+ * [NELiX TransaX](https://www.nelixtransax.com/) - US
168
+ * [NetRegistry](http://www.netregistry.com.au) - AU
169
+ * [BBS Netaxept](http://www.betalingsterminal.no/Netthandel-forside/) - NO, DK, SE, FI
170
+ * [NETbilling](http://www.netbilling.com) - US
171
+ * [NETPAY Gateway](http://www.netpay.com.mx) - MX
172
+ * [NMI](http://nmi.com/) - US
173
+ * [Ogone](http://www.ogone.com/) - BE, DE, FR, NL, AT, CH
174
+ * [Omise](https://www.omise.co/) - TH, JP
175
+ * [Openpay](Openpay) - MX
176
+ * [Optimal Payments](http://www.optimalpayments.com/) - CA, US, GB
177
+ * [Orbital Paymentech](http://chasepaymentech.com/) - US, CA
178
+ * [Pagar.me](https://pagar.me/) - BR
179
+ * [PagoFacil](http://www.pagofacil.net/) - MX
180
+ * [PayConex](http://www.bluefincommerce.com/) - US, CA
181
+ * [PayGate PayXML](http://paygate.co.za/) - US, ZA
182
+ * [PayHub](http://www.payhub.com/) - US
183
+ * [PayJunction](http://www.payjunction.com/) - US
184
+ * [PaySecure](http://www.commsecure.com.au/paysecure.shtml) - AU
185
+ * [Paybox Direct](http://www.paybox.com/) - FR
186
+ * [Payeezy](https://developer.payeezy.com/) - CA, US
187
+ * [Payex](http://payex.com/) - DK, FI, NO, SE
188
+ * [Windcave (formerly PaymentExpress)](https://www.windcave.com/) - AU, CA, DE, ES, FR, GB, HK, IE, MY, NL, NZ, SG, US, ZA
189
+ * [PAYMILL](https://paymill.com) - AD, AT, BE, BG, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HU, IE, IL, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE, SI, SK, TR, VA
190
+ * [PayPal Express Checkout](https://www.paypal.com/webapps/mpp/express-checkout) - US, CA, SG, AU
191
+ * [PayPal Express Checkout (UK)](https://www.paypal.com/uk/webapps/mpp/express-checkout) - GB
192
+ * [PayPal Payflow Pro](https://www.paypal.com/webapps/mpp/payflow-payment-gateway) - US, CA, SG, AU
193
+ * [PayPal Payments Pro (US)](https://www.paypal.com/us/webapps/mpp/paypal-payments-pro) - US
194
+ * [PayPal Payments Pro (UK)](https://www.paypal.com/uk/webapps/mpp/pro) - GB
195
+ * [PayPal Website Payments Pro (CA)](https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside) - CA
196
+ * [PayPal Express Checkout for Digital Goods](https://www.x.com/community/ppx/xspaces/digital_goods) - AU, CA, CN, FI, GB, ID, IN, IT, MY, NO, NZ, PH, PL, SE, SG, TH, VN
197
+ * [Payscout](http://www.payscout.com/) - US
198
+ * [Paystation](http://paystation.co.nz) - NZ
199
+ * [Pay Way](http://www.payway.com.au) - AU
200
+ * [PayU India](https://www.payu.in/) - IN
201
+ * [Pin Payments](http://www.pinpayments.com/) - AU
202
+ * [Plug'n Pay](http://www.plugnpay.com/) - US
203
+ * [Psigate](http://www.psigate.com/) - CA
204
+ * [PSL Payment Solutions](http://www.paymentsolutionsltd.com/) - GB
205
+ * [QuickBooks Merchant Services](http://payments.intuit.com/) - US
206
+ * [QuickBooks Payments](http://payments.intuit.com/) - US
207
+ * [Quantum Gateway](http://www.quantumgateway.com) - US
208
+ * [QuickPay](http://quickpay.net/) - AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GB, GR, HR, HU, IE, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE SI, SK
209
+ * [Qvalent](https://www.qvalent.com/) - AU
210
+ * [Raven](http://www.deepcovelabs.com/raven) - AI, AN, AT, AU, BE, BG, BS, BZ, CA, CH, CR, CY, CZ, DE, DK, DM, DO, EE, EL, ES, FI, FR, GB, GG, GI, HK, HR, HU, IE, IL, IM, IN, IT, JE, KN, LI, LT, LU, LV, MH, MT, MY, NL, NO, NZ, PA, PE, PH, PL, PT, RO, RS, SC, SE, SG, SI, SK, UK, US, VG, ZA
211
+ * [Realex](http://www.realexpayments.com/) - IE, GB, FR, BE, NL, LU, IT
212
+ * [Redsys](http://www.redsys.es/) - ES
213
+ * [S5](http://www.s5.dk/) - DK
214
+ * [SagePay](http://www.sagepay.com) - GB, IE
215
+ * [Sage Payment Solutions](http://www.sagepayments.com) - US, CA
216
+ * [Sallie Mae](http://www.salliemae.com/) - US
217
+ * [SecureNet](http://www.securenet.com/) - US
218
+ * [SecurePay](http://www.securepay.com/) - US, CA, GB, AU
219
+ * [SecurePayTech](http://www.securepaytech.com/) - NZ
220
+ * [SecurionPay](https://securionpay.com/) - AD, BE, BG, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GI, GL, GR, GS, GT, HR, HU, IE, IS, IT, LI, LR, LT, LU, LV, MC, MT, MU, MV, MW, NL, NO, PL, RO, SE, SI
221
+ * [SkipJack](http://www.skipjack.com/) - US, CA
222
+ * [SoEasyPay](http://www.soeasypay.com/) - US, CA, AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IE, IT, LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, SE, GB, IS, NO, CH
223
+ * [Spreedly](https://spreedly.com) - AD, AE, AT, AU, BD, BE, BG, BN, CA, CH, CY, CZ, DE, DK, EE, EG, ES, FI, FR, GB, GI, GR, HK, HU, ID, IE, IL, IM, IN, IS, IT, JO, KW, LB, LI, LK, LT, LU, LV, MC, MT, MU, MV, MX, MY, NL, NO, NZ, OM, PH, PL, PT, QA, RO, SA, SE, SG, SI, SK, SM, TR, TT, UM, US, VA, VN, ZA
224
+ * [Stripe](https://stripe.com/) - AT, AU, BE, CA, CH, DE, DK, ES, FI, FR, GB, IE, IT, LU, NL, NO, SE, SG, US
225
+ * [Swipe](https://www.swipehq.com/checkout) - CA, NZ
226
+ * [TNS](http://www.tnsi.com/) - AR, AU, BR, FR, DE, HK, MX, NZ, SG, GB, US
227
+ * [Transact Pro](https://www.transactpro.lv/business/online-payments-acceptance) - US
228
+ * [TransFirst](http://www.transfirst.com/) - US
229
+ * [Transnational](http://www.tnbci.com/) - US
230
+ * [Trexle](https://trexle.com) - AD, AE, AT, AU, BD, BE, BG, BN, CA, CH, CY, CZ, DE, DK, EE, EG, ES, FI, FR, GB, GI, GR, HK, HU, ID, IE, IL, IM, IN, IS, IT, JO, KW, LB, LI, LK, LT, LU, LV, MC, MT, MU, MV, MX, MY, NL, NO, NZ, OM, PH, PL, PT, QA, RO, SA, SE, SG, SI, SK, SM, TR, TT, UM, US, VA, VN, ZA
231
+ * [TrustCommerce](http://www.trustcommerce.com/) - US
232
+ * [USA ePay](http://www.usaepay.com/) - US
233
+ * [Vanco Payment Solutions](http://vancopayments.com/) - US
234
+ * [Verifi](http://www.verifi.com/) - US
235
+ * [ViaKLIX](http://viaklix.com) - US
236
+ * [WebPay](https://webpay.jp/) - JP
237
+ * [WePay](https://www.wepay.com/) - US
238
+ * [Wirecard](http://www.wirecard.com) - AD, CY, GI, IM, MT, RO, CH, AT, DK, GR, IT, MC, SM, TR, BE, EE, HU, LV, NL, SK, GB, BG, FI, IS, LI, NO, SI, VA, FR, IL, LT, PL, ES, CZ, DE, IE, LU, PT, SE
239
+ * [Worldpay Global](http://www.worldpay.com/) - HK, GB, AU, AD, BE, CH, CY, CZ, DE, DK, ES, FI, FR, GI, GR, HU, IE, IL, IT, LI, LU, MC, MT, NL, NO, NZ, PL, PT, SE, SG, SI, SM, TR, UM, VA
240
+ * [Worldpay Online](https://online.worldpay.com/) - HK, US, GB, AU, AD, BE, CH, CY, CZ, DE, DK, ES, FI, FR, GI, GR, HU, IE, IL, IT, LI, LU, MC, MT, NL, NO, NZ, PL, PT, SE, SG, SI, SM, TR, UM, VA
241
+ * [Worldpay US](http://www.worldpay.com/us) - US
242
+
243
+ ## API stability policy
244
+
245
+ Functionality or APIs that are deprecated will be marked as such. Deprecated functionality is removed on major version changes - for example, deprecations from 2.x are removed in 3.x.
246
+
247
+ ## Ruby and Rails compatibility policies
248
+
249
+ Because Active Merchant is a payment library, it needs to take security seriously. For this reason, Active Merchant guarantees compatibility only with actively supported versions of Ruby and Rails. At the time of this writing, that means that Ruby 2.5+ and Rails 5.0+ are supported.
@@ -0,0 +1,22 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class ApplePayPaymentToken < PaymentToken
4
+ # This is a representation of the token object specified here:
5
+ # https://developer.apple.com/library/ios/documentation/PassKit/Reference/PKPaymentToken_Ref/
6
+ # https://developer.apple.com/library/IOs//documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
7
+
8
+ attr_reader :payment_instrument_name, :payment_network
9
+ attr_accessor :transaction_identifier
10
+
11
+ def initialize(payment_data, options = {})
12
+ super
13
+ @payment_instrument_name = @metadata[:payment_instrument_name]
14
+ @payment_network = @metadata[:payment_network]
15
+ end
16
+
17
+ def type
18
+ 'apple_pay'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+
3
+ module ActiveMerchant
4
+ module Billing
5
+ # Implements the Address Verification System
6
+ # https://www.cybersource.com/developers/other_resources/quick_references/avs_results/.
7
+ # http://en.wikipedia.org/wiki/Address_Verification_System
8
+ # http://www.emsecommerce.net/avs_cvv2_response_codes.htm
9
+ # https://www.cardfellow.com/blog/address-verification-service-avs/
10
+ class AVSResult
11
+ MESSAGES = {
12
+ 'A' => 'Street address matches, but postal code does not match.',
13
+ 'B' => 'Street address matches, but postal code not verified.',
14
+ 'C' => 'Street address and postal code do not match.',
15
+ 'D' => 'Street address and postal code match.',
16
+ 'E' => 'AVS data is invalid or AVS is not allowed for this card type.',
17
+ 'F' => 'Card member\'s name does not match, but billing postal code matches.',
18
+ 'G' => 'Non-U.S. issuing bank does not support AVS.',
19
+ 'H' => 'Card member\'s name does not match. Street address and postal code match.',
20
+ 'I' => 'Address not verified.',
21
+ 'J' => 'Card member\'s name, billing address, and postal code match. Shipping information verified and chargeback protection guaranteed through the Fraud Protection Program.',
22
+ 'K' => 'Card member\'s name matches but billing address and billing postal code do not match.',
23
+ 'L' => 'Card member\'s name and billing postal code match, but billing address does not match.',
24
+ 'M' => 'Street address and postal code match.',
25
+ 'N' => 'Street address and postal code do not match. For American Express: Card member\'s name, street address and postal code do not match.',
26
+ 'O' => 'Card member\'s name and billing address match, but billing postal code does not match.',
27
+ 'P' => 'Postal code matches, but street address not verified.',
28
+ 'Q' => 'Card member\'s name, billing address, and postal code match. Shipping information verified but chargeback protection not guaranteed.',
29
+ 'R' => 'System unavailable.',
30
+ 'S' => 'U.S.-issuing bank does not support AVS.',
31
+ 'T' => 'Card member\'s name does not match, but street address matches.',
32
+ 'U' => 'Address information unavailable.',
33
+ 'V' => 'Card member\'s name, billing address, and billing postal code match.',
34
+ 'W' => 'Street address does not match, but 9-digit postal code matches.',
35
+ 'X' => 'Street address and 9-digit postal code match.',
36
+ 'Y' => 'Street address and 5-digit postal code match.',
37
+ 'Z' => 'Street address does not match, but 5-digit postal code matches.'
38
+ }
39
+
40
+ # Map vendor's AVS result code to a postal match code
41
+ POSTAL_MATCH_CODE = {
42
+ 'Y' => %w(D H F H J L M P Q V W X Y Z),
43
+ 'N' => %w(A C K N O),
44
+ 'X' => %w(G S),
45
+ nil => %w(B E I R T U)
46
+ }.inject({}) do |map, (type, codes)|
47
+ codes.each { |code| map[code] = type }
48
+ map
49
+ end
50
+
51
+ # Map vendor's AVS result code to a street match code
52
+ STREET_MATCH_CODE = {
53
+ 'Y' => %w(A B D H J M O Q T V X Y),
54
+ 'N' => %w(C K L N W Z),
55
+ 'X' => %w(G S),
56
+ nil => %w(E F I P R U)
57
+ }.inject({}) do |map, (type, codes)|
58
+ codes.each { |code| map[code] = type }
59
+ map
60
+ end
61
+
62
+ attr_reader :code, :message, :street_match, :postal_match
63
+
64
+ def self.messages
65
+ MESSAGES
66
+ end
67
+
68
+ def initialize(attrs)
69
+ attrs ||= {}
70
+
71
+ @code = attrs[:code].upcase unless attrs[:code].blank?
72
+ @message = self.class.messages[code]
73
+
74
+ if attrs[:street_match].blank?
75
+ @street_match = STREET_MATCH_CODE[code]
76
+ else
77
+ @street_match = attrs[:street_match].upcase
78
+ end
79
+
80
+ if attrs[:postal_match].blank?
81
+ @postal_match = POSTAL_MATCH_CODE[code]
82
+ else
83
+ @postal_match = attrs[:postal_match].upcase
84
+ end
85
+ end
86
+
87
+ def to_hash
88
+ { 'code' => code,
89
+ 'message' => message,
90
+ 'street_match' => street_match,
91
+ 'postal_match' => postal_match }
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,48 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Base
4
+ GATEWAY_MODE_DEPRECATION_MESSAGE = 'Base#gateway_mode is deprecated in favor of Base#mode and will be removed in a future version'
5
+
6
+ # Set ActiveMerchant gateways in test mode.
7
+ #
8
+ # ActiveMerchant::Billing::Base.mode = :test
9
+ mattr_accessor :mode
10
+
11
+ def self.gateway_mode=(mode)
12
+ ActiveMerchant.deprecated(GATEWAY_MODE_DEPRECATION_MESSAGE)
13
+ @@mode = mode
14
+ end
15
+
16
+ def self.gateway_mode
17
+ ActiveMerchant.deprecated(GATEWAY_MODE_DEPRECATION_MESSAGE)
18
+ @@mode
19
+ end
20
+
21
+ self.mode = :production
22
+
23
+ # Return the matching gateway for the provider
24
+ # * <tt>bogus</tt>: BogusGateway - Does nothing (for testing)
25
+ # * <tt>moneris</tt>: MonerisGateway
26
+ # * <tt>authorize_net</tt>: AuthorizeNetGateway
27
+ # * <tt>trust_commerce</tt>: TrustCommerceGateway
28
+ #
29
+ # ActiveMerchant::Billing::Base.gateway('moneris').new
30
+ def self.gateway(name)
31
+ name_str = name.to_s.strip.downcase
32
+
33
+ raise(ArgumentError, 'A gateway provider must be specified') if name_str.blank?
34
+
35
+ begin
36
+ Billing.const_get("#{name_str}_gateway".camelize)
37
+ rescue
38
+ raise ArgumentError, "The specified gateway is not valid (#{name_str})"
39
+ end
40
+ end
41
+
42
+ # A check to see if we're in test mode
43
+ def self.test?
44
+ mode == :test
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,112 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # The Check object is a plain old Ruby object, similar to CreditCard. It supports validation
4
+ # of necessary attributes such as checkholder's name, routing and account numbers, but it is
5
+ # not backed by any database.
6
+ #
7
+ # You may use Check in place of CreditCard with any gateway that supports it.
8
+ class Check < Model
9
+ attr_accessor :first_name, :last_name,
10
+ :bank_name, :routing_number, :account_number,
11
+ :account_holder_type, :account_type, :number
12
+
13
+ # Used for Canadian bank accounts
14
+ attr_accessor :institution_number, :transit_number
15
+
16
+ # Canadian Institution Numbers
17
+ # Partial list found here: https://en.wikipedia.org/wiki/Routing_number_(Canada)
18
+ CAN_INSTITUTION_NUMBERS = %w(
19
+ 001 002 003 004 006 010 016 030 039 117 127 177 219 245 260 269 270 308
20
+ 309 310 315 320 338 340 509 540 608 614 623 809 815 819 828 829 837 839
21
+ 865 879 889 899 241 242 248 250 265 275 277 290 294 301 303 307 311 314
22
+ 321 323 327 328 330 332 334 335 342 343 346 352 355 361 362 366 370 372
23
+ 376 378 807 853 890 618 842
24
+ )
25
+
26
+ def name
27
+ @name ||= "#{first_name} #{last_name}".strip
28
+ end
29
+
30
+ def name=(value)
31
+ return if empty?(value)
32
+
33
+ @name = value
34
+ segments = value.split(' ')
35
+ @last_name = segments.pop
36
+ @first_name = segments.join(' ')
37
+ end
38
+
39
+ def validate
40
+ errors = []
41
+
42
+ %i[name routing_number account_number].each do |attr|
43
+ errors << [attr, 'cannot be empty'] if empty?(self.send(attr))
44
+ end
45
+
46
+ errors << [:routing_number, 'is invalid'] unless valid_routing_number?
47
+
48
+ errors << [:account_holder_type, 'must be personal or business'] if !empty?(account_holder_type) && !%w[business personal].include?(account_holder_type.to_s)
49
+
50
+ errors << [:account_type, 'must be checking or savings'] if !empty?(account_type) && !%w[checking savings].include?(account_type.to_s)
51
+
52
+ errors_hash(errors)
53
+ end
54
+
55
+ def type
56
+ 'check'
57
+ end
58
+
59
+ def credit_card?
60
+ false
61
+ end
62
+
63
+ def valid_routing_number?
64
+ digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) }
65
+ case digits.size
66
+ when 9
67
+ return checksum(digits) == 0 || CAN_INSTITUTION_NUMBERS.include?(routing_number[1..3])
68
+ when 8
69
+ return CAN_INSTITUTION_NUMBERS.include?(routing_number[5..7])
70
+ end
71
+
72
+ false
73
+ end
74
+
75
+ # Routing numbers may be validated by calculating a checksum and dividing it by 10. The
76
+ # formula is:
77
+ # (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
78
+ # See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
79
+ def checksum(digits)
80
+ ((3 * (digits[0] + digits[3] + digits[6])) +
81
+ (7 * (digits[1] + digits[4] + digits[7])) +
82
+ (digits[2] + digits[5] + digits[8])) % 10
83
+ end
84
+
85
+ # Always return MICR-formatted routing number for Canadian routing numbers, US routing numbers unchanged
86
+ def micr_format_routing_number
87
+ digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) }
88
+ case digits.size
89
+ when 9
90
+ if checksum(digits) == 0
91
+ return routing_number
92
+ else
93
+ return routing_number[4..8] + routing_number[1..3]
94
+ end
95
+ when 8
96
+ return routing_number
97
+ end
98
+ end
99
+
100
+ # Always return electronic-formatted routing number for Canadian routing numbers, US routing numbers unchanged
101
+ def electronic_format_routing_number
102
+ digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) }
103
+ case digits.size
104
+ when 9
105
+ return routing_number
106
+ when 8
107
+ return '0' + routing_number[5..7] + routing_number[0..4]
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,118 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ module Compatibility
4
+ module Model
5
+ def valid?
6
+ Compatibility.deprecated
7
+ super
8
+ end
9
+
10
+ def errors
11
+ Compatibility.deprecated
12
+ internal_errors
13
+ end
14
+ end
15
+
16
+ @rails_required = false
17
+ def self.rails_required!
18
+ @rails_required = true
19
+ end
20
+
21
+ def self.deprecated
22
+ ActiveMerchant.deprecated(
23
+ %(Implicit inclusion of Rails-specific functionality is deprecated.) +
24
+ %( Explicitly require "active_merchant/billing/rails" if you need it.)
25
+ ) unless @rails_required
26
+ end
27
+
28
+ def self.humanize(lower_case_and_underscored_word)
29
+ result = lower_case_and_underscored_word.to_s.dup
30
+ result.gsub!(/_id$/, '')
31
+ result.tr!('_', ' ')
32
+ result.gsub(/([a-z\d]*)/i, &:downcase).gsub(/^\w/) { $&.upcase }
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ # This lives in compatibility until we remove the deprecation for implicitly
39
+ # requiring Rails
40
+ module ActiveMerchant
41
+ module Billing
42
+ module Rails
43
+ module Model
44
+ def valid?
45
+ internal_errors.clear
46
+
47
+ validate.each do |attribute, errors|
48
+ errors.each do |error|
49
+ internal_errors.add(attribute, error)
50
+ end
51
+ end
52
+
53
+ internal_errors.empty?
54
+ end
55
+
56
+ private
57
+
58
+ def internal_errors
59
+ @internal_errors ||= Errors.new
60
+ end
61
+
62
+ class Errors < Hash
63
+ def initialize
64
+ super() { |h, k| h[k] = [] }
65
+ end
66
+
67
+ alias count size
68
+
69
+ def [](key)
70
+ super(key.to_s)
71
+ end
72
+
73
+ def []=(key, value)
74
+ super(key.to_s, value)
75
+ end
76
+
77
+ def empty?
78
+ all? { |_k, v| v&.empty? }
79
+ end
80
+
81
+ def on(field)
82
+ self[field].to_a.first
83
+ end
84
+
85
+ def add(field, error)
86
+ self[field] << error
87
+ end
88
+
89
+ def add_to_base(error)
90
+ add(:base, error)
91
+ end
92
+
93
+ def each_full
94
+ full_messages.each { |msg| yield msg }
95
+ end
96
+
97
+ def full_messages
98
+ result = []
99
+
100
+ self.each do |key, messages|
101
+ next unless messages && !messages.empty?
102
+
103
+ if key == 'base'
104
+ result << messages.first.to_s
105
+ else
106
+ result << "#{Compatibility.humanize(key)} #{messages.first}"
107
+ end
108
+ end
109
+
110
+ result
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ Compatibility::Model.send(:include, Rails::Model)
117
+ end
118
+ end