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,162 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class InstapayGateway < Gateway
4
+ self.live_url = 'https://trans.instapaygateway.com/cgi-bin/process.cgi'
5
+
6
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
7
+ self.supported_countries = ['US']
8
+ self.money_format = :dollars
9
+ self.default_currency = 'USD'
10
+ # The card types supported by the payment gateway
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
12
+
13
+ # The homepage URL of the gateway
14
+ self.homepage_url = 'http://www.instapayllc.com'
15
+
16
+ # The name of the gateway
17
+ self.display_name = 'InstaPay'
18
+
19
+ SUCCESS = 'Accepted'
20
+ SUCCESS_MESSAGE = 'The transaction has been approved'
21
+
22
+ def initialize(options = {})
23
+ requires!(options, :login)
24
+ super
25
+ end
26
+
27
+ def authorize(money, creditcard, options = {})
28
+ post = {}
29
+ post[:authonly] = 1
30
+ add_amount(post, money)
31
+ add_invoice(post, options)
32
+ add_creditcard(post, creditcard)
33
+ add_address(post, options)
34
+ add_customer_data(post, options)
35
+
36
+ commit('ns_quicksale_cc', post)
37
+ end
38
+
39
+ def purchase(money, creditcard, options = {})
40
+ post = {}
41
+ add_amount(post, money)
42
+ add_invoice(post, options)
43
+ add_creditcard(post, creditcard)
44
+ add_address(post, options)
45
+ add_customer_data(post, options)
46
+
47
+ commit('ns_quicksale_cc', post)
48
+ end
49
+
50
+ def capture(money, authorization, options = {})
51
+ post = {}
52
+ add_amount(post, money)
53
+ add_reference(post, authorization)
54
+ commit('ns_quicksale_cc', post)
55
+ end
56
+
57
+ private
58
+
59
+ def add_amount(post, money)
60
+ post[:amount] = amount(money)
61
+ end
62
+
63
+ def add_reference(post, reference)
64
+ post[:postonly] = reference
65
+ end
66
+
67
+ def add_customer_data(post, options)
68
+ post[:ci_email] = options[:email]
69
+ post['ci_IP Address'] = options[:ip]
70
+ end
71
+
72
+ def add_address(post, options)
73
+ if address = options[:billing_address] || options[:address]
74
+ post[:ci_billaddr1] = address[:address1]
75
+ post[:ci_billaddr2] = address[:address2]
76
+ post[:ci_billcity] = address[:city]
77
+ post[:ci_billstate] = address[:state]
78
+ post[:ci_billzip] = address[:zip]
79
+ post[:ci_billcountry] = address[:country]
80
+ post[:ci_phone] = address[:phone]
81
+ end
82
+
83
+ if address = options[:shipping_address]
84
+ post[:ci_shipaddr1] = address[:address1]
85
+ post[:ci_shipaddr2] = address[:address2]
86
+ post[:ci_shipcity] = address[:city]
87
+ post[:ci_shipstate] = address[:state]
88
+ post[:ci_shipzip] = address[:zip]
89
+ post[:ci_shipcountry] = address[:country]
90
+ end
91
+ end
92
+
93
+ def add_invoice(post, options)
94
+ post[:merchantordernumber] = options[:order_id]
95
+ post[:ci_memo] = options[:description]
96
+ post[:pocustomerrefid] = options[:invoice]
97
+ end
98
+
99
+ def add_creditcard(post, creditcard)
100
+ post[:ccnum] = creditcard.number
101
+ post[:expmon] = format(creditcard.month, :two_digits)
102
+ post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
103
+ post[:expyear] = creditcard.year
104
+ post[:ccname] = creditcard.name
105
+ end
106
+
107
+ def parse(body)
108
+ results = {}
109
+ fields = body.split("\r\n")
110
+
111
+ response = fields[1].split('=')
112
+ response_data = response[1].split(':')
113
+
114
+ if response[0] == SUCCESS
115
+ results[:success] = true
116
+ results[:message] = SUCCESS_MESSAGE
117
+ results[:transaction_type] = response_data[0]
118
+ results[:authorization_code] = response_data[1]
119
+ results[:reference_number] = response_data[2]
120
+ results[:batch_number] = response_data[3]
121
+ results[:transaction_id] = response_data[4]
122
+ results[:avs_result] = response_data[5]
123
+ results[:authorize_net] = response_data[6]
124
+ results[:cvv_result] = response_data[7]
125
+ else
126
+ results[:success] = false
127
+ results[:result] = response_data[0]
128
+ results[:response_code] = response_data[1]
129
+ results[:message] = response_data[2]
130
+ end
131
+
132
+ fields[1..-1].each do |pair|
133
+ key, value = pair.split('=')
134
+ results[key] = value
135
+ end
136
+ results
137
+ end
138
+
139
+ def commit(action, parameters)
140
+ data = ssl_post self.live_url, post_data(action, parameters)
141
+ response = parse(data)
142
+
143
+ Response.new(response[:success], response[:message], response,
144
+ :authorization => response[:transaction_id],
145
+ :avs_result => { :code => response[:avs_result] },
146
+ :cvv_result => response[:cvv_result]
147
+ )
148
+ end
149
+
150
+ def post_data(action, parameters = {})
151
+ post = {}
152
+ post[:acctid] = @options[:login]
153
+ if(@options[:password])
154
+ post[:merchantpin] = @options[:password]
155
+ end
156
+ post[:action] = action
157
+ request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
158
+ request
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,176 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class IppGateway < Gateway
6
+ self.live_url = 'https://www.ippayments.com.au/interface/api/dts.asmx'
7
+ self.test_url = 'https://demo.ippayments.com.au/interface/api/dts.asmx'
8
+
9
+ self.supported_countries = ['AU']
10
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
11
+
12
+ self.homepage_url = 'http://www.ippayments.com.au/'
13
+ self.display_name = 'IPP'
14
+
15
+ self.money_format = :cents
16
+
17
+ STANDARD_ERROR_CODE_MAPPING = {
18
+ '05' => STANDARD_ERROR_CODE[:card_declined],
19
+ '06' => STANDARD_ERROR_CODE[:processing_error],
20
+ '14' => STANDARD_ERROR_CODE[:invalid_number],
21
+ '54' => STANDARD_ERROR_CODE[:expired_card],
22
+ }
23
+
24
+ def initialize(options={})
25
+ ActiveMerchant.deprecated('IPP gateway is now named Bambora Asia-Pacific')
26
+ requires!(options, :username, :password)
27
+ super
28
+ end
29
+
30
+ def purchase(money, payment, options={})
31
+ commit('SubmitSinglePayment') do |xml|
32
+ xml.Transaction do
33
+ xml.CustRef options[:order_id]
34
+ add_amount(xml, money)
35
+ xml.TrnType '1'
36
+ add_credit_card(xml, payment)
37
+ add_credentials(xml)
38
+ xml.TrnSource options[:ip]
39
+ end
40
+ end
41
+ end
42
+
43
+ def authorize(money, payment, options={})
44
+ commit('SubmitSinglePayment') do |xml|
45
+ xml.Transaction do
46
+ xml.CustRef options[:order_id]
47
+ add_amount(xml, money)
48
+ xml.TrnType '2'
49
+ add_credit_card(xml, payment)
50
+ add_credentials(xml)
51
+ xml.TrnSource options[:ip]
52
+ end
53
+ end
54
+ end
55
+
56
+ def capture(money, authorization, options={})
57
+ commit('SubmitSingleCapture') do |xml|
58
+ xml.Capture do
59
+ xml.Receipt authorization
60
+ add_amount(xml, money)
61
+ add_credentials(xml)
62
+ end
63
+ end
64
+ end
65
+
66
+ def refund(money, authorization, options={})
67
+ commit('SubmitSingleRefund') do |xml|
68
+ xml.Refund do
69
+ xml.Receipt authorization
70
+ add_amount(xml, money)
71
+ add_credentials(xml)
72
+ end
73
+ end
74
+ end
75
+
76
+ def supports_scrubbing?
77
+ true
78
+ end
79
+
80
+ def scrub(transcript)
81
+ transcript.
82
+ gsub(%r((<CardNumber>)[^<]+(<))i, '\1[FILTERED]\2').
83
+ gsub(%r((<CVN>)[^<]+(<))i, '\1[FILTERED]\2').
84
+ gsub(%r((<Password>)[^<]+(<))i, '\1[FILTERED]\2')
85
+ end
86
+
87
+ private
88
+
89
+ def add_credentials(xml)
90
+ xml.Security do
91
+ xml.UserName @options[:username]
92
+ xml.Password @options[:password]
93
+ end
94
+ end
95
+
96
+ def add_amount(xml, money)
97
+ xml.Amount amount(money)
98
+ end
99
+
100
+ def add_credit_card(xml, payment)
101
+ xml.CreditCard :Registered => 'False' do
102
+ xml.CardNumber payment.number
103
+ xml.ExpM format(payment.month, :two_digits)
104
+ xml.ExpY format(payment.year, :four_digits)
105
+ xml.CVN payment.verification_value
106
+ xml.CardHolderName payment.name
107
+ end
108
+ end
109
+
110
+ def parse(body)
111
+ element = Nokogiri::XML(body).root.first_element_child.first_element_child
112
+
113
+ response = {}
114
+ doc = Nokogiri::XML(element)
115
+ doc.root.elements.each do |e|
116
+ response[e.name.underscore.to_sym] = e.inner_text
117
+ end
118
+ response
119
+ end
120
+
121
+ def commit(action, &block)
122
+ headers = {
123
+ 'Content-Type' => 'text/xml; charset=utf-8',
124
+ 'SOAPAction' => "http://www.ippayments.com.au/interface/api/dts/#{action}",
125
+ }
126
+ response = parse(ssl_post(commit_url, new_submit_xml(action, &block), headers))
127
+
128
+ Response.new(
129
+ success_from(response),
130
+ message_from(response),
131
+ response,
132
+ authorization: authorization_from(response),
133
+ error_code: error_code_from(response),
134
+ test: test?
135
+ )
136
+ end
137
+
138
+ def new_submit_xml(action)
139
+ xml = Builder::XmlMarkup.new(indent: 2)
140
+ xml.instruct!
141
+ xml.soap :Envelope, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' do
142
+ xml.soap :Body do
143
+ xml.__send__(action, 'xmlns' => 'http://www.ippayments.com.au/interface/api/dts') do
144
+ xml.trnXML do
145
+ inner_xml = Builder::XmlMarkup.new(indent: 2)
146
+ yield(inner_xml)
147
+ xml.cdata!(inner_xml.target!)
148
+ end
149
+ end
150
+ end
151
+ end
152
+ xml.target!
153
+ end
154
+
155
+ def commit_url
156
+ (test? ? test_url : live_url)
157
+ end
158
+
159
+ def success_from(response)
160
+ (response[:response_code] == '0')
161
+ end
162
+
163
+ def error_code_from(response)
164
+ STANDARD_ERROR_CODE_MAPPING[response[:declined_code]]
165
+ end
166
+
167
+ def message_from(response)
168
+ response[:declined_message]
169
+ end
170
+
171
+ def authorization_from(response)
172
+ response[:receipt]
173
+ end
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,468 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # For more information on the Iridium Gateway please download the
4
+ # documentation from their Merchant Management System.
5
+ #
6
+ # The login and password are not the username and password you use to
7
+ # login to the Iridium Merchant Management System. Instead, you will
8
+ # use the API username and password you were issued separately.
9
+ class IridiumGateway < Gateway
10
+ self.live_url = self.test_url = 'https://gw1.iridiumcorp.net/'
11
+
12
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
13
+ self.supported_countries = ['GB', 'ES']
14
+ self.default_currency = 'EUR'
15
+ self.money_format = :cents
16
+
17
+ # The card types supported by the payment gateway
18
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club]
19
+
20
+ # The homepage URL of the gateway
21
+ self.homepage_url = 'http://www.iridiumcorp.co.uk/'
22
+
23
+ # The name of the gateway
24
+ self.display_name = 'Iridium'
25
+
26
+ CURRENCY_CODES = {
27
+ 'AED' => '784',
28
+ 'AFN' => '971',
29
+ 'ALL' => '008',
30
+ 'AMD' => '051',
31
+ 'ANG' => '532',
32
+ 'AOA' => '973',
33
+ 'ARS' => '032',
34
+ 'AUD' => '036',
35
+ 'AWG' => '533',
36
+ 'AZN' => '944',
37
+ 'BAM' => '977',
38
+ 'BBD' => '052',
39
+ 'BDT' => '050',
40
+ 'BGN' => '975',
41
+ 'BHD' => '048',
42
+ 'BIF' => '108',
43
+ 'BMD' => '060',
44
+ 'BND' => '096',
45
+ 'BOB' => '068',
46
+ 'BOV' => '984',
47
+ 'BRL' => '986',
48
+ 'BSD' => '044',
49
+ 'BTN' => '064',
50
+ 'BWP' => '072',
51
+ 'BYR' => '974',
52
+ 'BZD' => '084',
53
+ 'CAD' => '124',
54
+ 'CDF' => '976',
55
+ 'CHE' => '947',
56
+ 'CHF' => '756',
57
+ 'CHW' => '948',
58
+ 'CLF' => '990',
59
+ 'CLP' => '152',
60
+ 'CNY' => '156',
61
+ 'COP' => '170',
62
+ 'COU' => '970',
63
+ 'CRC' => '188',
64
+ 'CUP' => '192',
65
+ 'CVE' => '132',
66
+ 'CYP' => '196',
67
+ 'CZK' => '203',
68
+ 'DJF' => '262',
69
+ 'DKK' => '208',
70
+ 'DOP' => '214',
71
+ 'DZD' => '012',
72
+ 'EEK' => '233',
73
+ 'EGP' => '818',
74
+ 'ERN' => '232',
75
+ 'ETB' => '230',
76
+ 'EUR' => '978',
77
+ 'FJD' => '242',
78
+ 'FKP' => '238',
79
+ 'GBP' => '826',
80
+ 'GEL' => '981',
81
+ 'GHS' => '288',
82
+ 'GIP' => '292',
83
+ 'GMD' => '270',
84
+ 'GNF' => '324',
85
+ 'GTQ' => '320',
86
+ 'GYD' => '328',
87
+ 'HKD' => '344',
88
+ 'HNL' => '340',
89
+ 'HRK' => '191',
90
+ 'HTG' => '332',
91
+ 'HUF' => '348',
92
+ 'IDR' => '360',
93
+ 'ILS' => '376',
94
+ 'INR' => '356',
95
+ 'IQD' => '368',
96
+ 'IRR' => '364',
97
+ 'ISK' => '352',
98
+ 'JMD' => '388',
99
+ 'JOD' => '400',
100
+ 'JPY' => '392',
101
+ 'KES' => '404',
102
+ 'KGS' => '417',
103
+ 'KHR' => '116',
104
+ 'KMF' => '174',
105
+ 'KPW' => '408',
106
+ 'KRW' => '410',
107
+ 'KWD' => '414',
108
+ 'KYD' => '136',
109
+ 'KZT' => '398',
110
+ 'LAK' => '418',
111
+ 'LBP' => '422',
112
+ 'LKR' => '144',
113
+ 'LRD' => '430',
114
+ 'LSL' => '426',
115
+ 'LTL' => '440',
116
+ 'LVL' => '428',
117
+ 'LYD' => '434',
118
+ 'MAD' => '504',
119
+ 'MDL' => '498',
120
+ 'MGA' => '969',
121
+ 'MKD' => '807',
122
+ 'MMK' => '104',
123
+ 'MNT' => '496',
124
+ 'MOP' => '446',
125
+ 'MRO' => '478',
126
+ 'MTL' => '470',
127
+ 'MUR' => '480',
128
+ 'MVR' => '462',
129
+ 'MWK' => '454',
130
+ 'MXN' => '484',
131
+ 'MXV' => '979',
132
+ 'MYR' => '458',
133
+ 'MZN' => '943',
134
+ 'NAD' => '516',
135
+ 'NGN' => '566',
136
+ 'NIO' => '558',
137
+ 'NOK' => '578',
138
+ 'NPR' => '524',
139
+ 'NZD' => '554',
140
+ 'OMR' => '512',
141
+ 'PAB' => '590',
142
+ 'PEN' => '604',
143
+ 'PGK' => '598',
144
+ 'PHP' => '608',
145
+ 'PKR' => '586',
146
+ 'PLN' => '985',
147
+ 'PYG' => '600',
148
+ 'QAR' => '634',
149
+ 'ROL' => '642',
150
+ 'RON' => '946',
151
+ 'RSD' => '941',
152
+ 'RUB' => '643',
153
+ 'RWF' => '646',
154
+ 'SAR' => '682',
155
+ 'SBD' => '090',
156
+ 'SCR' => '690',
157
+ 'SDG' => '938',
158
+ 'SEK' => '752',
159
+ 'SGD' => '702',
160
+ 'SHP' => '654',
161
+ 'SKK' => '703',
162
+ 'SLL' => '694',
163
+ 'SOS' => '706',
164
+ 'SRD' => '968',
165
+ 'STD' => '678',
166
+ 'SYP' => '760',
167
+ 'SZL' => '748',
168
+ 'THB' => '764',
169
+ 'TJS' => '972',
170
+ 'TMM' => '795',
171
+ 'TND' => '788',
172
+ 'TOP' => '776',
173
+ 'TRY' => '949',
174
+ 'TTD' => '780',
175
+ 'TWD' => '901',
176
+ 'TZS' => '834',
177
+ 'UAH' => '980',
178
+ 'UGX' => '800',
179
+ 'USD' => '840',
180
+ 'USN' => '997',
181
+ 'USS' => '998',
182
+ 'UYU' => '858',
183
+ 'UZS' => '860',
184
+ 'VEB' => '862',
185
+ 'VND' => '704',
186
+ 'VUV' => '548',
187
+ 'WST' => '882',
188
+ 'XAF' => '950',
189
+ 'XAG' => '961',
190
+ 'XAU' => '959',
191
+ 'XBA' => '955',
192
+ 'XBB' => '956',
193
+ 'XBC' => '957',
194
+ 'XBD' => '958',
195
+ 'XCD' => '951',
196
+ 'XDR' => '960',
197
+ 'XOF' => '952',
198
+ 'XPD' => '964',
199
+ 'XPF' => '953',
200
+ 'XPT' => '962',
201
+ 'XTS' => '963',
202
+ 'XXX' => '999',
203
+ 'YER' => '886',
204
+ 'ZAR' => '710',
205
+ 'ZMK' => '894',
206
+ 'ZWD' => '716',
207
+ }
208
+
209
+ AVS_CODE = {
210
+ 'PASSED' => 'Y',
211
+ 'FAILED' => 'N',
212
+ 'PARTIAL' => 'X',
213
+ 'NOT_CHECKED' => 'X',
214
+ 'UNKNOWN' => 'X'
215
+ }
216
+
217
+ CVV_CODE = {
218
+ 'PASSED' => 'M',
219
+ 'FAILED' => 'N',
220
+ 'PARTIAL' => 'I',
221
+ 'NOT_CHECKED' => 'P',
222
+ 'UNKNOWN' => 'U'
223
+ }
224
+
225
+ def initialize(options = {})
226
+ requires!(options, :login, :password)
227
+ super
228
+ end
229
+
230
+ def authorize(money, payment_source, options = {})
231
+ setup_address_hash(options)
232
+
233
+ if payment_source.respond_to?(:number)
234
+ commit(build_purchase_request('PREAUTH', money, payment_source, options), options)
235
+ else
236
+ commit(build_reference_request('PREAUTH', money, payment_source, options), options)
237
+ end
238
+ end
239
+
240
+ def purchase(money, payment_source, options = {})
241
+ setup_address_hash(options)
242
+
243
+ if payment_source.respond_to?(:number)
244
+ commit(build_purchase_request('SALE', money, payment_source, options), options)
245
+ else
246
+ commit(build_reference_request('SALE', money, payment_source, options), options)
247
+ end
248
+ end
249
+
250
+ def capture(money, authorization, options = {})
251
+ commit(build_reference_request('COLLECTION', money, authorization, options), options)
252
+ end
253
+
254
+ def credit(money, authorization, options={})
255
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
256
+ refund(money, authorization, options)
257
+ end
258
+
259
+ def refund(money, authorization, options={})
260
+ commit(build_reference_request('REFUND', money, authorization, options), options)
261
+ end
262
+
263
+ def void(authorization, options={})
264
+ commit(build_reference_request('VOID', nil, authorization, options), options)
265
+ end
266
+
267
+ def supports_scrubbing
268
+ true
269
+ end
270
+
271
+ def scrub(transcript)
272
+ transcript.
273
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
274
+ gsub(%r((<CardNumber>)\d+(</CardNumber>)), '\1[FILTERED]\2').
275
+ gsub(%r((<CV2>)\d+(</CV2>)), '\1[FILTERED]\2')
276
+ end
277
+
278
+ private
279
+
280
+ def build_purchase_request(type, money, creditcard, options)
281
+ options[:action] = 'CardDetailsTransaction'
282
+ build_request(options) do |xml|
283
+ add_purchase_data(xml, type, money, options)
284
+ add_creditcard(xml, creditcard)
285
+ add_customerdetails(xml, creditcard, options[:billing_address], options)
286
+ end
287
+ end
288
+
289
+ def build_reference_request(type, money, authorization, options)
290
+ options[:action] = 'CrossReferenceTransaction'
291
+ order_id, cross_reference, _ = authorization.split(';')
292
+ build_request(options) do |xml|
293
+ if money
294
+ details = {'CurrencyCode' => currency_code(options[:currency] || default_currency), 'Amount' => amount(money)}
295
+ else
296
+ details = {'CurrencyCode' => currency_code(default_currency), 'Amount' => '0'}
297
+ end
298
+ xml.tag! 'TransactionDetails', details do
299
+ xml.tag! 'MessageDetails', {'TransactionType' => type, 'CrossReference' => cross_reference}
300
+ xml.tag! 'OrderID', (options[:order_id] || order_id)
301
+ end
302
+ end
303
+ end
304
+
305
+ def build_request(options)
306
+ requires!(options, :action)
307
+ xml = Builder::XmlMarkup.new :indent => 2
308
+ xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
309
+ xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
310
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
311
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
312
+ xml.tag! 'soap:Body' do
313
+ xml.tag! options[:action], {'xmlns' => 'https://www.thepaymentgateway.net/'} do
314
+ xml.tag! 'PaymentMessage' do
315
+ add_merchant_data(xml, options)
316
+ yield(xml)
317
+ end
318
+ end
319
+ end
320
+ end
321
+ xml.target!
322
+ end
323
+
324
+ def setup_address_hash(options)
325
+ options[:billing_address] = options[:billing_address] || options[:address] || {}
326
+ options[:shipping_address] = options[:shipping_address] || {}
327
+ end
328
+
329
+ def add_purchase_data(xml, type, money, options)
330
+ requires!(options, :order_id)
331
+ xml.tag! 'TransactionDetails', {'Amount' => amount(money), 'CurrencyCode' => currency_code(options[:currency] || currency(money))} do
332
+ xml.tag! 'MessageDetails', {'TransactionType' => type}
333
+ xml.tag! 'OrderID', options[:order_id]
334
+ xml.tag! 'TransactionControl' do
335
+ xml.tag! 'ThreeDSecureOverridePolicy', 'FALSE'
336
+ xml.tag! 'EchoAVSCheckResult', 'TRUE'
337
+ xml.tag! 'EchoCV2CheckResult', 'TRUE'
338
+ end
339
+ end
340
+ end
341
+
342
+ def add_customerdetails(xml, creditcard, address, options, shipTo = false)
343
+ xml.tag! 'CustomerDetails' do
344
+ if address
345
+ unless address[:country].blank?
346
+ country_code = Country.find(address[:country]).code(:numeric)
347
+ end
348
+ xml.tag! 'BillingAddress' do
349
+ xml.tag! 'Address1', address[:address1]
350
+ xml.tag! 'Address2', address[:address2]
351
+ xml.tag! 'City', address[:city]
352
+ xml.tag! 'State', address[:state]
353
+ xml.tag! 'PostCode', address[:zip]
354
+ xml.tag! 'CountryCode', country_code if country_code
355
+ end
356
+ xml.tag! 'PhoneNumber', address[:phone]
357
+ end
358
+
359
+ xml.tag! 'EmailAddress', options[:email]
360
+ xml.tag! 'CustomerIPAddress', options[:ip] || '127.0.0.1'
361
+ end
362
+ end
363
+
364
+ def add_creditcard(xml, creditcard)
365
+ xml.tag! 'CardDetails' do
366
+ xml.tag! 'CardName', creditcard.name
367
+ xml.tag! 'CV2', creditcard.verification_value if creditcard.verification_value
368
+ xml.tag! 'CardNumber', creditcard.number
369
+ xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, '0'), 'Year' => creditcard.year.to_s[/\d\d$/] }
370
+ end
371
+ end
372
+
373
+ def add_merchant_data(xml, options)
374
+ xml.tag! 'MerchantAuthentication', {'MerchantID' => @options[:login], 'Password' => @options[:password]}
375
+ end
376
+
377
+ def commit(request, options)
378
+ requires!(options, :action)
379
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, request,
380
+ {'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action],
381
+ 'Content-Type' => 'text/xml; charset=utf-8' }))
382
+
383
+ success = response[:transaction_result][:status_code] == '0'
384
+ message = response[:transaction_result][:message]
385
+ authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(';') : nil
386
+
387
+ Response.new(success, message, response,
388
+ :test => test?,
389
+ :authorization => authorization,
390
+ :avs_result => {
391
+ :street_match => AVS_CODE[ response[:transaction_output_data][:address_numeric_check_result] ],
392
+ :postal_match => AVS_CODE[ response[:transaction_output_data][:post_code_check_result] ],
393
+ },
394
+ :cvv_result => CVV_CODE[ response[:transaction_output_data][:cv2_check_result] ]
395
+ )
396
+ end
397
+
398
+ def parse(xml)
399
+ reply = {}
400
+ xml = REXML::Document.new(xml)
401
+ if (root = REXML::XPath.first(xml, '//CardDetailsTransactionResponse')) or
402
+ (root = REXML::XPath.first(xml, '//CrossReferenceTransactionResponse'))
403
+ root.elements.to_a.each do |node|
404
+ case node.name
405
+ when 'Message'
406
+ reply[:message] = reply(node.text)
407
+ else
408
+ parse_element(reply, node)
409
+ end
410
+ end
411
+ elsif root = REXML::XPath.first(xml, '//soap:Fault')
412
+ parse_element(reply, root)
413
+ reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}"
414
+ end
415
+ reply
416
+ end
417
+
418
+ def parse_element(reply, node)
419
+ case node.name
420
+ when 'CrossReferenceTransactionResult'
421
+ reply[:transaction_result] = {}
422
+ node.attributes.each do |a, b|
423
+ reply[:transaction_result][a.underscore.to_sym] = b
424
+ end
425
+ node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements?
426
+
427
+ when 'CardDetailsTransactionResult'
428
+ reply[:transaction_result] = {}
429
+ node.attributes.each do |a, b|
430
+ reply[:transaction_result][a.underscore.to_sym] = b
431
+ end
432
+ node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements?
433
+
434
+ when 'TransactionOutputData'
435
+ reply[:transaction_output_data] = {}
436
+ node.attributes.each { |a, b| reply[:transaction_output_data][a.underscore.to_sym] = b }
437
+ node.elements.each { |e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
438
+ when 'CustomVariables'
439
+ reply[:custom_variables] = {}
440
+ node.attributes.each { |a, b| reply[:custom_variables][a.underscore.to_sym] = b }
441
+ node.elements.each { |e| parse_element(reply[:custom_variables], e) } if node.has_elements?
442
+ when 'GatewayEntryPoints'
443
+ reply[:gateway_entry_points] = {}
444
+ node.attributes.each { |a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
445
+ node.elements.each { |e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
446
+ else
447
+ k = node.name.underscore.to_sym
448
+ if node.has_elements?
449
+ reply[k] = {}
450
+ node.elements.each { |e| parse_element(reply[k], e) }
451
+ else
452
+ if node.has_attributes?
453
+ reply[k] = {}
454
+ node.attributes.each { |a, b| reply[k][a.underscore.to_sym] = b }
455
+ else
456
+ reply[k] = node.text
457
+ end
458
+ end
459
+ end
460
+ reply
461
+ end
462
+
463
+ def currency_code(currency)
464
+ CURRENCY_CODES[currency]
465
+ end
466
+ end
467
+ end
468
+ end