swiss-crm-activemerchant 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +252 -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 +242 -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 +228 -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 +354 -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 +121 -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
@@ -0,0 +1,977 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # ==== Customer Information Manager (CIM)
6
+ #
7
+ # The Authorize.Net Customer Information Manager (CIM) is an optional additional service that allows you to store sensitive payment information on
8
+ # Authorize.Net's servers, simplifying payments for returning customers and recurring transactions. It can also help with Payment Card Industry (PCI)
9
+ # Data Security Standard compliance, since customer data is no longer stored locally.
10
+ #
11
+ # To use the AuthorizeNetCimGateway CIM must be enabled for your account.
12
+ #
13
+ # Information about CIM is available on the {Authorize.Net website}[http://www.authorize.net/solutions/merchantsolutions/merchantservices/cim/].
14
+ # Information about the CIM API is available at the {Authorize.Net Integration Center}[http://developer.authorize.net/]
15
+ #
16
+ # ==== Login and Password
17
+ #
18
+ # The login and password are not the username and password you use to
19
+ # login to the Authorize.Net Merchant Interface. Instead, you will
20
+ # use the API Login ID as the login and Transaction Key as the
21
+ # password.
22
+ #
23
+ # ==== How to Get Your API Login ID and Transaction Key
24
+ #
25
+ # 1. Log into the Merchant Interface
26
+ # 2. Select Settings from the Main Menu
27
+ # 3. Click on API Login ID and Transaction Key in the Security section
28
+ # 4. Type in the answer to the secret question configured on setup
29
+ # 5. Click Submit
30
+ class AuthorizeNetCimGateway < Gateway
31
+ self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
32
+ self.live_url = 'https://api2.authorize.net/xml/v1/request.api'
33
+
34
+ AUTHORIZE_NET_CIM_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
35
+
36
+ CIM_ACTIONS = {
37
+ create_customer_profile: 'createCustomerProfile',
38
+ create_customer_payment_profile: 'createCustomerPaymentProfile',
39
+ create_customer_shipping_address: 'createCustomerShippingAddress',
40
+ get_customer_profile: 'getCustomerProfile',
41
+ get_customer_profile_ids: 'getCustomerProfileIds',
42
+ get_customer_payment_profile: 'getCustomerPaymentProfile',
43
+ get_customer_shipping_address: 'getCustomerShippingAddress',
44
+ delete_customer_profile: 'deleteCustomerProfile',
45
+ delete_customer_payment_profile: 'deleteCustomerPaymentProfile',
46
+ delete_customer_shipping_address: 'deleteCustomerShippingAddress',
47
+ update_customer_profile: 'updateCustomerProfile',
48
+ update_customer_payment_profile: 'updateCustomerPaymentProfile',
49
+ update_customer_shipping_address: 'updateCustomerShippingAddress',
50
+ create_customer_profile_transaction: 'createCustomerProfileTransaction',
51
+ validate_customer_payment_profile: 'validateCustomerPaymentProfile'
52
+ }
53
+
54
+ CIM_TRANSACTION_TYPES = {
55
+ auth_capture: 'profileTransAuthCapture',
56
+ auth_only: 'profileTransAuthOnly',
57
+ capture_only: 'profileTransCaptureOnly',
58
+ prior_auth_capture: 'profileTransPriorAuthCapture',
59
+ refund: 'profileTransRefund',
60
+ void: 'profileTransVoid'
61
+ }
62
+
63
+ CIM_VALIDATION_MODES = {
64
+ none: 'none',
65
+ test: 'testMode',
66
+ live: 'liveMode',
67
+ old: 'oldLiveMode'
68
+ }
69
+
70
+ BANK_ACCOUNT_TYPES = {
71
+ checking: 'checking',
72
+ savings: 'savings',
73
+ business_checking: 'businessChecking'
74
+ }
75
+
76
+ ECHECK_TYPES = {
77
+ ccd: 'CCD',
78
+ ppd: 'PPD',
79
+ web: 'WEB'
80
+ }
81
+
82
+ self.homepage_url = 'http://www.authorize.net/'
83
+ self.display_name = 'Authorize.Net CIM'
84
+ self.supported_countries = ['US']
85
+ self.supported_cardtypes = %i[visa master american_express discover]
86
+
87
+ # Creates a new AuthorizeNetCimGateway
88
+ #
89
+ # The gateway requires that a valid API Login ID and Transaction Key be passed
90
+ # in the +options+ hash.
91
+ #
92
+ # ==== Options
93
+ #
94
+ # * <tt>:login</tt> -- The Authorize.Net API Login ID (REQUIRED)
95
+ # * <tt>:password</tt> -- The Authorize.Net Transaction Key. (REQUIRED)
96
+ # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
97
+ # Otherwise, perform transactions against the production server.
98
+ # * <tt>:test_requests</tt> -- +true+ or +false+. If true, perform transactions without the
99
+ # test flag. This is useful when you need to generate card declines, AVS or CVV errors.
100
+ # Will hold the same value as :test by default.
101
+ # * <tt>:delimiter</tt> -- The delimiter used in the direct response. Default is ',' (comma).
102
+ def initialize(options = {})
103
+ requires!(options, :login, :password)
104
+ super
105
+ @options[:test_requests] = test? if @options[:test_requests].nil?
106
+ end
107
+
108
+ # Creates a new customer profile along with any customer payment profiles and customer shipping addresses
109
+ # for the customer profile.
110
+ #
111
+ # Returns a Response with the Customer Profile ID of the new customer profile in the authorization field.
112
+ # It is *CRITICAL* that you save this ID. There is no way to retrieve this through the API. You will not
113
+ # be able to create another Customer Profile with the same information.
114
+ #
115
+ #
116
+ #
117
+ # ==== Options
118
+ #
119
+ # * <tt>:profile</tt> -- A hash containing at least one of the CONDITIONAL profile options below (REQUIRED)
120
+ #
121
+ # ==== Profile
122
+ #
123
+ # * <tt>:email</tt> -- Email address associated with the customer profile (CONDITIONAL)
124
+ # * <tt>:description</tt> -- Description of the customer or customer profile (CONDITIONAL)
125
+ # * <tt>:merchant_customer_id</tt> -- Merchant assigned ID for the customer (CONDITIONAL)
126
+ # * <tt>:payment_profile</tt> -- A hash containing the elements of the new payment profile (optional)
127
+ #
128
+ # ==== Payment Profile
129
+ #
130
+ # * <tt>:payment</tt> -- A hash containing information on payment. Either :credit_card or :bank_account (optional)
131
+ def create_customer_profile(options)
132
+ requires!(options, :profile)
133
+ requires!(options[:profile], :email) unless options[:profile][:merchant_customer_id] || options[:profile][:description]
134
+ requires!(options[:profile], :description) unless options[:profile][:email] || options[:profile][:merchant_customer_id]
135
+ requires!(options[:profile], :merchant_customer_id) unless options[:profile][:description] || options[:profile][:email]
136
+
137
+ request = build_request(:create_customer_profile, options)
138
+ commit(:create_customer_profile, request)
139
+ end
140
+
141
+ # Creates a new customer payment profile for an existing customer profile.
142
+ #
143
+ # ==== Options
144
+ #
145
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED)
146
+ # * <tt>:payment_profile</tt> -- A hash containing the elements of the new payment profile (REQUIRED)
147
+ #
148
+ # ==== Payment Profile
149
+ #
150
+ # * <tt>:payment</tt> -- A hash containing information on payment. Either :credit_card or :bank_account (REQUIRED)
151
+ def create_customer_payment_profile(options)
152
+ requires!(options, :customer_profile_id)
153
+ requires!(options, :payment_profile)
154
+ requires!(options[:payment_profile], :payment)
155
+
156
+ request = build_request(:create_customer_payment_profile, options)
157
+ commit(:create_customer_payment_profile, request)
158
+ end
159
+
160
+ # Creates a new customer shipping address for an existing customer profile.
161
+ #
162
+ # ==== Options
163
+ #
164
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED)
165
+ # * <tt>:address</tt> -- A hash containing the elements of the shipping address (REQUIRED)
166
+ def create_customer_shipping_address(options)
167
+ requires!(options, :customer_profile_id)
168
+ requires!(options, :address)
169
+
170
+ request = build_request(:create_customer_shipping_address, options)
171
+ commit(:create_customer_shipping_address, request)
172
+ end
173
+
174
+ # Deletes an existing customer profile along with all associated customer payment profiles and customer shipping addresses.
175
+ #
176
+ # ==== Options
177
+ #
178
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to be deleted. (REQUIRED)
179
+ def delete_customer_profile(options)
180
+ requires!(options, :customer_profile_id)
181
+
182
+ request = build_request(:delete_customer_profile, options)
183
+ commit(:delete_customer_profile, request)
184
+ end
185
+
186
+ # Deletes a customer payment profile from an existing customer profile.
187
+ #
188
+ # ==== Options
189
+ #
190
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED)
191
+ # * <tt>:customer_payment_profile_id</tt> -- The Payment Profile ID of the payment profile to be deleted. (REQUIRED)
192
+ def delete_customer_payment_profile(options)
193
+ requires!(options, :customer_profile_id)
194
+ requires!(options, :customer_payment_profile_id)
195
+
196
+ request = build_request(:delete_customer_payment_profile, options)
197
+ commit(:delete_customer_payment_profile, request)
198
+ end
199
+
200
+ # Deletes a customer shipping address from an existing customer profile.
201
+ #
202
+ # ==== Options
203
+ #
204
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED)
205
+ # * <tt>:customer_address_id</tt> -- The Shipping Address ID of the shipping address to be deleted. (REQUIRED)
206
+ def delete_customer_shipping_address(options)
207
+ requires!(options, :customer_profile_id)
208
+ requires!(options, :customer_address_id)
209
+
210
+ request = build_request(:delete_customer_shipping_address, options)
211
+ commit(:delete_customer_shipping_address, request)
212
+ end
213
+
214
+ # Retrieves an existing customer profile along with all the associated customer payment profiles and customer shipping addresses.
215
+ #
216
+ # Returns a Response whose params hash contains all the profile information.
217
+ #
218
+ # ==== Options
219
+ #
220
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to retrieve. (REQUIRED)
221
+ def get_customer_profile(options)
222
+ requires!(options, :customer_profile_id)
223
+
224
+ request = build_request(:get_customer_profile, options)
225
+ commit(:get_customer_profile, request)
226
+ end
227
+
228
+ def get_customer_profile_ids(options = {})
229
+ request = build_request(:get_customer_profile_ids, options)
230
+ commit(:get_customer_profile_ids, request)
231
+ end
232
+
233
+ # Retrieve a customer payment profile for an existing customer profile.
234
+ #
235
+ # Returns a Response whose params hash contains all the payment profile information. Sensitive information such as credit card
236
+ # numbers will be masked.
237
+ #
238
+ # ==== Options
239
+ #
240
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
241
+ # * <tt>:customer_payment_profile_id</tt> -- The Payment Profile ID of the payment profile to be retrieved. (REQUIRED)
242
+ def get_customer_payment_profile(options)
243
+ requires!(options, :customer_profile_id)
244
+ requires!(options, :customer_payment_profile_id)
245
+
246
+ request = build_request(:get_customer_payment_profile, options)
247
+ commit(:get_customer_payment_profile, request)
248
+ end
249
+
250
+ # Retrieve a customer shipping address for an existing customer profile.
251
+ #
252
+ # Returns a Response whose params hash contains all the shipping address information.
253
+ #
254
+ # ==== Options
255
+ #
256
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
257
+ # * <tt>:customer_address_id</tt> -- The Shipping Address ID of the shipping address to be retrieved. (REQUIRED)
258
+ def get_customer_shipping_address(options)
259
+ requires!(options, :customer_profile_id)
260
+ requires!(options, :customer_address_id)
261
+
262
+ request = build_request(:get_customer_shipping_address, options)
263
+ commit(:get_customer_shipping_address, request)
264
+ end
265
+
266
+ # Updates an existing customer profile.
267
+ #
268
+ # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
269
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_profile and then only change the
270
+ # elements you wish to change.
271
+ #
272
+ # ==== Options
273
+ #
274
+ # * <tt>:profile</tt> -- A hash containing the values the Customer Profile should be updated to. (REQUIRED)
275
+ #
276
+ # ==== Profile
277
+ #
278
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer profile to update. (REQUIRED)
279
+ def update_customer_profile(options)
280
+ requires!(options, :profile)
281
+ requires!(options[:profile], :customer_profile_id)
282
+
283
+ request = build_request(:update_customer_profile, options)
284
+ commit(:update_customer_profile, request)
285
+ end
286
+
287
+ # Updates a customer payment profile for an existing customer profile.
288
+ #
289
+ # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
290
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_payment_profile and then only
291
+ # change the elements you wish to change.
292
+ #
293
+ # ==== Options
294
+ #
295
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
296
+ # * <tt>:payment_profile</tt> -- A hash containing the values the Customer Payment Profile should be updated to. (REQUIRED)
297
+ #
298
+ # ==== Payment Profile
299
+ #
300
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to update. (REQUIRED)
301
+ def update_customer_payment_profile(options)
302
+ requires!(options, :customer_profile_id, :payment_profile)
303
+ requires!(options[:payment_profile], :customer_payment_profile_id)
304
+
305
+ request = build_request(:update_customer_payment_profile, options)
306
+ commit(:update_customer_payment_profile, request)
307
+ end
308
+
309
+ # Updates a customer shipping address for an existing customer profile.
310
+ #
311
+ # Warning: if you do not provide a parameter in the <tt>:address</tt> hash, it is automatically set to nil at
312
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_shipping_address and then only
313
+ # change the elements you wish to change.
314
+ #
315
+ # ==== Options
316
+ #
317
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
318
+ # * <tt>:address</tt> -- A hash containing the values the Customer Shipping Address should be updated to. (REQUIRED)
319
+ #
320
+ # ==== Address
321
+ #
322
+ # * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Payment Profile to update. (REQUIRED)
323
+ def update_customer_shipping_address(options)
324
+ requires!(options, :customer_profile_id, :address)
325
+ requires!(options[:address], :customer_address_id)
326
+
327
+ request = build_request(:update_customer_shipping_address, options)
328
+ commit(:update_customer_shipping_address, request)
329
+ end
330
+
331
+ # Creates a new payment transaction from an existing customer profile
332
+ #
333
+ # This is what is used to charge a customer whose information you have stored in a Customer Profile.
334
+ #
335
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
336
+ #
337
+ # ==== Options
338
+ #
339
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
340
+ #
341
+ # ==== Transaction
342
+ #
343
+ # * <tt>:type</tt> -- The type of transaction. Can be either <tt>:auth_only</tt>, <tt>:capture_only</tt>, <tt>:auth_capture</tt>, <tt>:prior_auth_capture</tt>, <tt>:refund</tt> or <tt>:void</tt>. (REQUIRED)
344
+ # * <tt>:amount</tt> -- The amount for the transaction. Formatted with a decimal. For example "4.95" (CONDITIONAL)
345
+ # - :type == :void (NOT USED)
346
+ # - :type == :refund (OPTIONAL)
347
+ # - :type == (:auth_only, :capture_only, :auth_capture, :prior_auth_capture) (REQUIRED)
348
+ #
349
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL)
350
+ # - :type == (:void, :prior_auth_capture) (OPTIONAL)
351
+ # - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below])
352
+ # - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
353
+ #
354
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL)
355
+ # - :type == (:void, :prior_auth_capture) (OPTIONAL)
356
+ # - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below])
357
+ # - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
358
+ #
359
+ # * <tt>:trans_id</tt> -- The payment gateway assigned transaction ID of the original transaction (CONDITIONAL):
360
+ # - :type = (:void, :refund, :prior_auth_capture) (REQUIRED)
361
+ # - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
362
+ #
363
+ # * <tt>:card_code</tt> -- CVV/CCV code (OPTIONAL)
364
+ # - :type = (:void, :refund, :prior_auth_capture) (NOT USED)
365
+ # - :type = (:auth_only, :capture_only, :auth_capture) (OPTIONAL)
366
+ #
367
+ # * <tt>:recurring_billing</tt> -- The recurring billing status (OPTIONAL)
368
+ # - :type = (:void, :refund, :prior_auth_capture) (NOT USED)
369
+ # - :type = (:auth_only, :capture_only, :auth_capture) (OPTIONAL)
370
+ #
371
+ # * <tt>:customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address (CONDITIONAL)
372
+ # - :type = (:void, :refund) (OPTIONAL)
373
+ # - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
374
+ # - :type = (:prior_auth_capture) (OPTIONAL)
375
+ #
376
+ # ==== For :type == :refund only
377
+ # * <tt>:credit_card_number_masked</tt> -- (CONDITIONAL - required for credit card refunds if :customer_profile_id AND :customer_payment_profile_id are missing)
378
+ # * <tt>:bank_routing_number_masked && :bank_account_number_masked</tt> -- (CONDITIONAL - required for electronic check refunds if :customer_profile_id AND :customer_payment_profile_id are missing) (NOT ABLE TO TEST - I keep getting "ACH transactions are not accepted by this merchant." when trying to make a payment and, until that's possible I can't refund (wiseleyb@gmail.com))
379
+ def create_customer_profile_transaction(options)
380
+ requires!(options, :transaction)
381
+ requires!(options[:transaction], :type)
382
+ case options[:transaction][:type]
383
+ when :void
384
+ requires!(options[:transaction], :trans_id)
385
+ when :refund
386
+ requires!(options[:transaction], :trans_id) &&
387
+ (
388
+ (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
389
+ options[:transaction][:credit_card_number_masked] ||
390
+ (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
391
+ )
392
+ when :prior_auth_capture
393
+ requires!(options[:transaction], :amount, :trans_id)
394
+ else
395
+ requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
396
+ end
397
+ request = build_request(:create_customer_profile_transaction, options)
398
+ commit(:create_customer_profile_transaction, request)
399
+ end
400
+
401
+ # Creates a new payment transaction for refund from an existing customer profile
402
+ #
403
+ # This is what is used to refund a transaction you have stored in a Customer Profile.
404
+ #
405
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
406
+ #
407
+ # ==== Options
408
+ #
409
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
410
+ #
411
+ # ==== Transaction
412
+ #
413
+ # * <tt>:amount</tt> -- The total amount to be refunded (REQUIRED)
414
+ #
415
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL :customer_payment_profile_id must be included if used)
416
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL :customer_profile_id must be included if used)
417
+ #
418
+ # * <tt>:credit_card_number_masked</tt> -- Four Xs followed by the last four digits of the credit card (CONDITIONAL - used if customer_profile_id and customer_payment_profile_id aren't given)
419
+ #
420
+ # * <tt>:bank_routing_number_masked</tt> -- The last four digits of the routing number to be refunded (CONDITIONAL - must be used with :bank_account_number_masked)
421
+ # * <tt>:bank_account_number_masked</tt> -- The last four digits of the bank account number to be refunded, Ex. XXXX1234 (CONDITIONAL - must be used with :bank_routing_number_masked)
422
+ #
423
+ # * <tt>:tax</tt> - A hash containing tax information for the refund (OPTIONAL - <tt>:amount</tt>, <tt>:name</tt> (31 characters), <tt>:description</tt> (255 characters))
424
+ # * <tt>:duty</tt> - A hash containing duty information for the refund (OPTIONAL - <tt>:amount</tt>, <tt>:name</tt> (31 characters), <tt>:description</tt> (255 characters))
425
+ # * <tt>:shipping</tt> - A hash containing shipping information for the refund (OPTIONAL - <tt>:amount</tt>, <tt>:name</tt> (31 characters), <tt>:description</tt> (255 characters))
426
+ def create_customer_profile_transaction_for_refund(options)
427
+ requires!(options, :transaction)
428
+ options[:transaction][:type] = :refund
429
+ requires!(options[:transaction], :trans_id)
430
+ requires!(options[:transaction], :amount)
431
+ request = build_request(:create_customer_profile_transaction, options)
432
+ commit(:create_customer_profile_transaction, request)
433
+ end
434
+
435
+ # Creates a new payment transaction for void from an existing customer profile
436
+ #
437
+ # This is what is used to void a transaction you have stored in a Customer Profile.
438
+ #
439
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
440
+ #
441
+ # ==== Options
442
+ #
443
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
444
+ #
445
+ # ==== Transaction
446
+ #
447
+ # * <tt>:trans_id</tt> -- The payment gateway assigned transaction id of the original transaction. (REQUIRED)
448
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction.
449
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction.
450
+ # * <tt>:customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address.
451
+ def create_customer_profile_transaction_for_void(options)
452
+ requires!(options, :transaction)
453
+ options[:transaction][:type] = :void
454
+ requires!(options[:transaction], :trans_id)
455
+ request = build_request(:create_customer_profile_transaction, options)
456
+ commit(:create_customer_profile_transaction, request)
457
+ end
458
+
459
+ # Verifies an existing customer payment profile by generating a test transaction
460
+ #
461
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
462
+ #
463
+ # ==== Options
464
+ #
465
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (REQUIRED)
466
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to be verified. (REQUIRED)
467
+ # * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Shipping Address to be verified. (OPTIONAL)
468
+ # * <tt>:card_code</tt> -- If the payment profile is a credit card, the CCV/CVV code to validate with (OPTIONAL)
469
+ # * <tt>:validation_mode</tt> -- <tt>:live</tt> or <tt>:test</tt> In Test Mode, only field validation is performed. (REQUIRED
470
+ # In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.01. If successful, the transaction is immediately voided. (REQUIRED)
471
+ def validate_customer_payment_profile(options)
472
+ requires!(options, :customer_profile_id, :customer_payment_profile_id, :validation_mode)
473
+
474
+ request = build_request(:validate_customer_payment_profile, options)
475
+ commit(:validate_customer_payment_profile, request)
476
+ end
477
+
478
+ private
479
+
480
+ def expdate(credit_card)
481
+ if credit_card.year.present? && credit_card.month.present?
482
+ sprintf('%04d-%02d', credit_card.year, credit_card.month)
483
+ else
484
+ 'XXXX'
485
+ end
486
+ end
487
+
488
+ def build_request(action, options = {})
489
+ raise StandardError, "Invalid Customer Information Manager Action: #{action}" unless CIM_ACTIONS.include?(action)
490
+
491
+ xml = Builder::XmlMarkup.new(indent: 2)
492
+ xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
493
+ xml.tag!("#{CIM_ACTIONS[action]}Request", xmlns: AUTHORIZE_NET_CIM_NAMESPACE) do
494
+ add_merchant_authentication(xml)
495
+ # Merchant-assigned reference ID for the request
496
+ xml.tag!('refId', options[:ref_id]) if options[:ref_id]
497
+ # Order options
498
+ add_order(xml, options[:order]) if options[:order]
499
+ send("build_#{action}_request", xml, options)
500
+ end
501
+ end
502
+
503
+ # Contains the merchant’s payment gateway account authentication information
504
+ def add_merchant_authentication(xml)
505
+ xml.tag!('merchantAuthentication') do
506
+ xml.tag!('name', @options[:login])
507
+ xml.tag!('transactionKey', @options[:password])
508
+ end
509
+ end
510
+
511
+ def build_create_customer_profile_request(xml, options)
512
+ add_profile(xml, options[:profile])
513
+
514
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
515
+
516
+ if options.has_key?(:payment_profile)
517
+ xml.tag!('paymentProfile') do
518
+ add_payment_profile(xml, options[:payment_profile])
519
+ end
520
+ end
521
+
522
+ xml.target!
523
+ end
524
+
525
+ def build_create_customer_payment_profile_request(xml, options)
526
+ xml.tag!('customerProfileId', options[:customer_profile_id])
527
+
528
+ xml.tag!('paymentProfile') do
529
+ add_payment_profile(xml, options[:payment_profile])
530
+ end
531
+
532
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
533
+
534
+ xml.target!
535
+ end
536
+
537
+ def build_create_customer_shipping_address_request(xml, options)
538
+ xml.tag!('customerProfileId', options[:customer_profile_id])
539
+
540
+ xml.tag!('address') do
541
+ add_address(xml, options[:address])
542
+ end
543
+
544
+ xml.target!
545
+ end
546
+
547
+ def build_delete_customer_profile_request(xml, options)
548
+ xml.tag!('customerProfileId', options[:customer_profile_id])
549
+ xml.target!
550
+ end
551
+
552
+ def build_delete_customer_payment_profile_request(xml, options)
553
+ xml.tag!('customerProfileId', options[:customer_profile_id])
554
+ xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
555
+ xml.target!
556
+ end
557
+
558
+ def build_delete_customer_shipping_address_request(xml, options)
559
+ xml.tag!('customerProfileId', options[:customer_profile_id])
560
+ xml.tag!('customerAddressId', options[:customer_address_id])
561
+ xml.target!
562
+ end
563
+
564
+ def build_get_customer_profile_request(xml, options)
565
+ xml.tag!('customerProfileId', options[:customer_profile_id])
566
+ xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
567
+ xml.tag!('includeIssuerInfo', options[:include_issuer_info]) if options[:include_issuer_info]
568
+ xml.target!
569
+ end
570
+
571
+ def build_get_customer_profile_ids_request(xml, options)
572
+ xml.target!
573
+ end
574
+
575
+ def build_get_customer_payment_profile_request(xml, options)
576
+ xml.tag!('customerProfileId', options[:customer_profile_id])
577
+ xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
578
+ xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
579
+ xml.tag!('includeIssuerInfo', options[:include_issuer_info]) if options[:include_issuer_info]
580
+ xml.target!
581
+ end
582
+
583
+ def build_get_customer_shipping_address_request(xml, options)
584
+ xml.tag!('customerProfileId', options[:customer_profile_id])
585
+ xml.tag!('customerAddressId', options[:customer_address_id])
586
+ xml.target!
587
+ end
588
+
589
+ def build_update_customer_profile_request(xml, options)
590
+ add_profile(xml, options[:profile], true)
591
+
592
+ xml.target!
593
+ end
594
+
595
+ def build_update_customer_payment_profile_request(xml, options)
596
+ xml.tag!('customerProfileId', options[:customer_profile_id])
597
+
598
+ xml.tag!('paymentProfile') do
599
+ add_payment_profile(xml, options[:payment_profile])
600
+ end
601
+
602
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
603
+
604
+ xml.target!
605
+ end
606
+
607
+ def build_update_customer_shipping_address_request(xml, options)
608
+ xml.tag!('customerProfileId', options[:customer_profile_id])
609
+
610
+ xml.tag!('address') do
611
+ add_address(xml, options[:address])
612
+ end
613
+
614
+ xml.target!
615
+ end
616
+
617
+ def build_create_customer_profile_transaction_request(xml, options)
618
+ options[:extra_options] ||= {}
619
+ options[:extra_options]['x_delim_char'] = @options[:delimiter] if @options[:delimiter]
620
+
621
+ add_transaction(xml, options[:transaction])
622
+ xml.tag!('extraOptions') do
623
+ xml.cdata!(format_extra_options(options[:extra_options]))
624
+ end unless options[:extra_options].blank?
625
+
626
+ xml.target!
627
+ end
628
+
629
+ def build_validate_customer_payment_profile_request(xml, options)
630
+ xml.tag!('customerProfileId', options[:customer_profile_id])
631
+ xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
632
+ xml.tag!('customerShippingAddressId', options[:customer_address_id]) if options[:customer_address_id]
633
+ tag_unless_blank(xml, 'cardCode', options[:card_code])
634
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
635
+
636
+ xml.target!
637
+ end
638
+
639
+ # :merchant_customer_id (Optional)
640
+ # :description (Optional)
641
+ # :email (Optional)
642
+ # :payment_profiles (Optional)
643
+ def add_profile(xml, profile, update = false)
644
+ xml.tag!('profile') do
645
+ # Merchant assigned ID for the customer. Up to 20 characters. (optional)
646
+ xml.tag!('merchantCustomerId', profile[:merchant_customer_id]) if profile[:merchant_customer_id]
647
+ # Description of the customer. Up to 255 Characters (optional)
648
+ xml.tag!('description', profile[:description]) if profile[:description]
649
+ # Email Address for the customer. Up to 255 Characters (optional)
650
+ xml.tag!('email', profile[:email]) if profile[:email]
651
+
652
+ if update
653
+ xml.tag!('customerProfileId', profile[:customer_profile_id])
654
+ else
655
+ add_payment_profiles(xml, profile[:payment_profiles]) if profile[:payment_profiles]
656
+ add_ship_to_list(xml, profile[:ship_to_list]) if profile[:ship_to_list]
657
+ end
658
+ end
659
+ end
660
+
661
+ def add_transaction(xml, transaction)
662
+ raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}" unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
663
+
664
+ xml.tag!('transaction') do
665
+ xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
666
+ # The amount to be billed to the customer
667
+ case transaction[:type]
668
+ when :void
669
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
670
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
671
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
672
+ xml.tag!('transId', transaction[:trans_id])
673
+ when :refund
674
+ xml.tag!('amount', transaction[:amount])
675
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
676
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
677
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
678
+ tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
679
+ tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
680
+ tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
681
+ add_order(xml, transaction[:order]) if transaction[:order].present?
682
+ xml.tag!('transId', transaction[:trans_id])
683
+ add_tax(xml, transaction[:tax]) if transaction[:tax]
684
+ add_duty(xml, transaction[:duty]) if transaction[:duty]
685
+ add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
686
+ when :prior_auth_capture
687
+ xml.tag!('amount', transaction[:amount])
688
+ add_order(xml, transaction[:order]) if transaction[:order].present?
689
+ xml.tag!('transId', transaction[:trans_id])
690
+ else
691
+ xml.tag!('amount', transaction[:amount])
692
+ xml.tag!('customerProfileId', transaction[:customer_profile_id])
693
+ xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
694
+ xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
695
+ add_order(xml, transaction[:order]) if transaction[:order].present?
696
+
697
+ end
698
+ if %i[auth_capture auth_only capture_only].include?(transaction[:type])
699
+ xml.tag!('recurringBilling', transaction[:recurring_billing]) if transaction.has_key?(:recurring_billing)
700
+ end
701
+ tag_unless_blank(xml, 'cardCode', transaction[:card_code]) unless %i[void refund prior_auth_capture].include?(transaction[:type])
702
+ end
703
+ end
704
+ end
705
+
706
+ def add_tax(xml, tax)
707
+ xml.tag!('tax') do
708
+ xml.tag!('amount', tax[:amount]) if tax[:amount]
709
+ xml.tag!('name', tax[:name]) if tax[:name]
710
+ xml.tag!('description', tax[:description]) if tax[:description]
711
+ end
712
+ end
713
+
714
+ def add_duty(xml, duty)
715
+ xml.tag!('duty') do
716
+ xml.tag!('amount', duty[:amount]) if duty[:amount]
717
+ xml.tag!('name', duty[:name]) if duty[:name]
718
+ xml.tag!('description', duty[:description]) if duty[:description]
719
+ end
720
+ end
721
+
722
+ def add_shipping(xml, shipping)
723
+ xml.tag!('shipping') do
724
+ xml.tag!('amount', shipping[:amount]) if shipping[:amount]
725
+ xml.tag!('name', shipping[:name]) if shipping[:name]
726
+ xml.tag!('description', shipping[:description]) if shipping[:description]
727
+ end
728
+ end
729
+
730
+ def add_order(xml, order)
731
+ xml.tag!('order') do
732
+ xml.tag!('invoiceNumber', order[:invoice_number]) if order[:invoice_number]
733
+ xml.tag!('description', order[:description]) if order[:description]
734
+ xml.tag!('purchaseOrderNumber', order[:purchase_order_number]) if order[:purchase_order_number]
735
+ end
736
+ end
737
+
738
+ def add_payment_profiles(xml, payment_profiles)
739
+ xml.tag!('paymentProfiles') do
740
+ add_payment_profile(xml, payment_profiles)
741
+ end
742
+ end
743
+
744
+ # :customer_type => 'individual or business', # Optional
745
+ # :bill_to => @address,
746
+ # :payment => @payment
747
+ def add_payment_profile(xml, payment_profile)
748
+ # 'individual' or 'business' (optional)
749
+ xml.tag!('customerType', payment_profile[:customer_type]) if payment_profile[:customer_type]
750
+
751
+ if payment_profile[:bill_to]
752
+ xml.tag!('billTo') do
753
+ add_address(xml, payment_profile[:bill_to])
754
+ end
755
+ end
756
+
757
+ if payment_profile[:payment]
758
+ xml.tag!('payment') do
759
+ add_credit_card(xml, payment_profile[:payment][:credit_card]) if payment_profile[:payment].has_key?(:credit_card)
760
+ add_bank_account(xml, payment_profile[:payment][:bank_account]) if payment_profile[:payment].has_key?(:bank_account)
761
+ add_drivers_license(xml, payment_profile[:payment][:drivers_license]) if payment_profile[:payment].has_key?(:drivers_license)
762
+ # This element is only required for Wells Fargo SecureSource eCheck.Net merchants
763
+ # The customer's Social Security Number or Tax ID
764
+ xml.tag!('taxId', payment_profile[:payment]) if payment_profile[:payment].has_key?(:tax_id)
765
+ end
766
+ end
767
+
768
+ xml.tag!('customerPaymentProfileId', payment_profile[:customer_payment_profile_id]) if payment_profile[:customer_payment_profile_id]
769
+ end
770
+
771
+ def add_ship_to_list(xml, ship_to_list)
772
+ xml.tag!('shipToList') do
773
+ add_address(xml, ship_to_list)
774
+ end
775
+ end
776
+
777
+ def add_address(xml, address)
778
+ xml.tag!('firstName', address[:first_name])
779
+ xml.tag!('lastName', address[:last_name])
780
+ xml.tag!('company', address[:company])
781
+ xml.tag!('address', address[:address1]) if address[:address1]
782
+ xml.tag!('address', address[:address]) if address[:address]
783
+ xml.tag!('city', address[:city])
784
+ xml.tag!('state', address[:state])
785
+ xml.tag!('zip', address[:zip])
786
+ xml.tag!('country', address[:country])
787
+ xml.tag!('phoneNumber', address[:phone_number]) if address[:phone_number]
788
+ xml.tag!('faxNumber', address[:fax_number]) if address[:fax_number]
789
+
790
+ xml.tag!('customerAddressId', address[:customer_address_id]) if address[:customer_address_id]
791
+ end
792
+
793
+ # Adds customer’s credit card information
794
+ # Note: This element should only be included
795
+ # when the payment method is credit card.
796
+ def add_credit_card(xml, credit_card)
797
+ return unless credit_card
798
+
799
+ xml.tag!('creditCard') do
800
+ # The credit card number used for payment of the subscription
801
+ xml.tag!('cardNumber', full_or_masked_card_number(credit_card.number))
802
+ # The expiration date of the credit card used for the subscription
803
+ xml.tag!('expirationDate', expdate(credit_card))
804
+ # Note that Authorize.net does not save CVV codes as part of the
805
+ # payment profile. Any transactions/validations after the payment
806
+ # profile is created that wish to use CVV verification must pass
807
+ # the CVV code to authorize.net again.
808
+ xml.tag!('cardCode', credit_card.verification_value) if credit_card.verification_value?
809
+ end
810
+ end
811
+
812
+ # Adds customer’s bank account information
813
+ # Note: This element should only be included
814
+ # when the payment method is bank account.
815
+ def add_bank_account(xml, bank_account)
816
+ raise StandardError, "Invalid Bank Account Type: #{bank_account[:account_type]}" unless BANK_ACCOUNT_TYPES.include?(bank_account[:account_type])
817
+ raise StandardError, "Invalid eCheck Type: #{bank_account[:echeck_type]}" unless ECHECK_TYPES.include?(bank_account[:echeck_type])
818
+
819
+ xml.tag!('bankAccount') do
820
+ # The type of bank account
821
+ xml.tag!('accountType', BANK_ACCOUNT_TYPES[bank_account[:account_type]])
822
+ # The routing number of the customer’s bank
823
+ xml.tag!('routingNumber', bank_account[:routing_number])
824
+ # The bank account number
825
+ xml.tag!('accountNumber', bank_account[:account_number])
826
+ # The full name of the individual associated
827
+ # with the bank account number
828
+ xml.tag!('nameOnAccount', bank_account[:name_on_account])
829
+ # The type of electronic check transaction
830
+ xml.tag!('echeckType', ECHECK_TYPES[bank_account[:echeck_type]])
831
+ # The full name of the individual associated
832
+ # with the bank account number (optional)
833
+ xml.tag!('bankName', bank_account[:bank_name]) if bank_account[:bank_name]
834
+ end
835
+ end
836
+
837
+ # Adds customer’s driver's license information
838
+ # Note: This element is only required for
839
+ # Wells Fargo SecureSource eCheck.Net merchants
840
+ def add_drivers_license(xml, drivers_license)
841
+ xml.tag!('driversLicense') do
842
+ # The state of the customer's driver's license
843
+ # A valid two character state code
844
+ xml.tag!('state', drivers_license[:state])
845
+ # The customer’s driver's license number
846
+ xml.tag!('number', drivers_license[:number])
847
+ # The date of birth listed on the customer's driver's license
848
+ # YYYY-MM-DD
849
+ xml.tag!('dateOfBirth', drivers_license[:date_of_birth])
850
+ end
851
+ end
852
+
853
+ def commit(action, request)
854
+ url = test? ? test_url : live_url
855
+ xml = ssl_post(url, request, 'Content-Type' => 'text/xml')
856
+
857
+ response_params = parse(action, xml)
858
+
859
+ message_element = response_params['messages']['message']
860
+ first_error = message_element.is_a?(Array) ? message_element.first : message_element
861
+ message = first_error['text']
862
+ test_mode = @options[:test_requests] || message =~ /Test Mode/
863
+ success = response_params['messages']['result_code'] == 'Ok'
864
+ response_params['direct_response'] = parse_direct_response(response_params['direct_response']) if response_params['direct_response']
865
+ transaction_id = response_params['direct_response']['transaction_id'] if response_params['direct_response']
866
+
867
+ response_options = {}
868
+ response_options[:test] = test_mode
869
+ response_options[:authorization] = transaction_id || response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil)
870
+ response_options[:error_code] = first_error['code'] unless success
871
+
872
+ Response.new(success, message, response_params, response_options)
873
+ end
874
+
875
+ def tag_unless_blank(xml, tag_name, data)
876
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
877
+ end
878
+
879
+ def format_extra_options(options)
880
+ options&.map { |k, v| "#{k}=#{v}" }&.join('&')
881
+ end
882
+
883
+ def parse_direct_response(params)
884
+ delimiter = @options[:delimiter] || ','
885
+ direct_response = { 'raw' => params }
886
+ direct_response_fields = params.split(delimiter)
887
+ direct_response.merge(
888
+ {
889
+ 'response_code' => direct_response_fields[0],
890
+ 'response_subcode' => direct_response_fields[1],
891
+ 'response_reason_code' => direct_response_fields[2],
892
+ 'message' => direct_response_fields[3],
893
+ 'approval_code' => direct_response_fields[4],
894
+ 'avs_response' => direct_response_fields[5],
895
+ 'transaction_id' => direct_response_fields[6],
896
+ 'invoice_number' => direct_response_fields[7],
897
+ 'order_description' => direct_response_fields[8],
898
+ 'amount' => direct_response_fields[9],
899
+ 'method' => direct_response_fields[10],
900
+ 'transaction_type' => direct_response_fields[11],
901
+ 'customer_id' => direct_response_fields[12],
902
+ 'first_name' => direct_response_fields[13],
903
+ 'last_name' => direct_response_fields[14],
904
+ 'company' => direct_response_fields[15],
905
+ 'address' => direct_response_fields[16],
906
+ 'city' => direct_response_fields[17],
907
+ 'state' => direct_response_fields[18],
908
+ 'zip_code' => direct_response_fields[19],
909
+ 'country' => direct_response_fields[20],
910
+ 'phone' => direct_response_fields[21],
911
+ 'fax' => direct_response_fields[22],
912
+ 'email_address' => direct_response_fields[23],
913
+ 'ship_to_first_name' => direct_response_fields[24],
914
+ 'ship_to_last_name' => direct_response_fields[25],
915
+ 'ship_to_company' => direct_response_fields[26],
916
+ 'ship_to_address' => direct_response_fields[27],
917
+ 'ship_to_city' => direct_response_fields[28],
918
+ 'ship_to_state' => direct_response_fields[29],
919
+ 'ship_to_zip_code' => direct_response_fields[30],
920
+ 'ship_to_country' => direct_response_fields[31],
921
+ 'tax' => direct_response_fields[32],
922
+ 'duty' => direct_response_fields[33],
923
+ 'freight' => direct_response_fields[34],
924
+ 'tax_exempt' => direct_response_fields[35],
925
+ 'purchase_order_number' => direct_response_fields[36],
926
+ 'md5_hash' => direct_response_fields[37],
927
+ 'card_code' => direct_response_fields[38],
928
+ 'cardholder_authentication_verification_response' => direct_response_fields[39],
929
+ # The following direct response fields are only available in version 3.1 of the
930
+ # transaction response. Check your merchant account settings for details.
931
+ 'account_number' => direct_response_fields[50] || '',
932
+ 'card_type' => direct_response_fields[51] || '',
933
+ 'split_tender_id' => direct_response_fields[52] || '',
934
+ 'requested_amount' => direct_response_fields[53] || '',
935
+ 'balance_on_card' => direct_response_fields[54] || ''
936
+ }
937
+ )
938
+ end
939
+
940
+ def parse(action, xml)
941
+ xml = REXML::Document.new(xml)
942
+ root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") ||
943
+ REXML::XPath.first(xml, '//ErrorResponse')
944
+ response = parse_element(root) if root
945
+
946
+ response
947
+ end
948
+
949
+ def parse_element(node)
950
+ if node.has_elements?
951
+ response = {}
952
+ node.elements.each { |e|
953
+ key = e.name.underscore
954
+ value = parse_element(e)
955
+ if response.has_key?(key)
956
+ if response[key].is_a?(Array)
957
+ response[key].push(value)
958
+ else
959
+ response[key] = [response[key], value]
960
+ end
961
+ else
962
+ response[key] = parse_element(e)
963
+ end
964
+ }
965
+ else
966
+ response = node.text
967
+ end
968
+
969
+ response
970
+ end
971
+
972
+ def full_or_masked_card_number(card_number)
973
+ !card_number.nil? && card_number.length == 4 ? "XXXX#{card_number}" : card_number
974
+ end
975
+ end
976
+ end
977
+ end