swiss-crm-activemerchant 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +252 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +242 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -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 +397 -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/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -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 +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +235 -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 +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -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/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -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 +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -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 +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -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 +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -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 +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +354 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -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 +121 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,289 @@
|
|
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 = %i[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 =
|
218
|
+
begin
|
219
|
+
ssl_post(test? ? self.test_url : self.live_url, soap_request(post, action), 'Content-Type' => 'application/soap+xml; charset=utf-8')
|
220
|
+
rescue ResponseError => e
|
221
|
+
e.response.body
|
222
|
+
end
|
223
|
+
response = parse(raw)
|
224
|
+
|
225
|
+
EwayResponse.new(response[:success], response[:message], response,
|
226
|
+
test: test?,
|
227
|
+
authorization: response[:auth_code])
|
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
|
+
end
|
288
|
+
end
|
289
|
+
end
|