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,563 @@
1
+ require 'json'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class EwayRapidGateway < Gateway
6
+ self.test_url = 'https://api.sandbox.ewaypayments.com/'
7
+ self.live_url = 'https://api.ewaypayments.com/'
8
+
9
+ self.money_format = :cents
10
+ self.supported_countries = ['AU', 'NZ', 'GB', 'SG', 'MY', 'HK']
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
12
+ self.homepage_url = 'http://www.eway.com.au/'
13
+ self.display_name = 'eWAY Rapid 3.1'
14
+ self.default_currency = 'AUD'
15
+
16
+ class_attribute :partner_id
17
+
18
+ def initialize(options = {})
19
+ requires!(options, :login, :password)
20
+ super
21
+ end
22
+
23
+ # Public: Run a purchase transaction.
24
+ #
25
+ # amount - The monetary amount of the transaction in cents.
26
+ # payment_method - The payment method or authorization token returned from store.
27
+ # options - A standard ActiveMerchant options hash:
28
+ # :transaction_type - One of: Purchase (default), MOTO
29
+ # or Recurring. For stored card payments (aka - TokenPayments),
30
+ # this must be either MOTO or Recurring.
31
+ # :invoice - The merchant’s invoice number for this
32
+ # transaction (optional).
33
+ # :order_id - A merchant-supplied identifier for the
34
+ # transaction (optional).
35
+ # :description - A merchant-supplied description of the
36
+ # transaction (optional).
37
+ # :currency - Three letter currency code for the
38
+ # transaction (default: "AUD")
39
+ # :billing_address - Standard ActiveMerchant address hash
40
+ # (optional).
41
+ # :shipping_address - Standard ActiveMerchant address hash
42
+ # (optional).
43
+ # :ip - The ip of the consumer initiating the
44
+ # transaction (optional).
45
+ # :application_id - A string identifying the application
46
+ # submitting the transaction
47
+ # (default: "https://github.com/activemerchant/active_merchant")
48
+ #
49
+ # Returns an ActiveMerchant::Billing::Response object where authorization is the Transaction ID on success
50
+ def purchase(amount, payment_method, options={})
51
+ params = {}
52
+ add_metadata(params, options)
53
+ add_invoice(params, amount, options)
54
+ add_customer_data(params, options, payment_method)
55
+ add_credit_card(params, payment_method, options)
56
+ params['Method'] = payment_method.respond_to?(:number) ? 'ProcessPayment' : 'TokenPayment'
57
+ commit(url_for('Transaction'), params)
58
+ end
59
+
60
+ def authorize(amount, payment_method, options={})
61
+ params = {}
62
+ add_metadata(params, options)
63
+ add_invoice(params, amount, options)
64
+ add_customer_data(params, options, payment_method)
65
+ add_credit_card(params, payment_method, options)
66
+ params['Method'] = 'Authorise'
67
+ commit(url_for('Authorisation'), params)
68
+ end
69
+
70
+ def capture(amount, identification, options = {})
71
+ params = {}
72
+ add_metadata(params, options)
73
+ add_invoice(params, amount, options)
74
+ add_reference(params, identification)
75
+ commit(url_for('CapturePayment'), params)
76
+ end
77
+
78
+ def void(identification, options = {})
79
+ params = {}
80
+ add_reference(params, identification)
81
+ commit(url_for('CancelAuthorisation'), params)
82
+ end
83
+
84
+ # Public: Refund a transaction.
85
+ #
86
+ # amount - The monetary amount of the transaction in cents
87
+ # identification - The transaction id which is returned in the
88
+ # authorization of the successful purchase transaction
89
+ # options - A standard ActiveMerchant options hash:
90
+ # :invoice - The merchant’s invoice number for this
91
+ # transaction (optional).
92
+ # :order_id - A merchant-supplied identifier for the
93
+ # transaction (optional).
94
+ # :description - A merchant-supplied description of the
95
+ # transaction (optional).
96
+ # :currency - Three letter currency code for the
97
+ # transaction (default: "AUD")
98
+ # :billing_address - Standard ActiveMerchant address hash
99
+ # (optional).
100
+ # :shipping_address - Standard ActiveMerchant address hash
101
+ # (optional).
102
+ # :ip - The ip of the consumer initiating the
103
+ # transaction (optional).
104
+ # :application_id - A string identifying the application
105
+ # submitting the transaction
106
+ # (default: "https://github.com/activemerchant/active_merchant")
107
+ #
108
+ # Returns an ActiveMerchant::Billing::Response object
109
+ def refund(amount, identification, options = {})
110
+ params = {}
111
+ add_metadata(params, options)
112
+ add_invoice(params, amount, options, 'Refund')
113
+ add_reference(params['Refund'], identification)
114
+ add_customer_data(params, options)
115
+ commit(url_for("Transaction/#{identification}/Refund"), params)
116
+ end
117
+
118
+ # Public: Store card details and return a valid token
119
+ #
120
+ # payment_method - The payment method or nil if :customer_token is provided
121
+ # options - A supplemented ActiveMerchant options hash:
122
+ # :order_id - A merchant-supplied identifier for the
123
+ # transaction (optional).
124
+ # :description - A merchant-supplied description of the
125
+ # transaction (optional).
126
+ # :billing_address - Standard ActiveMerchant address hash
127
+ # (required).
128
+ # :ip - The ip of the consumer initiating the
129
+ # transaction (optional).
130
+ # :application_id - A string identifying the application
131
+ # submitting the transaction
132
+ # (default: "https://github.com/activemerchant/active_merchant")
133
+ #
134
+ # Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
135
+ def store(payment_method, options = {})
136
+ requires!(options, :billing_address)
137
+ params = {}
138
+ add_metadata(params, options)
139
+ add_invoice(params, 0, options)
140
+ add_customer_data(params, options, payment_method)
141
+ add_credit_card(params, payment_method, options)
142
+ params['Method'] = 'CreateTokenCustomer'
143
+ commit(url_for('Transaction'), params)
144
+ end
145
+
146
+ # Public: Update a customer's data
147
+ #
148
+ # customer_token - The customer token returned in the authorization of
149
+ # a successful store transaction.
150
+ # payment_method - The payment method or nil if :customer_token is provided
151
+ # options - A supplemented ActiveMerchant options hash:
152
+ # :order_id - A merchant-supplied identifier for the
153
+ # transaction (optional).
154
+ # :description - A merchant-supplied description of the
155
+ # transaction (optional).
156
+ # :billing_address - Standard ActiveMerchant address hash
157
+ # (optional).
158
+ # :ip - The ip of the consumer initiating the
159
+ # transaction (optional).
160
+ # :application_id - A string identifying the application
161
+ # submitting the transaction
162
+ # (default: "https://github.com/activemerchant/active_merchant")
163
+ #
164
+ # Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
165
+ def update(customer_token, payment_method, options = {})
166
+ params = {}
167
+ add_metadata(params, options)
168
+ add_invoice(params, 0, options)
169
+ add_customer_data(params, options, payment_method)
170
+ add_credit_card(params, payment_method, options)
171
+ add_customer_token(params, customer_token)
172
+ params['Method'] = 'UpdateTokenCustomer'
173
+ commit(url_for('Transaction'), params)
174
+ end
175
+
176
+ def supports_scrubbing
177
+ true
178
+ end
179
+
180
+ def scrub(transcript)
181
+ transcript.
182
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
183
+ gsub(%r(("Number\\?":\\?")[^"]*)i, '\1[FILTERED]').
184
+ gsub(%r(("CVN\\?":\\?"?)[^",]*)i, '\1[FILTERED]')
185
+ end
186
+
187
+ private
188
+
189
+ def add_metadata(params, options)
190
+ params['RedirectUrl'] = options[:redirect_url] || 'http://example.com'
191
+ params['CustomerIP'] = options[:ip] if options[:ip]
192
+ params['TransactionType'] = options[:transaction_type] || 'Purchase'
193
+ params['DeviceID'] = options[:application_id] || application_id
194
+ if partner = options[:partner_id] || partner_id
195
+ params['PartnerID'] = truncate(partner, 50)
196
+ end
197
+ params
198
+ end
199
+
200
+ def add_invoice(params, money, options, key = 'Payment')
201
+ currency_code = options[:currency] || currency(money)
202
+ params[key] = {
203
+ 'TotalAmount' => localized_amount(money, currency_code),
204
+ 'InvoiceReference' => truncate(options[:order_id], 50),
205
+ 'InvoiceNumber' => truncate(options[:invoice] || options[:order_id], 12),
206
+ 'InvoiceDescription' => truncate(options[:description], 64),
207
+ 'CurrencyCode' => currency_code,
208
+ }
209
+ end
210
+
211
+ def add_reference(params, reference)
212
+ params['TransactionID'] = reference
213
+ end
214
+
215
+ def add_customer_data(params, options, payment_method = nil)
216
+ add_customer_fields(params, options, payment_method)
217
+ add_shipping_fields(params, options)
218
+ end
219
+
220
+ def add_customer_fields(params, options, payment_method)
221
+ key = 'Customer'
222
+ params[key] ||= {}
223
+
224
+ customer_address = options[:billing_address] || options[:address]
225
+
226
+ add_name_and_email(params[key], customer_address, options[:email], payment_method)
227
+ add_address(params[key], customer_address)
228
+ end
229
+
230
+ def add_shipping_fields(params, options)
231
+ key = 'ShippingAddress'
232
+ params[key] = {}
233
+
234
+ add_name_and_email(params[key], options[:shipping_address], options[:email])
235
+ add_address(params[key], options[:shipping_address], {:skip_company => true})
236
+ end
237
+
238
+ def add_name_and_email(params, address, email, payment_method = nil)
239
+ if address.present?
240
+ params['FirstName'], params['LastName'] = split_names(address[:name])
241
+ elsif payment_method_name_available?(payment_method)
242
+ params['FirstName'] = payment_method.first_name
243
+ params['LastName'] = payment_method.last_name
244
+ end
245
+
246
+ params['Email'] = email
247
+ end
248
+
249
+ def payment_method_name_available?(payment_method)
250
+ payment_method.respond_to?(:first_name) && payment_method.respond_to?(:last_name) &&
251
+ payment_method.first_name.present? && payment_method.last_name.present?
252
+ end
253
+
254
+ def add_address(params, address, options={})
255
+ return unless address
256
+
257
+ params['Title'] = address[:title]
258
+ params['CompanyName'] = address[:company] unless options[:skip_company]
259
+ params['Street1'] = truncate(address[:address1], 50)
260
+ params['Street2'] = truncate(address[:address2], 50)
261
+ params['City'] = truncate(address[:city], 50)
262
+ params['State'] = address[:state]
263
+ params['PostalCode'] = address[:zip]
264
+ params['Country'] = address[:country].to_s.downcase
265
+ params['Phone'] = address[:phone] || address[:phone_number]
266
+ params['Fax'] = address[:fax]
267
+ end
268
+
269
+ def add_credit_card(params, credit_card, options)
270
+ return unless credit_card
271
+ params['Customer'] ||= {}
272
+ if credit_card.respond_to? :number
273
+ card_details = params['Customer']['CardDetails'] = {}
274
+ card_details['Name'] = truncate(credit_card.name, 50)
275
+ card_details['Number'] = credit_card.number
276
+ card_details['ExpiryMonth'] = '%02d' % (credit_card.month || 0)
277
+ card_details['ExpiryYear'] = '%02d' % (credit_card.year || 0)
278
+ card_details['CVN'] = credit_card.verification_value
279
+ else
280
+ add_customer_token(params, credit_card)
281
+ end
282
+ end
283
+
284
+ def add_customer_token(params, token)
285
+ params['Customer'] ||= {}
286
+ params['Customer']['TokenCustomerID'] = token
287
+ end
288
+
289
+ def url_for(action)
290
+ (test? ? test_url : live_url) + action
291
+ end
292
+
293
+ def commit(url, params)
294
+ headers = {
295
+ 'Authorization' => ('Basic ' + Base64.strict_encode64(@options[:login].to_s + ':' + @options[:password].to_s).chomp),
296
+ 'Content-Type' => 'application/json'
297
+ }
298
+ request = params.to_json
299
+ raw = parse(ssl_post(url, request, headers))
300
+
301
+ succeeded = success?(raw)
302
+ ActiveMerchant::Billing::Response.new(
303
+ succeeded,
304
+ message_from(succeeded, raw),
305
+ raw,
306
+ :authorization => authorization_from(raw),
307
+ :test => test?,
308
+ :avs_result => avs_result_from(raw),
309
+ :cvv_result => cvv_result_from(raw)
310
+ )
311
+ rescue ActiveMerchant::ResponseError => e
312
+ return ActiveMerchant::Billing::Response.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
313
+ end
314
+
315
+ def parse(data)
316
+ JSON.parse(data)
317
+ end
318
+
319
+ def success?(response)
320
+ if response['ResponseCode'] == '00'
321
+ true
322
+ elsif response['TransactionStatus']
323
+ (response['TransactionStatus'] == true)
324
+ elsif response['Succeeded']
325
+ (response['Succeeded'] == true)
326
+ else
327
+ false
328
+ end
329
+ end
330
+
331
+ def parse_errors(message)
332
+ errors = message.split(',').collect { |code| MESSAGES[code.strip] }.flatten.join(',')
333
+ errors.presence || message
334
+ end
335
+
336
+ def message_from(succeeded, response)
337
+ if response['Errors']
338
+ parse_errors(response['Errors'])
339
+ elsif response['ResponseMessage']
340
+ parse_errors(response['ResponseMessage'])
341
+ elsif response['ResponseCode']
342
+ ActiveMerchant::Billing::EwayGateway::MESSAGES[response['ResponseCode']]
343
+ elsif succeeded
344
+ 'Succeeded'
345
+ else
346
+ 'Failed'
347
+ end
348
+ end
349
+
350
+ def authorization_from(response)
351
+ # Note: TransactionID is always null for store requests, but TokenCustomerID is also sent back for purchase from
352
+ # stored card transactions so we give precedence to TransactionID
353
+ response['TransactionID'] || response['Customer']['TokenCustomerID']
354
+ end
355
+
356
+ def avs_result_from(response)
357
+ verification = response['Verification'] || {}
358
+ code = case verification['Address']
359
+ when 'Valid'
360
+ 'M'
361
+ when 'Invalid'
362
+ 'N'
363
+ else
364
+ 'I'
365
+ end
366
+ {:code => code}
367
+ end
368
+
369
+ def cvv_result_from(response)
370
+ verification = response['Verification'] || {}
371
+ case verification['CVN']
372
+ when 'Valid'
373
+ 'M'
374
+ when 'Invalid'
375
+ 'N'
376
+ else
377
+ 'P'
378
+ end
379
+ end
380
+
381
+ MESSAGES = {
382
+ 'A2000' => 'Transaction Approved Successful',
383
+ 'A2008' => 'Honour With Identification Successful',
384
+ 'A2010' => 'Approved For Partial Amount Successful',
385
+ 'A2011' => 'Approved, VIP Successful',
386
+ 'A2016' => 'Approved, Update Track 3 Successful',
387
+ 'D4401' => 'Refer to Issuer Failed',
388
+ 'D4402' => 'Refer to Issuer, special Failed',
389
+ 'D4403' => 'No Merchant Failed',
390
+ 'D4404' => 'Pick Up Card Failed',
391
+ 'D4405' => 'Do Not Honour Failed',
392
+ 'D4406' => 'Error Failed',
393
+ 'D4407' => 'Pick Up Card, Special Failed',
394
+ 'D4409' => 'Request In Progress Failed',
395
+ 'D4412' => 'Invalid Transaction Failed',
396
+ 'D4413' => 'Invalid Amount Failed',
397
+ 'D4414' => 'Invalid Card Number Failed',
398
+ 'D4415' => 'No Issuer Failed',
399
+ 'D4419' => 'Re-enter Last Transaction Failed',
400
+ 'D4421' => 'No Action Taken Failed',
401
+ 'D4422' => 'Suspected Malfunction Failed',
402
+ 'D4423' => 'Unacceptable Transaction Fee Failed',
403
+ 'D4425' => 'Unable to Locate Record On File Failed',
404
+ 'D4430' => 'Format Error Failed ',
405
+ 'D4431' => 'Bank Not Supported By Switch Failed',
406
+ 'D4433' => 'Expired Card, Capture Failed ',
407
+ 'D4434' => 'Suspected Fraud, Retain Card Failed',
408
+ 'D4435' => 'Card Acceptor, Contact Acquirer, Retain Card Failed',
409
+ 'D4436' => 'Restricted Card, Retain Card Failed',
410
+ 'D4437' => 'Contact Acquirer Security Department, Retain Card Failed',
411
+ 'D4438' => 'PIN Tries Exceeded, Capture Failed',
412
+ 'D4439' => 'No Credit Account Failed',
413
+ 'D4440' => 'Function Not Supported Failed',
414
+ 'D4441' => 'Lost Card Failed',
415
+ 'D4442' => 'No Universal Account Failed',
416
+ 'D4443' => 'Stolen Card Failed',
417
+ 'D4444' => 'No Investment Account Failed',
418
+ 'D4451' => 'Insufficient Funds Failed',
419
+ 'D4452' => 'No Cheque Account Failed',
420
+ 'D4453' => 'No Savings Account Failed',
421
+ 'D4454' => 'Expired Card Failed',
422
+ 'D4455' => 'Incorrect PIN Failed',
423
+ 'D4456' => 'No Card Record Failed',
424
+ 'D4457' => 'Function Not Permitted to Cardholder Failed',
425
+ 'D4458' => 'Function Not Permitted to Terminal Failed',
426
+ 'D4459' => 'Suspected Fraud Failed',
427
+ 'D4460' => 'Acceptor Contact Acquirer Failed',
428
+ 'D4461' => 'Exceeds Withdrawal Limit Failed',
429
+ 'D4462' => 'Restricted Card Failed',
430
+ 'D4463' => 'Security Violation Failed',
431
+ 'D4464' => 'Original Amount Incorrect Failed',
432
+ 'D4466' => 'Acceptor Contact Acquirer, Security Failed',
433
+ 'D4467' => 'Capture Card Failed',
434
+ 'D4475' => 'PIN Tries Exceeded Failed',
435
+ 'D4482' => 'CVV Validation Error Failed',
436
+ 'D4490' => 'Cut off In Progress Failed',
437
+ 'D4491' => 'Card Issuer Unavailable Failed',
438
+ 'D4492' => 'Unable To Route Transaction Failed',
439
+ 'D4493' => 'Cannot Complete, Violation Of The Law Failed',
440
+ 'D4494' => 'Duplicate Transaction Failed',
441
+ 'D4496' => 'System Error Failed',
442
+ 'D4497' => 'MasterPass Error Failed',
443
+ 'D4498' => 'PayPal Create Transaction Error Failed',
444
+ 'D4499' => 'Invalid Transaction for Auth/Void Failed',
445
+ 'S5000' => 'System Error',
446
+ 'S5011' => 'PayPal Connection Error',
447
+ 'S5012' => 'PayPal Settings Error',
448
+ 'S5085' => 'Started 3dSecure',
449
+ 'S5086' => 'Routed 3dSecure',
450
+ 'S5087' => 'Completed 3dSecure',
451
+ 'S5088' => 'PayPal Transaction Created',
452
+ 'S5099' => 'Incomplete (Access Code in progress/incomplete)',
453
+ 'S5010' => 'Unknown error returned by gateway',
454
+ 'V6000' => 'Validation error',
455
+ 'V6001' => 'Invalid CustomerIP',
456
+ 'V6002' => 'Invalid DeviceID',
457
+ 'V6003' => 'Invalid Request PartnerID',
458
+ 'V6004' => 'Invalid Request Method',
459
+ 'V6010' => 'Invalid TransactionType, account not certified for eCome only MOTO or Recurring available',
460
+ 'V6011' => 'Invalid Payment TotalAmount',
461
+ 'V6012' => 'Invalid Payment InvoiceDescription',
462
+ 'V6013' => 'Invalid Payment InvoiceNumber',
463
+ 'V6014' => 'Invalid Payment InvoiceReference',
464
+ 'V6015' => 'Invalid Payment CurrencyCode',
465
+ 'V6016' => 'Payment Required',
466
+ 'V6017' => 'Payment CurrencyCode Required',
467
+ 'V6018' => 'Unknown Payment CurrencyCode',
468
+ 'V6021' => 'EWAY_CARDHOLDERNAME Required',
469
+ 'V6022' => 'EWAY_CARDNUMBER Required',
470
+ 'V6023' => 'EWAY_CARDCVN Required',
471
+ 'V6033' => 'Invalid Expiry Date',
472
+ 'V6034' => 'Invalid Issue Number',
473
+ 'V6035' => 'Invalid Valid From Date',
474
+ 'V6040' => 'Invalid TokenCustomerID',
475
+ 'V6041' => 'Customer Required',
476
+ 'V6042' => 'Customer FirstName Required',
477
+ 'V6043' => 'Customer LastName Required',
478
+ 'V6044' => 'Customer CountryCode Required',
479
+ 'V6045' => 'Customer Title Required ',
480
+ 'V6046' => 'TokenCustomerID Required',
481
+ 'V6047' => 'RedirectURL Required',
482
+ 'V6048' => 'Invalid Checkout URL',
483
+ 'V6051' => 'Invalid Customer FirstName',
484
+ 'V6052' => 'Invalid Customer LastName',
485
+ 'V6053' => 'Invalid Customer CountryCode',
486
+ 'V6058' => 'Invalid Customer Title ',
487
+ 'V6059' => 'Invalid RedirectURL',
488
+ 'V6060' => 'Invalid TokenCustomerID',
489
+ 'V6061' => 'Invalid Customer Reference',
490
+ 'V6062' => 'Invalid Customer CompanyName',
491
+ 'V6063' => 'Invalid Customer JobDescription',
492
+ 'V6064' => 'Invalid Customer Street1',
493
+ 'V6065' => 'Invalid Customer Street2',
494
+ 'V6066' => 'Invalid Customer City',
495
+ 'V6067' => 'Invalid Customer State',
496
+ 'V6068' => 'Invalid Customer PostalCode',
497
+ 'V6069' => 'Invalid Customer Email ',
498
+ 'V6070' => 'Invalid Customer Phone',
499
+ 'V6071' => 'Invalid Customer Mobile',
500
+ 'V6072' => 'Invalid Customer Comments',
501
+ 'V6073' => 'Invalid Customer Fax',
502
+ 'V6074' => 'Invalid Customer URL',
503
+ 'V6075' => 'Invalid ShippingAddress FirstName',
504
+ 'V6076' => 'Invalid ShippingAddress LastName',
505
+ 'V6077' => 'Invalid ShippingAddress Street1',
506
+ 'V6078' => 'Invalid ShippingAddress Street2',
507
+ 'V6079' => 'Invalid ShippingAddress City',
508
+ 'V6080' => 'Invalid ShippingAddress State',
509
+ 'V6081' => 'Invalid ShippingAddress PostalCode',
510
+ 'V6082' => 'Invalid ShippingAddress Email',
511
+ 'V6083' => 'Invalid ShippingAddress Phone',
512
+ 'V6084' => 'Invalid ShippingAddress Country',
513
+ 'V6085' => 'Invalid ShippingAddress ShippingMethod',
514
+ 'V6086' => 'Invalid ShippingAddress Fax',
515
+ 'V6091' => 'Unknown Customer CountryCode',
516
+ 'V6092' => 'Unknown ShippingAddress CountryCode',
517
+ 'V6100' => 'Invalid EWAY_CARDNAME',
518
+ 'V6101' => 'Invalid EWAY_CARDEXPIRYMONTH',
519
+ 'V6102' => 'Invalid EWAY_CARDEXPIRYYEAR ',
520
+ 'V6103' => 'Invalid EWAY_CARDSTARTMONTH',
521
+ 'V6104' => 'Invalid EWAY_CARDSTARTYEAR',
522
+ 'V6105' => 'Invalid EWAY_CARDISSUENUMBER ',
523
+ 'V6106' => 'Invalid EWAY_CARDCVN',
524
+ 'V6107' => 'Invalid EWAY_ACCESSCODE',
525
+ 'V6108' => 'Invalid CustomerHostAddress',
526
+ 'V6109' => 'Invalid UserAgent',
527
+ 'V6110' => 'Invalid EWAY_CARDNUMBER',
528
+ 'V6111' => 'Unauthorised API Access, Account Not PCI Certified',
529
+ 'V6112' => 'Redundant card details other than expiry year and month',
530
+ 'V6113' => 'Invalid transaction for refund',
531
+ 'V6114' => 'Gateway validation error',
532
+ 'V6115' => 'Invalid DirectRefundRequest, Transaction ID',
533
+ 'V6116' => 'Invalid card data on original TransactionID',
534
+ 'V6117' => 'Invalid CreateAccessCodeSharedRequest, FooterText',
535
+ 'V6118' => 'Invalid CreateAccessCodeSharedRequest, HeaderText',
536
+ 'V6119' => 'Invalid CreateAccessCodeSharedRequest, Language',
537
+ 'V6120' => 'Invalid CreateAccessCodeSharedRequest, LogoUrl ',
538
+ 'V6121' => 'Invalid TransactionSearch, Filter Match Type',
539
+ 'V6122' => 'Invalid TransactionSearch, Non numeric Transaction ID',
540
+ 'V6123' => 'Invalid TransactionSearch,no TransactionID or AccessCode specified',
541
+ 'V6124' => 'Invalid Line Items. The line items have been provided however the totals do not match the TotalAmount field',
542
+ 'V6125' => 'Selected Payment Type not enabled',
543
+ 'V6126' => 'Invalid encrypted card number, decryption failed',
544
+ 'V6127' => 'Invalid encrypted cvn, decryption failed',
545
+ 'V6128' => 'Invalid Method for Payment Type',
546
+ 'V6129' => 'Transaction has not been authorised for Capture/Cancellation',
547
+ 'V6130' => 'Generic customer information error ',
548
+ 'V6131' => 'Generic shipping information error',
549
+ 'V6132' => 'Transaction has already been completed or voided, operation not permitted',
550
+ 'V6133' => 'Checkout not available for Payment Type',
551
+ 'V6134' => 'Invalid Auth Transaction ID for Capture/Void',
552
+ 'V6135' => 'PayPal Error Processing Refund',
553
+ 'V6140' => 'Merchant account is suspended',
554
+ 'V6141' => 'Invalid PayPal account details or API signature',
555
+ 'V6142' => 'Authorise not available for Bank/Branch',
556
+ 'V6150' => 'Invalid Refund Amount',
557
+ 'V6151' => 'Refund amount greater than original transaction',
558
+ 'V6152' => 'Original transaction already refunded for total amount',
559
+ 'V6153' => 'Card type not support by merchant',
560
+ }
561
+ end
562
+ end
563
+ end