active_accountability_merchant 1.97.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +2948 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +246 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +15 -0
  8. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  9. data/lib/active_merchant/billing/avs_result.rb +96 -0
  10. data/lib/active_merchant/billing/base.rb +61 -0
  11. data/lib/active_merchant/billing/check.rb +80 -0
  12. data/lib/active_merchant/billing/compatibility.rb +117 -0
  13. data/lib/active_merchant/billing/credit_card.rb +406 -0
  14. data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
  15. data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
  16. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  17. data/lib/active_merchant/billing/gateway.rb +330 -0
  18. data/lib/active_merchant/billing/gateways.rb +14 -0
  19. data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
  20. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  23. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
  24. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  25. data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
  26. data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
  27. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  28. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  29. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -0
  30. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  31. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +217 -0
  33. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
  34. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  35. data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
  36. data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
  37. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  38. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  39. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  40. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -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 +316 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -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 +327 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  59. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  60. data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
  61. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  62. data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
  63. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  64. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  65. data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
  68. data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  73. data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
  74. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  75. data/lib/active_merchant/billing/gateways/epay.rb +285 -0
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  77. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
  80. data/lib/active_merchant/billing/gateways/exact.rb +224 -0
  81. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -0
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  91. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  92. data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
  96. data/lib/active_merchant/billing/gateways/hps.rb +350 -0
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  99. data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
  100. data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
  101. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  102. data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
  103. data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
  104. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  111. data/lib/active_merchant/billing/gateways/litle.rb +507 -0
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
  121. data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +332 -0
  125. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
  128. data/lib/active_merchant/billing/gateways/monei.rb +338 -0
  129. data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
  130. data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +388 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
  147. data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  152. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  153. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -0
  154. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  155. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  157. data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
  158. data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
  159. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  160. data/lib/active_merchant/billing/gateways/payex.rb +410 -0
  161. data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
  162. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  165. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  166. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  167. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  168. data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
  169. data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
  170. data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
  171. data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
  172. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  175. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  176. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  177. data/lib/active_merchant/billing/gateways/paypal_express.rb +269 -0
  178. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  179. data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
  180. data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
  181. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  182. data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
  183. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  184. data/lib/active_merchant/billing/gateways/pin.rb +234 -0
  185. data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
  186. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  187. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  188. data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
  189. data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
  190. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  191. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  192. data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
  193. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  194. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
  195. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  196. data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
  197. data/lib/active_merchant/billing/gateways/realex.rb +374 -0
  198. data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
  199. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  200. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  201. data/lib/active_merchant/billing/gateways/sage.rb +448 -0
  202. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  203. data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
  204. data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
  205. data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
  206. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
  207. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
  208. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  209. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  210. data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
  211. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  212. data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
  213. data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
  214. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
  215. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
  216. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  218. data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
  219. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  220. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  221. data/lib/active_merchant/billing/gateways/transax.rb +22 -0
  222. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  223. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  224. data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
  225. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  226. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
  227. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
  228. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  229. data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
  230. data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
  231. data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
  232. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  233. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  234. data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
  235. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  236. data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
  237. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  238. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  239. data/lib/active_merchant/billing/model.rb +30 -0
  240. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  241. data/lib/active_merchant/billing/payment_token.rb +21 -0
  242. data/lib/active_merchant/billing/rails.rb +3 -0
  243. data/lib/active_merchant/billing/response.rb +92 -0
  244. data/lib/active_merchant/connection.rb +195 -0
  245. data/lib/active_merchant/country.rb +336 -0
  246. data/lib/active_merchant/empty.rb +20 -0
  247. data/lib/active_merchant/errors.rb +35 -0
  248. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  249. data/lib/active_merchant/network_connection_retries.rb +80 -0
  250. data/lib/active_merchant/post_data.rb +25 -0
  251. data/lib/active_merchant/posts_data.rb +92 -0
  252. data/lib/active_merchant/version.rb +3 -0
  253. data/lib/activemerchant.rb +1 -0
  254. data/lib/certs/cacert.pem +3988 -0
  255. data/lib/support/gateway_support.rb +69 -0
  256. data/lib/support/outbound_hosts.rb +28 -0
  257. data/lib/support/ssl_verify.rb +92 -0
  258. data/lib/support/ssl_version.rb +87 -0
  259. metadata +435 -0
