active_accountability_merchant 1.97.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +2948 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +246 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +15 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +96 -0
- data/lib/active_merchant/billing/base.rb +61 -0
- data/lib/active_merchant/billing/check.rb +80 -0
- data/lib/active_merchant/billing/compatibility.rb +117 -0
- data/lib/active_merchant/billing/credit_card.rb +406 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +330 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +217 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +316 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
- data/lib/active_merchant/billing/gateways/element.rb +356 -0
- data/lib/active_merchant/billing/gateways/epay.rb +285 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
- data/lib/active_merchant/billing/gateways/exact.rb +224 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/forte.rb +270 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
- data/lib/active_merchant/billing/gateways/hps.rb +350 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
- data/lib/active_merchant/billing/gateways/litle.rb +507 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
- data/lib/active_merchant/billing/gateways/migs.rb +332 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
- data/lib/active_merchant/billing/gateways/monei.rb +338 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
- data/lib/active_merchant/billing/gateways/omise.rb +324 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
- data/lib/active_merchant/billing/gateways/opp.rb +388 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
- data/lib/active_merchant/billing/gateways/payex.rb +410 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +269 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +234 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
- data/lib/active_merchant/billing/gateways/realex.rb +374 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
- data/lib/active_merchant/billing/gateways/s5.rb +246 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
- data/lib/active_merchant/billing/gateways/sage.rb +448 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
- data/lib/active_merchant/billing/gateways/telr.rb +274 -0
- data/lib/active_merchant/billing/gateways/tns.rb +22 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
- data/lib/active_merchant/billing/gateways/transax.rb +22 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +92 -0
- data/lib/active_merchant/connection.rb +195 -0
- data/lib/active_merchant/country.rb +336 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
- data/lib/active_merchant/network_connection_retries.rb +80 -0
- data/lib/active_merchant/post_data.rb +25 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3988 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +92 -0
- data/lib/support/ssl_version.rb +87 -0
- metadata +435 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# Public: For more information on the Eway Gateway please visit their
|
6
|
+
# {Developers Area}[http://www.eway.com.au/developers/api/direct-payments]
|
7
|
+
class EwayGateway < Gateway
|
8
|
+
self.live_url = 'https://www.eway.com.au'
|
9
|
+
|
10
|
+
self.money_format = :cents
|
11
|
+
self.supported_countries = ['AU']
|
12
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
|
13
|
+
self.homepage_url = 'http://www.eway.com.au/'
|
14
|
+
self.display_name = 'eWAY'
|
15
|
+
|
16
|
+
# Public: Create a new Eway Gateway.
|
17
|
+
# options - A hash of options:
|
18
|
+
# :login - Your Customer ID.
|
19
|
+
# :password - Your XML Refund Password that you
|
20
|
+
# specified on the Eway site. (optional)
|
21
|
+
def initialize(options = {})
|
22
|
+
requires!(options, :login)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def purchase(money, creditcard, options = {})
|
27
|
+
requires_address!(options)
|
28
|
+
|
29
|
+
post = {}
|
30
|
+
add_creditcard(post, creditcard)
|
31
|
+
add_address(post, options)
|
32
|
+
add_customer_id(post)
|
33
|
+
add_invoice_data(post, options)
|
34
|
+
add_non_optional_data(post)
|
35
|
+
add_amount(post, money)
|
36
|
+
post[:CustomerEmail] = options[:email]
|
37
|
+
|
38
|
+
commit(purchase_url(post[:CVN]), money, post)
|
39
|
+
end
|
40
|
+
|
41
|
+
def refund(money, authorization, options={})
|
42
|
+
post = {}
|
43
|
+
|
44
|
+
add_customer_id(post)
|
45
|
+
add_amount(post, money)
|
46
|
+
add_non_optional_data(post)
|
47
|
+
post[:OriginalTrxnNumber] = authorization
|
48
|
+
post[:RefundPassword] = @options[:password]
|
49
|
+
post[:CardExpiryMonth] = nil
|
50
|
+
post[:CardExpiryYear] = nil
|
51
|
+
|
52
|
+
commit(refund_url, money, post)
|
53
|
+
end
|
54
|
+
|
55
|
+
def supports_scrubbing
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
59
|
+
def scrub(transcript)
|
60
|
+
transcript.
|
61
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
62
|
+
gsub(%r((<ewayCardNumber>)\d+(</ewayCardNumber>))i, '\1[FILTERED]\2').
|
63
|
+
gsub(%r((<ewayCVN>)\d+(</ewayCVN>))i, '\1[FILTERED]\2')
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def requires_address!(options)
|
69
|
+
raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless options.has_key?(:address) or options.has_key?(:billing_address)
|
70
|
+
end
|
71
|
+
|
72
|
+
def add_creditcard(post, creditcard)
|
73
|
+
post[:CardNumber] = creditcard.number
|
74
|
+
post[:CardExpiryMonth] = sprintf('%.2i', creditcard.month)
|
75
|
+
post[:CardExpiryYear] = sprintf('%.4i', creditcard.year)[-2..-1]
|
76
|
+
post[:CustomerFirstName] = creditcard.first_name
|
77
|
+
post[:CustomerLastName] = creditcard.last_name
|
78
|
+
post[:CardHoldersName] = creditcard.name
|
79
|
+
|
80
|
+
post[:CVN] = creditcard.verification_value if creditcard.verification_value?
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_address(post, options)
|
84
|
+
if address = options[:billing_address] || options[:address]
|
85
|
+
post[:CustomerAddress] = [ address[:address1], address[:address2], address[:city], address[:state], address[:country] ].compact.join(', ')
|
86
|
+
post[:CustomerPostcode] = address[:zip]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_customer_id(post)
|
91
|
+
post[:CustomerID] = @options[:login]
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_invoice_data(post, options)
|
95
|
+
post[:CustomerInvoiceRef] = options[:order_id]
|
96
|
+
post[:CustomerInvoiceDescription] = options[:description]
|
97
|
+
end
|
98
|
+
|
99
|
+
def add_amount(post, money)
|
100
|
+
post[:TotalAmount] = amount(money)
|
101
|
+
end
|
102
|
+
|
103
|
+
def add_non_optional_data(post)
|
104
|
+
post[:Option1] = nil
|
105
|
+
post[:Option2] = nil
|
106
|
+
post[:Option3] = nil
|
107
|
+
post[:TrxnNumber] = nil
|
108
|
+
end
|
109
|
+
|
110
|
+
def commit(url, money, parameters)
|
111
|
+
raw_response = ssl_post(url, post_data(parameters))
|
112
|
+
response = parse(raw_response)
|
113
|
+
|
114
|
+
Response.new(success?(response),
|
115
|
+
message_from(response[:ewaytrxnerror]),
|
116
|
+
response,
|
117
|
+
:authorization => response[:ewaytrxnnumber],
|
118
|
+
:test => test?
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
def success?(response)
|
123
|
+
response[:ewaytrxnstatus] == 'True'
|
124
|
+
end
|
125
|
+
|
126
|
+
def parse(xml)
|
127
|
+
response = {}
|
128
|
+
xml = REXML::Document.new(xml)
|
129
|
+
xml.elements.each('//ewayResponse/*') do |node|
|
130
|
+
response[node.name.downcase.to_sym] = normalize(node.text)
|
131
|
+
end unless xml.root.nil?
|
132
|
+
|
133
|
+
response
|
134
|
+
end
|
135
|
+
|
136
|
+
def post_data(parameters = {})
|
137
|
+
xml = REXML::Document.new
|
138
|
+
root = xml.add_element('ewaygateway')
|
139
|
+
|
140
|
+
parameters.each do |key, value|
|
141
|
+
root.add_element("eway#{key}").text = value
|
142
|
+
end
|
143
|
+
xml.to_s
|
144
|
+
end
|
145
|
+
|
146
|
+
def message_from(message)
|
147
|
+
return '' if message.blank?
|
148
|
+
MESSAGES[message[0, 2]] || message
|
149
|
+
end
|
150
|
+
|
151
|
+
def purchase_url(cvn)
|
152
|
+
suffix = test? ? 'xmltest/testpage.asp' : 'xmlpayment.asp'
|
153
|
+
gateway_part = cvn ? 'gateway_cvn' : 'gateway'
|
154
|
+
"#{live_url}/#{gateway_part}/#{suffix}"
|
155
|
+
end
|
156
|
+
|
157
|
+
def refund_url
|
158
|
+
suffix = test? ? 'xmltest/refund_test.asp' : 'xmlpaymentrefund.asp'
|
159
|
+
"#{live_url}/gateway/#{suffix}"
|
160
|
+
end
|
161
|
+
|
162
|
+
MESSAGES = {
|
163
|
+
'00' => 'Transaction Approved',
|
164
|
+
'01' => 'Refer to Issuer',
|
165
|
+
'02' => 'Refer to Issuer, special',
|
166
|
+
'03' => 'No Merchant',
|
167
|
+
'04' => 'Pick Up Card',
|
168
|
+
'05' => 'Do Not Honour',
|
169
|
+
'06' => 'Error',
|
170
|
+
'07' => 'Pick Up Card, Special',
|
171
|
+
'08' => 'Honour With Identification',
|
172
|
+
'09' => 'Request In Progress',
|
173
|
+
'10' => 'Approved For Partial Amount',
|
174
|
+
'11' => 'Approved, VIP',
|
175
|
+
'12' => 'Invalid Transaction',
|
176
|
+
'13' => 'Invalid Amount',
|
177
|
+
'14' => 'Invalid Card Number',
|
178
|
+
'15' => 'No Issuer',
|
179
|
+
'16' => 'Approved, Update Track 3',
|
180
|
+
'19' => 'Re-enter Last Transaction',
|
181
|
+
'21' => 'No Action Taken',
|
182
|
+
'22' => 'Suspected Malfunction',
|
183
|
+
'23' => 'Unacceptable Transaction Fee',
|
184
|
+
'25' => 'Unable to Locate Record On File',
|
185
|
+
'30' => 'Format Error',
|
186
|
+
'31' => 'Bank Not Supported By Switch',
|
187
|
+
'33' => 'Expired Card, Capture',
|
188
|
+
'34' => 'Suspected Fraud, Retain Card',
|
189
|
+
'35' => 'Card Acceptor, Contact Acquirer, Retain Card',
|
190
|
+
'36' => 'Restricted Card, Retain Card',
|
191
|
+
'37' => 'Contact Acquirer Security Department, Retain Card',
|
192
|
+
'38' => 'PIN Tries Exceeded, Capture',
|
193
|
+
'39' => 'No Credit Account',
|
194
|
+
'40' => 'Function Not Supported',
|
195
|
+
'41' => 'Lost Card',
|
196
|
+
'42' => 'No Universal Account',
|
197
|
+
'43' => 'Stolen Card',
|
198
|
+
'44' => 'No Investment Account',
|
199
|
+
'51' => 'Insufficient Funds',
|
200
|
+
'52' => 'No Cheque Account',
|
201
|
+
'53' => 'No Savings Account',
|
202
|
+
'54' => 'Expired Card',
|
203
|
+
'55' => 'Incorrect PIN',
|
204
|
+
'56' => 'No Card Record',
|
205
|
+
'57' => 'Function Not Permitted to Cardholder',
|
206
|
+
'58' => 'Function Not Permitted to Terminal',
|
207
|
+
'59' => 'Suspected Fraud',
|
208
|
+
'60' => 'Acceptor Contact Acquirer',
|
209
|
+
'61' => 'Exceeds Withdrawal Limit',
|
210
|
+
'62' => 'Restricted Card',
|
211
|
+
'63' => 'Security Violation',
|
212
|
+
'64' => 'Original Amount Incorrect',
|
213
|
+
'66' => 'Acceptor Contact Acquirer, Security',
|
214
|
+
'67' => 'Capture Card',
|
215
|
+
'75' => 'PIN Tries Exceeded',
|
216
|
+
'82' => 'CVV Validation Error',
|
217
|
+
'90' => 'Cutoff In Progress',
|
218
|
+
'91' => 'Card Issuer Unavailable',
|
219
|
+
'92' => 'Unable To Route Transaction',
|
220
|
+
'93' => 'Cannot Complete, Violation Of The Law',
|
221
|
+
'94' => 'Duplicate Transaction',
|
222
|
+
'96' => 'System Error'
|
223
|
+
}
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,290 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class EwayManagedGateway < Gateway
|
4
|
+
self.test_url = 'https://www.eway.com.au/gateway/ManagedPaymentService/test/managedCreditCardPayment.asmx'
|
5
|
+
self.live_url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx'
|
6
|
+
|
7
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
8
|
+
self.supported_countries = ['AU']
|
9
|
+
|
10
|
+
# The card types supported by the payment gateway
|
11
|
+
self.supported_cardtypes = [:visa, :master]
|
12
|
+
|
13
|
+
self.default_currency = 'AUD'
|
14
|
+
|
15
|
+
# accepted money format
|
16
|
+
self.money_format = :cents
|
17
|
+
|
18
|
+
# The homepage URL of the gateway
|
19
|
+
self.homepage_url = 'http://www.eway.com.au/'
|
20
|
+
|
21
|
+
# The name of the gateway
|
22
|
+
self.display_name = 'eWay Managed Payments'
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
requires!(options, :login, :username, :password)
|
26
|
+
|
27
|
+
# eWay returns 500 code for faults, which AM snaffles.
|
28
|
+
# So, we tell it to allow them.
|
29
|
+
options[:ignore_http_status] = true
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
# add a new customer CC to your eway account and return unique ManagedCustomerID
|
34
|
+
# supports storing details required by eway see "add_creditcard" and "add_address"
|
35
|
+
def store(creditcard, options = {})
|
36
|
+
post = {}
|
37
|
+
|
38
|
+
# Handle our required fields
|
39
|
+
requires!(options, :billing_address)
|
40
|
+
|
41
|
+
# Handle eWay specific required fields.
|
42
|
+
billing_address = options[:billing_address]
|
43
|
+
eway_requires!(billing_address)
|
44
|
+
|
45
|
+
add_creditcard(post, creditcard)
|
46
|
+
add_address(post, billing_address)
|
47
|
+
add_misc_fields(post, options)
|
48
|
+
|
49
|
+
commit('CreateCustomer', post)
|
50
|
+
end
|
51
|
+
|
52
|
+
def update(billing_id, creditcard, options={})
|
53
|
+
post = {}
|
54
|
+
|
55
|
+
# Handle our required fields
|
56
|
+
requires!(options, :billing_address)
|
57
|
+
|
58
|
+
# Handle eWay specific required fields.
|
59
|
+
billing_address = options[:billing_address]
|
60
|
+
eway_requires!(billing_address)
|
61
|
+
|
62
|
+
post[:managedCustomerID]=billing_id
|
63
|
+
add_creditcard(post, creditcard)
|
64
|
+
add_address(post, billing_address)
|
65
|
+
add_misc_fields(post, options)
|
66
|
+
|
67
|
+
commit('UpdateCustomer', post)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Process a payment in the given amount against the stored credit card given by billing_id
|
71
|
+
#
|
72
|
+
# ==== Parameters
|
73
|
+
#
|
74
|
+
# * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
|
75
|
+
# * <tt>billing_id</tt> -- The eWay provided card/customer token to charge (managedCustomerID)
|
76
|
+
# * <tt>options</tt> -- A hash of optional parameters.
|
77
|
+
#
|
78
|
+
# ==== Options
|
79
|
+
#
|
80
|
+
# * <tt>:order_id</tt> -- The order number, passed to eWay as the "Invoice Reference"
|
81
|
+
# * <tt>:invoice</tt> -- The invoice number, passed to eWay as the "Invoice Reference" unless :order_id is also given
|
82
|
+
# * <tt>:description</tt> -- A description of the payment, passed to eWay as the "Invoice Description"
|
83
|
+
def purchase(money, billing_id, options={})
|
84
|
+
post = {}
|
85
|
+
post[:managedCustomerID] = billing_id.to_s
|
86
|
+
post[:amount]=money
|
87
|
+
add_invoice(post, options)
|
88
|
+
|
89
|
+
commit('ProcessPayment', post)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Get customer's stored credit card details given by billing_id
|
93
|
+
#
|
94
|
+
# ==== Parameters
|
95
|
+
#
|
96
|
+
# * <tt>billing_id</tt> -- The eWay provided card/customer token to charge (managedCustomerID)
|
97
|
+
def retrieve(billing_id)
|
98
|
+
post = {}
|
99
|
+
post[:managedCustomerID] = billing_id.to_s
|
100
|
+
|
101
|
+
commit('QueryCustomer', post)
|
102
|
+
end
|
103
|
+
|
104
|
+
# TODO: eWay API also provides QueryPayment
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def eway_requires!(hash)
|
109
|
+
raise ArgumentError.new('Missing eWay required parameter in `billing_address`: title') unless hash.has_key?(:title)
|
110
|
+
raise ArgumentError.new('Missing eWay required parameter in `billing_address`: country') unless hash.has_key?(:country)
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_address(post, address)
|
114
|
+
post[:Address] = address[:address1].to_s
|
115
|
+
post[:Phone] = address[:phone].to_s
|
116
|
+
post[:PostCode] = address[:zip].to_s
|
117
|
+
post[:Suburb] = address[:city].to_s
|
118
|
+
post[:Country] = address[:country].to_s.downcase
|
119
|
+
post[:State] = address[:state].to_s
|
120
|
+
post[:Mobile] = address[:mobile].to_s
|
121
|
+
post[:Fax] = address[:fax].to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_misc_fields(post, options)
|
125
|
+
post[:CustomerRef]=options[:billing_address][:customer_ref] || options[:customer]
|
126
|
+
post[:Title]=options[:billing_address][:title]
|
127
|
+
post[:Company]=options[:billing_address][:company]
|
128
|
+
post[:JobDesc]=options[:billing_address][:job_desc]
|
129
|
+
post[:Email]=options[:billing_address][:email] || options[:email]
|
130
|
+
post[:URL]=options[:billing_address][:url]
|
131
|
+
post[:Comments]=options[:description]
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_invoice(post, options)
|
135
|
+
post[:invoiceReference] = options[:order_id] || options[:invoice]
|
136
|
+
post[:invoiceDescription] = options[:description]
|
137
|
+
end
|
138
|
+
|
139
|
+
# add credit card details to be stored by eway. NOTE eway requires "title" field
|
140
|
+
def add_creditcard(post, creditcard)
|
141
|
+
post[:CCNumber] = creditcard.number
|
142
|
+
post[:CCExpiryMonth] = sprintf('%.2i', creditcard.month)
|
143
|
+
post[:CCExpiryYear] = sprintf('%.4i', creditcard.year)[-2..-1]
|
144
|
+
post[:CCNameOnCard] = creditcard.name
|
145
|
+
post[:FirstName] = creditcard.first_name
|
146
|
+
post[:LastName] = creditcard.last_name
|
147
|
+
end
|
148
|
+
|
149
|
+
def parse(body)
|
150
|
+
reply = {}
|
151
|
+
xml = REXML::Document.new(body)
|
152
|
+
if root = REXML::XPath.first(xml, '//soap:Fault') then
|
153
|
+
reply=parse_fault(root)
|
154
|
+
else
|
155
|
+
if root = REXML::XPath.first(xml, '//ProcessPaymentResponse/ewayResponse') then
|
156
|
+
# Successful payment
|
157
|
+
reply=parse_purchase(root)
|
158
|
+
else
|
159
|
+
if root = REXML::XPath.first(xml, '//QueryCustomerResult') then
|
160
|
+
reply=parse_query_customer(root)
|
161
|
+
else
|
162
|
+
if root = REXML::XPath.first(xml, '//CreateCustomerResult') then
|
163
|
+
reply[:message]='OK'
|
164
|
+
reply[:CreateCustomerResult]=root.text
|
165
|
+
reply[:success]=true
|
166
|
+
else
|
167
|
+
if root = REXML::XPath.first(xml, '//UpdateCustomerResult') then
|
168
|
+
if root.text.casecmp('true').zero? then
|
169
|
+
reply[:message]='OK'
|
170
|
+
reply[:success]=true
|
171
|
+
else
|
172
|
+
# ERROR: This state should never occur. If there is a problem,
|
173
|
+
# a soap:Fault will be returned. The presence of this
|
174
|
+
# element always means a success.
|
175
|
+
raise StandardError, 'Unexpected "false" in UpdateCustomerResult'
|
176
|
+
end
|
177
|
+
else
|
178
|
+
# ERROR: This state should never occur currently. We have handled
|
179
|
+
# responses for all the methods which we support.
|
180
|
+
raise StandardError, 'Unexpected response'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
return reply
|
187
|
+
end
|
188
|
+
|
189
|
+
def parse_fault(node)
|
190
|
+
reply={}
|
191
|
+
reply[:message]=REXML::XPath.first(node, '//soap:Reason/soap:Text').text
|
192
|
+
reply[:success]=false
|
193
|
+
reply
|
194
|
+
end
|
195
|
+
|
196
|
+
def parse_purchase(node)
|
197
|
+
reply={}
|
198
|
+
reply[:message]=REXML::XPath.first(node, '//ewayTrxnError').text
|
199
|
+
reply[:success]=(REXML::XPath.first(node, '//ewayTrxnStatus').text == 'True')
|
200
|
+
reply[:auth_code]=REXML::XPath.first(node, '//ewayAuthCode').text
|
201
|
+
reply[:transaction_number]=REXML::XPath.first(node, '//ewayTrxnNumber').text
|
202
|
+
reply
|
203
|
+
end
|
204
|
+
|
205
|
+
def parse_query_customer(node)
|
206
|
+
reply={}
|
207
|
+
reply[:message]='OK'
|
208
|
+
reply[:success]=true
|
209
|
+
reply[:CCNumber]=REXML::XPath.first(node, '//CCNumber').text
|
210
|
+
reply[:CCName]=REXML::XPath.first(node, '//CCName').text
|
211
|
+
reply[:CCExpiryMonth]=REXML::XPath.first(node, '//CCExpiryMonth').text
|
212
|
+
reply[:CCExpiryYear]=REXML::XPath.first(node, '//CCExpiryYear').text
|
213
|
+
reply
|
214
|
+
end
|
215
|
+
|
216
|
+
def commit(action, post)
|
217
|
+
raw = begin
|
218
|
+
ssl_post(test? ? self.test_url : self.live_url, soap_request(post, action), 'Content-Type' => 'application/soap+xml; charset=utf-8')
|
219
|
+
rescue ResponseError => e
|
220
|
+
e.response.body
|
221
|
+
end
|
222
|
+
response = parse(raw)
|
223
|
+
|
224
|
+
EwayResponse.new(response[:success], response[:message], response,
|
225
|
+
:test => test?,
|
226
|
+
:authorization => response[:auth_code]
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
# Where we build the full SOAP 1.2 request using builder
|
231
|
+
def soap_request(arguments, action)
|
232
|
+
# eWay demands all fields be sent, but contain an empty string if blank
|
233
|
+
post = case action
|
234
|
+
when 'QueryCustomer'
|
235
|
+
arguments
|
236
|
+
when 'ProcessPayment'
|
237
|
+
default_payment_fields.merge(arguments)
|
238
|
+
when 'CreateCustomer'
|
239
|
+
default_customer_fields.merge(arguments)
|
240
|
+
when 'UpdateCustomer'
|
241
|
+
default_customer_fields.merge(arguments)
|
242
|
+
end
|
243
|
+
|
244
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
245
|
+
xml.instruct!
|
246
|
+
xml.tag! 'soap12:Envelope', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'} do
|
247
|
+
xml.tag! 'soap12:Header' do
|
248
|
+
xml.tag! 'eWAYHeader', {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do
|
249
|
+
xml.tag! 'eWAYCustomerID', @options[:login]
|
250
|
+
xml.tag! 'Username', @options[:username]
|
251
|
+
xml.tag! 'Password', @options[:password]
|
252
|
+
end
|
253
|
+
end
|
254
|
+
xml.tag! 'soap12:Body' do |x|
|
255
|
+
x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y|
|
256
|
+
post.each do |key, value|
|
257
|
+
y.tag! key, value
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
xml.target!
|
263
|
+
end
|
264
|
+
|
265
|
+
def default_customer_fields
|
266
|
+
hash={}
|
267
|
+
%w( CustomerRef Title FirstName LastName Company JobDesc Email Address Suburb State PostCode Country Phone Mobile Fax URL Comments CCNumber CCNameOnCard CCExpiryMonth CCExpiryYear ).each do |field|
|
268
|
+
hash[field.to_sym]=''
|
269
|
+
end
|
270
|
+
return hash
|
271
|
+
end
|
272
|
+
|
273
|
+
def default_payment_fields
|
274
|
+
hash={}
|
275
|
+
%w( managedCustomerID amount invoiceReference invoiceDescription ).each do |field|
|
276
|
+
hash[field.to_sym]=''
|
277
|
+
end
|
278
|
+
return hash
|
279
|
+
end
|
280
|
+
|
281
|
+
class EwayResponse < Response
|
282
|
+
# add a method to response so we can easily get the eway token "ManagedCustomerID"
|
283
|
+
def token
|
284
|
+
@params['CreateCustomerResult']
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|