@@ -0,0 +1,194 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class SoEasyPayGateway < Gateway
4
+ self.live_url = self.test_url = 'https://secure.soeasypay.com/gateway.asmx'
5
+ self.money_format = :cents
6
+
7
+ self.supported_countries = [
8
+ 'US', 'CA', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE',
9
+ 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU',
10
+ 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB',
11
+ 'IS', 'NO', 'CH'
12
+ ]
13
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club]
14
+ self.homepage_url = 'http://www.soeasypay.com/'
15
+ self.display_name = 'SoEasyPay'
16
+
17
+ def initialize(options = {})
18
+ requires!(options, :login, :password)
19
+ super
20
+ end
21
+
22
+ def authorize(money, payment_source, options = {})
23
+ if payment_source.respond_to?(:number)
24
+ commit('AuthorizeTransaction', do_authorization(money, payment_source, options), options)
25
+ else
26
+ commit('ReauthorizeTransaction', do_reauthorization(money, payment_source, options), options)
27
+ end
28
+ end
29
+
30
+ def purchase(money, payment_source, options = {})
31
+ if payment_source.respond_to?(:number)
32
+ commit('SaleTransaction', do_sale(money, payment_source, options), options)
33
+ else
34
+ commit('RebillTransaction', do_rebill(money, payment_source, options), options)
35
+ end
36
+ end
37
+
38
+ def capture(money, authorization, options = {})
39
+ commit('CaptureTransaction', do_capture(money, authorization, options), options)
40
+ end
41
+
42
+ def refund(money, authorization, options={})
43
+ commit('RefundTransaction', do_refund(money, authorization, options), options)
44
+ end
45
+
46
+ def void(authorization, options={})
47
+ commit('CancelTransaction', do_void(authorization, options), options)
48
+ end
49
+
50
+ private
51
+
52
+ def do_authorization(money, card, options)
53
+ build_soap('AuthorizeTransaction') do |soap|
54
+ fill_credentials(soap, options)
55
+ fill_order_info(soap, money, options)
56
+ fill_cardholder(soap, card, options)
57
+ fill_card(soap, card)
58
+ end
59
+ end
60
+
61
+ def do_sale(money, card, options)
62
+ build_soap('SaleTransaction') do |soap|
63
+ fill_credentials(soap, options)
64
+ fill_order_info(soap, money, options)
65
+ fill_cardholder(soap, card, options)
66
+ fill_card(soap, card)
67
+ end
68
+ end
69
+
70
+ def do_reauthorization(money, authorization, options)
71
+ build_soap('ReauthorizeTransaction') do |soap|
72
+ fill_credentials(soap, options)
73
+ fill_order_info(soap, money, options)
74
+ fill_transaction_id(soap, authorization)
75
+ end
76
+ end
77
+
78
+ def do_rebill(money, authorization, options)
79
+ build_soap('RebillTransaction') do |soap|
80
+ fill_credentials(soap, options)
81
+ fill_order_info(soap, money, options)
82
+ fill_transaction_id(soap, authorization)
83
+ end
84
+ end
85
+
86
+ def do_capture(money, authorization, options)
87
+ build_soap('CaptureTransaction') do |soap|
88
+ fill_credentials(soap, options)
89
+ fill_order_info(soap, money, options, :no_currency)
90
+ fill_transaction_id(soap, authorization)
91
+ end
92
+ end
93
+
94
+ def do_refund(money, authorization, options)
95
+ build_soap('RefundTransaction') do |soap|
96
+ fill_credentials(soap, options)
97
+ fill_order_info(soap, money, options, :no_currency)
98
+ fill_transaction_id(soap, authorization)
99
+ end
100
+ end
101
+
102
+ def do_void(authorization, options)
103
+ build_soap('CancelTransaction') do |soap|
104
+ fill_credentials(soap, options)
105
+ fill_transaction_id(soap, authorization)
106
+ end
107
+ end
108
+
109
+ def fill_credentials(soap, options)
110
+ soap.tag!('websiteID', @options[:login].to_s)
111
+ soap.tag!('password', @options[:password].to_s)
112
+ end
113
+
114
+ def fill_cardholder(soap, card, options)
115
+ ch_info = options[:billing_address] || options[:address]
116
+
117
+ soap.tag!('customerIP', options[:ip].to_s)
118
+ name = card.name || ch_info[:name]
119
+ soap.tag!('cardHolderName', name.to_s)
120
+ address = ch_info[:address1] || ''
121
+ address << ch_info[:address2] if ch_info[:address2]
122
+ soap.tag!('cardHolderAddress', address.to_s)
123
+ soap.tag!('cardHolderZipcode', ch_info[:zip].to_s)
124
+ soap.tag!('cardHolderCity', ch_info[:city].to_s)
125
+ soap.tag!('cardHolderState', ch_info[:state].to_s)
126
+ soap.tag!('cardHolderCountryCode', ch_info[:country].to_s)
127
+ soap.tag!('cardHolderPhone', ch_info[:phone].to_s)
128
+ soap.tag!('cardHolderEmail', options[:email].to_s)
129
+ end
130
+
131
+ def fill_transaction_id(soap, transaction_id)
132
+ soap.tag!('transactionID', transaction_id.to_s)
133
+ end
134
+
135
+ def fill_card(soap, card)
136
+ soap.tag!('cardNumber', card.number.to_s)
137
+ soap.tag!('cardSecurityCode', card.verification_value.to_s)
138
+ soap.tag!('cardExpireMonth', card.month.to_s.rjust(2, '0'))
139
+ soap.tag!('cardExpireYear', card.year.to_s)
140
+ end
141
+
142
+ def fill_order_info(soap, money, options, skip_currency=false)
143
+ soap.tag!('orderID', options[:order_id].to_s)
144
+ soap.tag!('orderDescription', "Order #{options[:order_id]}")
145
+ soap.tag!('amount', amount(money).to_s)
146
+ soap.tag!('currency', (options[:currency] || currency(money)).to_s) unless skip_currency
147
+ end
148
+
149
+ def parse(response, action)
150
+ result = {}
151
+ document = REXML::Document.new(response)
152
+ response_element = document.root.get_elements("//[@xsi:type='tns:#{action}Response']").first
153
+ response_element.elements.each do |element|
154
+ result[element.name.underscore] = element.text
155
+ end
156
+ result
157
+ end
158
+
159
+ def commit(soap_action, soap, options)
160
+ headers = {'SOAPAction' => "\"urn:Interface##{soap_action}\"",
161
+ 'Content-Type' => 'text/xml; charset=utf-8'}
162
+ response_string = ssl_post(test? ? self.test_url : self.live_url, soap, headers)
163
+ response = parse(response_string, soap_action)
164
+ return Response.new(response['errorcode'] == '000',
165
+ response['errormessage'],
166
+ response,
167
+ :test => test?,
168
+ :authorization => response['transaction_id'])
169
+ end
170
+
171
+ def build_soap(request)
172
+ retval = Builder::XmlMarkup.new(:indent => 2)
173
+ retval.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
174
+ retval.tag!('soap:Envelope', {
175
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
176
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
177
+ 'xmlns:soapenc' => 'http://schemas.xmlsoap.org/soap/encoding/',
178
+ 'xmlns:tns' => 'urn:Interface',
179
+ 'xmlns:types' => 'urn:Interface/encodedTypes',
180
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/'}) do
181
+ retval.tag!('soap:Body', {'soap:encodingStyle'=>'http://schemas.xmlsoap.org/soap/encoding/'}) do
182
+ retval.tag!("tns:#{request}") do
183
+ retval.tag!("#{request}Request", {'xsi:type'=>"tns:#{request}Request"}) do
184
+ yield retval
185
+ end
186
+ end
187
+ end
188
+ end
189
+ retval.target!
190
+ end
191
+
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,306 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # Public: This gateway allows you to interact with any gateway you've
6
+ # created in Spreedly (https://spreedly.com). It's an adapter which can be
7
+ # particularly useful if you already have code interacting with
8
+ # ActiveMerchant and want to easily take advantage of Spreedly's vault.
9
+ class SpreedlyCoreGateway < Gateway
10
+ self.live_url = 'https://core.spreedly.com/v1'
11
+
12
+ self.supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK EE EG ES FI FR GB
13
+ GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC
14
+ MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM
15
+ TR TT UM US VA VN ZA)
16
+
17
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
18
+ self.homepage_url = 'https://spreedly.com'
19
+ self.display_name = 'Spreedly'
20
+ self.money_format = :cents
21
+ self.default_currency = 'USD'
22
+
23
+ # Public: Create a new Spreedly gateway.
24
+ #
25
+ # options - A hash of options:
26
+ # :login - The environment key.
27
+ # :password - The access secret.
28
+ # :gateway_token - The token of the gateway you've created in
29
+ # Spreedly.
30
+ def initialize(options = {})
31
+ requires!(options, :login, :password, :gateway_token)
32
+ super
33
+ end
34
+
35
+ # Public: Run a purchase transaction.
36
+ #
37
+ # money - The monetary amount of the transaction in cents.
38
+ # payment_method - The CreditCard or Check or the Spreedly payment method token.
39
+ # options - A hash of options:
40
+ # :store - Retain the payment method if the purchase
41
+ # succeeds. Defaults to false. (optional)
42
+ def purchase(money, payment_method, options = {})
43
+ request = build_transaction_request(money, payment_method, options)
44
+ commit("gateways/#{options[:gateway_token] || @options[:gateway_token]}/purchase.xml", request)
45
+ end
46
+
47
+ # Public: Run an authorize transaction.
48
+ #
49
+ # money - The monetary amount of the transaction in cents.
50
+ # payment_method - The CreditCard or the Spreedly payment method token.
51
+ # options - A hash of options:
52
+ # :store - Retain the payment method if the authorize
53
+ # succeeds. Defaults to false. (optional)
54
+ def authorize(money, payment_method, options = {})
55
+ request = build_transaction_request(money, payment_method, options)
56
+ commit("gateways/#{@options[:gateway_token]}/authorize.xml", request)
57
+ end
58
+
59
+ def capture(money, authorization, options={})
60
+ request = build_xml_request('transaction') do |doc|
61
+ add_invoice(doc, money, options)
62
+ end
63
+
64
+ commit("transactions/#{authorization}/capture.xml", request)
65
+ end
66
+
67
+ def refund(money, authorization, options={})
68
+ request = build_xml_request('transaction') do |doc|
69
+ add_invoice(doc, money, options)
70
+ add_extra_options(:gateway_specific_fields, doc, options)
71
+ end
72
+
73
+ commit("transactions/#{authorization}/credit.xml", request)
74
+ end
75
+
76
+ def void(authorization, options={})
77
+ commit("transactions/#{authorization}/void.xml", '')
78
+ end
79
+
80
+ # Public: Determine whether a credit card is chargeable card and available for purchases.
81
+ #
82
+ # payment_method - The CreditCard or the Spreedly payment method token.
83
+ # options - A hash of options:
84
+ # :store - Retain the payment method if the verify
85
+ # succeeds. Defaults to false. (optional)
86
+ def verify(payment_method, options = {})
87
+ if payment_method.is_a?(String)
88
+ verify_with_token(payment_method, options)
89
+ else
90
+ MultiResponse.run do |r|
91
+ r.process { save_card(options[:store], payment_method, options) }
92
+ r.process { verify_with_token(r.authorization, options) }
93
+ end
94
+ end
95
+ end
96
+
97
+ # Public: Store a credit card in the Spreedly vault and retain it.
98
+ #
99
+ # credit_card - The CreditCard to store
100
+ # options - A standard ActiveMerchant options hash
101
+ def store(credit_card, options={})
102
+ retain = (options.has_key?(:retain) ? options[:retain] : true)
103
+ save_card(retain, credit_card, options)
104
+ end
105
+
106
+ # Public: Redact the CreditCard in Spreedly. This wipes the sensitive
107
+ # payment information from the card.
108
+ #
109
+ # credit_card - The CreditCard to store
110
+ # options - A standard ActiveMerchant options hash
111
+ def unstore(authorization, options={})
112
+ commit("payment_methods/#{authorization}/redact.xml", '', :put)
113
+ end
114
+
115
+ # Public: Get the transaction with the given token.
116
+ def find(transaction_token)
117
+ commit("transactions/#{transaction_token}.xml", nil, :get)
118
+ end
119
+
120
+ alias_method :status, :find
121
+
122
+ def supports_scrubbing?
123
+ true
124
+ end
125
+
126
+ def scrub(transcript)
127
+ transcript.
128
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
129
+ gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2').
130
+ gsub(%r((<verification_value>).+(</verification_value>)), '\1[FILTERED]\2').
131
+ gsub(%r((<payment_method_token>).+(</payment_method_token>)), '\1[FILTERED]\2')
132
+ end
133
+
134
+ private
135
+
136
+ def save_card(retain, credit_card, options)
137
+ request = build_xml_request('payment_method') do |doc|
138
+ add_credit_card(doc, credit_card, options)
139
+ add_extra_options(:data, doc, options)
140
+ doc.retained(true) if retain
141
+ end
142
+
143
+ commit('payment_methods.xml', request, :post, :payment_method_token)
144
+ end
145
+
146
+ def purchase_with_token(money, payment_method_token, options)
147
+ request = build_transaction_request(money, payment_method_token, options)
148
+ commit("gateways/#{options[:gateway_token] || @options[:gateway_token]}/purchase.xml", request)
149
+ end
150
+
151
+ def authorize_with_token(money, payment_method_token, options)
152
+ request = build_transaction_request(money, payment_method_token, options)
153
+ commit("gateways/#{@options[:gateway_token]}/authorize.xml", request)
154
+ end
155
+
156
+ def verify_with_token(payment_method_token, options)
157
+ request = build_transaction_request(nil, payment_method_token, options)
158
+ commit("gateways/#{@options[:gateway_token]}/verify.xml", request)
159
+ end
160
+
161
+ def build_transaction_request(money, payment_method, options)
162
+ build_xml_request('transaction') do |doc|
163
+ add_invoice(doc, money, options)
164
+ add_payment_method(doc, payment_method, options)
165
+ add_extra_options(:gateway_specific_fields, doc, options)
166
+ end
167
+ end
168
+
169
+ def add_invoice(doc, money, options)
170
+ doc.amount amount(money) unless money.nil?
171
+ doc.currency_code(options[:currency] || currency(money) || default_currency)
172
+ doc.order_id(options[:order_id])
173
+ doc.ip(options[:ip]) if options[:ip]
174
+ doc.description(options[:description]) if options[:description]
175
+
176
+ if options[:merchant_name_descriptor]
177
+ doc.merchant_name_descriptor(options[:merchant_name_descriptor])
178
+ end
179
+ if options[:merchant_location_descriptor]
180
+ doc.merchant_location_descriptor(options[:merchant_location_descriptor])
181
+ end
182
+ end
183
+
184
+ def add_payment_method(doc, payment_method, options)
185
+ doc.retain_on_success(true) if options[:store]
186
+
187
+ if payment_method.is_a?(String)
188
+ doc.payment_method_token(payment_method)
189
+ elsif payment_method.is_a?(CreditCard)
190
+ add_credit_card(doc, payment_method, options)
191
+ elsif payment_method.is_a?(Check)
192
+ add_bank_account(doc, payment_method, options)
193
+ else
194
+ raise TypeError, 'Payment method not supported'
195
+ end
196
+ end
197
+
198
+ def add_credit_card(doc, credit_card, options)
199
+ doc.credit_card do
200
+ doc.number(credit_card.number)
201
+ doc.verification_value(credit_card.verification_value)
202
+ doc.first_name(credit_card.first_name)
203
+ doc.last_name(credit_card.last_name)
204
+ doc.month(credit_card.month)
205
+ doc.year(credit_card.year)
206
+ doc.email(options[:email])
207
+ doc.address1(options[:billing_address].try(:[], :address1))
208
+ doc.address2(options[:billing_address].try(:[], :address2))
209
+ doc.city(options[:billing_address].try(:[], :city))
210
+ doc.state(options[:billing_address].try(:[], :state))
211
+ doc.zip(options[:billing_address].try(:[], :zip))
212
+ doc.country(options[:billing_address].try(:[], :country))
213
+ end
214
+ end
215
+
216
+ def add_bank_account(doc, bank_account, options)
217
+ doc.bank_account do
218
+ doc.first_name(bank_account.first_name)
219
+ doc.last_name(bank_account.last_name)
220
+ doc.bank_routing_number(bank_account.routing_number)
221
+ doc.bank_account_number(bank_account.account_number)
222
+ doc.bank_account_type(bank_account.account_type)
223
+ doc.bank_account_holder_type(bank_account.account_holder_type)
224
+ end
225
+ end
226
+
227
+ def add_extra_options(type, doc, options)
228
+ doc.send(type) do
229
+ extra_options_to_doc(doc, options[type])
230
+ end
231
+ end
232
+
233
+ def extra_options_to_doc(doc, value)
234
+ return doc.text value unless value.kind_of? Hash
235
+ value.each do |k, v|
236
+ doc.send(k) do
237
+ extra_options_to_doc(doc, v)
238
+ end
239
+ end
240
+ end
241
+
242
+ def parse(xml)
243
+ response = {}
244
+
245
+ doc = Nokogiri::XML(xml)
246
+ doc.root.xpath('*').each do |node|
247
+ if node.elements.empty?
248
+ response[node.name.downcase.to_sym] = node.text
249
+ else
250
+ node.elements.each do |childnode|
251
+ childnode_to_response(response, node, childnode)
252
+ end
253
+ end
254
+ end
255
+
256
+ response
257
+ end
258
+
259
+ def childnode_to_response(response, node, childnode)
260
+ name = "#{node.name.downcase}_#{childnode.name.downcase}"
261
+ if name == 'payment_method_data' && !childnode.elements.empty?
262
+ response[name.to_sym] = Hash.from_xml(childnode.to_s).values.first
263
+ else
264
+ response[name.to_sym] = childnode.text
265
+ end
266
+ end
267
+
268
+ def build_xml_request(root)
269
+ builder = Nokogiri::XML::Builder.new
270
+ builder.__send__(root) do |doc|
271
+ yield(doc)
272
+ end
273
+ builder.to_xml
274
+ end
275
+
276
+ def commit(relative_url, request, method = :post, authorization_field = :token)
277
+ begin
278
+ raw_response = ssl_request(method, "#{live_url}/#{relative_url}", request, headers)
279
+ rescue ResponseError => e
280
+ raw_response = e.response.body
281
+ end
282
+
283
+ response_from(raw_response, authorization_field)
284
+ end
285
+
286
+ def response_from(raw_response, authorization_field)
287
+ parsed = parse(raw_response)
288
+ options = {
289
+ :authorization => parsed[authorization_field],
290
+ :test => (parsed[:on_test_gateway] == 'true'),
291
+ :avs_result => { :code => parsed[:response_avs_code] },
292
+ :cvv_result => parsed[:response_cvv_code]
293
+ }
294
+
295
+ Response.new(parsed[:succeeded] == 'true', parsed[:message] || parsed[:error], parsed, options)
296
+ end
297
+
298
+ def headers
299
+ {
300
+ 'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:login]}:#{@options[:password]}").chomp),
301
+ 'Content-Type' => 'text/xml'
302
+ }
303
+ end
304
+ end
305
+ end
306
+ end