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,142 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CommercegateGateway < Gateway
|
4
|
+
self.test_url = self.live_url = 'https://secure.commercegate.com/gateway/nvp'
|
5
|
+
|
6
|
+
self.supported_countries = %w(
|
7
|
+
AD AT AX BE BG CH CY CZ DE DK ES FI FR GB GG
|
8
|
+
GI GR HR HU IE IM IS IT JE LI LT LU LV MC MT
|
9
|
+
NL NO PL PT RO SE SI SK VA
|
10
|
+
)
|
11
|
+
|
12
|
+
self.money_format = :dollars
|
13
|
+
self.default_currency = 'EUR'
|
14
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
15
|
+
self.homepage_url = 'http://www.commercegate.com/'
|
16
|
+
self.display_name = 'CommerceGate'
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
requires!(options, :login, :password, :site_id, :offer_id)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def authorize(money, creditcard, options = {})
|
24
|
+
post = {}
|
25
|
+
add_creditcard(post, creditcard)
|
26
|
+
add_auth_purchase_options(post, money, options)
|
27
|
+
commit('AUTH', post)
|
28
|
+
end
|
29
|
+
|
30
|
+
def capture(money, authorization, options = {})
|
31
|
+
post = {}
|
32
|
+
post[:currencyCode] = (options[:currency] || currency(money))
|
33
|
+
post[:amount] = amount(money)
|
34
|
+
post[:transID] = authorization
|
35
|
+
commit('CAPTURE', post)
|
36
|
+
end
|
37
|
+
|
38
|
+
def purchase(money, creditcard, options = {})
|
39
|
+
post = {}
|
40
|
+
add_creditcard(post, creditcard)
|
41
|
+
add_auth_purchase_options(post, money, options)
|
42
|
+
commit('SALE', post)
|
43
|
+
end
|
44
|
+
|
45
|
+
def refund(money, identification, options = {})
|
46
|
+
post = {}
|
47
|
+
post[:currencyCode] = options[:currency] || currency(money)
|
48
|
+
post[:amount] = amount(money)
|
49
|
+
post[:transID] = identification
|
50
|
+
commit('REFUND', post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def void(identification, options = {})
|
54
|
+
post = {}
|
55
|
+
post[:transID] = identification
|
56
|
+
commit('VOID_AUTH', post)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def add_address(post, address)
|
62
|
+
if address
|
63
|
+
post[:address] = address[:address1]
|
64
|
+
post[:city] = address[:city]
|
65
|
+
post[:state] = address[:state]
|
66
|
+
post[:postalCode] = address[:zip]
|
67
|
+
end
|
68
|
+
post[:countryCode] = ((address && address[:country]) || 'US')
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_auth_purchase_options(post, money, options)
|
72
|
+
add_address(post, options[:address])
|
73
|
+
|
74
|
+
post[:customerIP] = options[:ip] || '127.0.0.1'
|
75
|
+
post[:amount] = amount(money)
|
76
|
+
post[:email] = options[:email] || 'unknown@example.com'
|
77
|
+
post[:currencyCode] = options[:currency] || currency(money)
|
78
|
+
post[:merchAcct] = options[:merchant]
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_creditcard(params, creditcard)
|
82
|
+
params[:firstName] = creditcard.first_name
|
83
|
+
params[:lastName] = creditcard.last_name
|
84
|
+
params[:cardNumber] = creditcard.number
|
85
|
+
params[:expiryMonth] = creditcard.month
|
86
|
+
params[:expiryYear] = creditcard.year
|
87
|
+
params[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
88
|
+
end
|
89
|
+
|
90
|
+
def commit(action, parameters)
|
91
|
+
parameters[:apiUsername] = @options[:login]
|
92
|
+
parameters[:apiPassword] = @options[:password]
|
93
|
+
parameters[:siteID] = @options[:site_id]
|
94
|
+
parameters[:offerID] = @options[:offer_id]
|
95
|
+
parameters[:action] = action
|
96
|
+
|
97
|
+
response = parse(ssl_post(self.live_url, post_data(parameters)))
|
98
|
+
|
99
|
+
Response.new(
|
100
|
+
successful?(response),
|
101
|
+
message_from(response),
|
102
|
+
response,
|
103
|
+
authorization: response['transID'],
|
104
|
+
test: test?,
|
105
|
+
avs_result: { code: response['avsCode'] },
|
106
|
+
cvv_result: response['cvvCode']
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
def parse(body)
|
111
|
+
results = {}
|
112
|
+
|
113
|
+
body.split(/\&/).each do |pair|
|
114
|
+
key, val = pair.split(%r{=})
|
115
|
+
results[key] = CGI.unescape(val)
|
116
|
+
end
|
117
|
+
|
118
|
+
results
|
119
|
+
end
|
120
|
+
|
121
|
+
def successful?(response)
|
122
|
+
response['returnCode'] == '0'
|
123
|
+
end
|
124
|
+
|
125
|
+
def message_from(response)
|
126
|
+
if response['returnText'].present?
|
127
|
+
response['returnText']
|
128
|
+
else
|
129
|
+
'Invalid response received from the CommerceGate API. ' \
|
130
|
+
'Please contact CommerceGate support if you continue to receive this message. ' \
|
131
|
+
"(The raw response returned by the API was #{response.inspect})"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def post_data(parameters)
|
136
|
+
parameters.collect do |key, value|
|
137
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
138
|
+
end.join('&')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class ConektaGateway < Gateway
|
4
|
+
self.live_url = 'https://api.conekta.io/'
|
5
|
+
|
6
|
+
self.supported_countries = ['MX']
|
7
|
+
self.supported_cardtypes = %i[visa master american_express carnet]
|
8
|
+
self.homepage_url = 'https://conekta.io/'
|
9
|
+
self.display_name = 'Conekta Gateway'
|
10
|
+
self.money_format = :cents
|
11
|
+
self.default_currency = 'MXN'
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
requires!(options, :key)
|
15
|
+
options[:version] ||= '1.0.0'
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def purchase(money, payment_source, options = {})
|
20
|
+
post = {}
|
21
|
+
|
22
|
+
add_order(post, money, options)
|
23
|
+
add_payment_source(post, payment_source, options)
|
24
|
+
add_details_data(post, options)
|
25
|
+
|
26
|
+
commit(:post, 'charges', post, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def authorize(money, payment_source, options = {})
|
30
|
+
post = {}
|
31
|
+
|
32
|
+
add_order(post, money, options)
|
33
|
+
add_payment_source(post, payment_source, options)
|
34
|
+
add_details_data(post, options)
|
35
|
+
|
36
|
+
post[:capture] = false
|
37
|
+
commit(:post, 'charges', post, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def capture(money, identifier, options = {})
|
41
|
+
post = {}
|
42
|
+
|
43
|
+
post[:order_id] = identifier
|
44
|
+
add_order(post, money, options)
|
45
|
+
|
46
|
+
commit(:post, "charges/#{identifier}/capture", post, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def refund(money, identifier, options)
|
50
|
+
post = {}
|
51
|
+
|
52
|
+
post[:order_id] = identifier
|
53
|
+
add_order(post, money, options)
|
54
|
+
|
55
|
+
commit(:post, "charges/#{identifier}/refund", post, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def void(identifier, options = {})
|
59
|
+
post = {}
|
60
|
+
commit(:post, "charges/#{identifier}/void", post, options)
|
61
|
+
end
|
62
|
+
|
63
|
+
def supports_scrubbing
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
def scrub(transcript)
|
68
|
+
transcript.
|
69
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
70
|
+
gsub(%r((&?card%5Bnumber%5D=)[^&]*)i, '\1[FILTERED]').
|
71
|
+
gsub(%r((&?card%5Bcvc%5D=)[^&]*)i, '\1[FILTERED]')
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def add_order(post, money, options)
|
77
|
+
post[:description] = options[:description] || 'Active Merchant Purchase'
|
78
|
+
post[:reference_id] = options[:order_id] if options[:order_id]
|
79
|
+
post[:currency] = (options[:currency] || currency(money)).downcase
|
80
|
+
post[:monthly_installments] = options[:monthly_installments] if options[:monthly_installments]
|
81
|
+
post[:amount] = amount(money)
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_details_data(post, options)
|
85
|
+
details = {}
|
86
|
+
details[:name] = options[:customer] || (options[:billing_address][:name] if options[:billing_address])
|
87
|
+
details[:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address])
|
88
|
+
details[:email] = options[:email] if options[:email]
|
89
|
+
details[:ip] = options[:ip] if options[:ip]
|
90
|
+
add_billing_address(details, options)
|
91
|
+
add_line_items(details, options)
|
92
|
+
add_shipment(details, options)
|
93
|
+
post[:details] = details
|
94
|
+
post[:device_fingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_shipment(post, options)
|
98
|
+
shipment = {}
|
99
|
+
shipment[:carrier] = options[:carrier] if options[:carrier]
|
100
|
+
shipment[:service] = options[:service] if options[:service]
|
101
|
+
shipment[:tracking_number] = options[:tracking_number] if options[:tracking_number]
|
102
|
+
shipment[:price] = options[:price] if options[:price]
|
103
|
+
add_shipment_address(shipment, options)
|
104
|
+
post[:shipment] = shipment
|
105
|
+
end
|
106
|
+
|
107
|
+
def add_shipment_address(post, options)
|
108
|
+
if (address = options[:shipping_address])
|
109
|
+
post[:address] = {}
|
110
|
+
post[:address][:street1] = address[:address1] if address[:address1]
|
111
|
+
post[:address][:street2] = address[:address2] if address[:address2]
|
112
|
+
post[:address][:street3] = address[:address3] if address[:address3]
|
113
|
+
post[:address][:city] = address[:city] if address[:city]
|
114
|
+
post[:address][:state] = address[:state] if address[:state]
|
115
|
+
post[:address][:country] = address[:country] if address[:country]
|
116
|
+
post[:address][:zip] = address[:zip] if address[:zip]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_line_items(post, options)
|
121
|
+
post[:line_items] = (options[:line_items] || []).collect do |line_item|
|
122
|
+
line_item
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_billing_address(post, options)
|
127
|
+
if (address = (options[:billing_address] || options[:address]))
|
128
|
+
post[:billing_address] = {}
|
129
|
+
post[:billing_address][:street1] = address[:address1] if address[:address1]
|
130
|
+
post[:billing_address][:street2] = address[:address2] if address[:address2]
|
131
|
+
post[:billing_address][:street3] = address[:address3] if address[:address3]
|
132
|
+
post[:billing_address][:city] = address[:city] if address[:city]
|
133
|
+
post[:billing_address][:state] = address[:state] if address[:state]
|
134
|
+
post[:billing_address][:country] = address[:country] if address[:country]
|
135
|
+
post[:billing_address][:zip] = address[:zip] if address[:zip]
|
136
|
+
post[:billing_address][:company_name] = address[:company_name] if address[:company_name]
|
137
|
+
post[:billing_address][:tax_id] = address[:tax_id] if address[:tax_id]
|
138
|
+
post[:billing_address][:name] = address[:name] if address[:name]
|
139
|
+
post[:billing_address][:phone] = address[:phone] if address[:phone]
|
140
|
+
post[:billing_address][:email] = address[:email] if address[:email]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def add_address(post, options)
|
145
|
+
if (address = (options[:billing_address] || options[:address]))
|
146
|
+
post[:address] = {}
|
147
|
+
post[:address][:street1] = address[:address1] if address[:address1]
|
148
|
+
post[:address][:street2] = address[:address2] if address[:address2]
|
149
|
+
post[:address][:street3] = address[:address3] if address[:address3]
|
150
|
+
post[:address][:city] = address[:city] if address[:city]
|
151
|
+
post[:address][:state] = address[:state] if address[:state]
|
152
|
+
post[:address][:country] = address[:country] if address[:country]
|
153
|
+
post[:address][:zip] = address[:zip] if address[:zip]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def add_payment_source(post, payment_source, options)
|
158
|
+
if payment_source.kind_of?(String)
|
159
|
+
post[:card] = payment_source
|
160
|
+
elsif payment_source.respond_to?(:number)
|
161
|
+
post[:card] = {}
|
162
|
+
post[:card][:name] = payment_source.name
|
163
|
+
post[:card][:cvc] = payment_source.verification_value
|
164
|
+
post[:card][:number] = payment_source.number
|
165
|
+
post[:card][:exp_month] = sprintf('%02d', payment_source.month)
|
166
|
+
post[:card][:exp_year] = payment_source.year.to_s[-2, 2]
|
167
|
+
add_address(post[:card], options)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def parse(body)
|
172
|
+
return {} unless body
|
173
|
+
|
174
|
+
JSON.parse(body)
|
175
|
+
end
|
176
|
+
|
177
|
+
def headers(options)
|
178
|
+
{
|
179
|
+
'Accept' => "application/vnd.conekta-v#{@options[:version]}+json",
|
180
|
+
'Accept-Language' => 'es',
|
181
|
+
'Authorization' => 'Basic ' + Base64.encode64("#{@options[:key]}:"),
|
182
|
+
'RaiseHtmlError' => 'false',
|
183
|
+
'Conekta-Client-User-Agent' => { 'agent' => "Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}" }.to_json,
|
184
|
+
'X-Conekta-Client-User-Agent' => conekta_client_user_agent(options),
|
185
|
+
'X-Conekta-Client-User-Metadata' => options[:meta].to_json
|
186
|
+
}
|
187
|
+
end
|
188
|
+
|
189
|
+
def conekta_client_user_agent(options)
|
190
|
+
return user_agent unless options[:application]
|
191
|
+
|
192
|
+
JSON.dump(JSON.parse(user_agent).merge!({ application: options[:application] }))
|
193
|
+
end
|
194
|
+
|
195
|
+
def commit(method, url, parameters, options = {})
|
196
|
+
success = false
|
197
|
+
begin
|
198
|
+
raw_response = parse(ssl_request(method, live_url + url, (parameters ? parameters.to_query : nil), headers(options)))
|
199
|
+
success = (raw_response.key?('object') && (raw_response['object'] != 'error'))
|
200
|
+
rescue ResponseError => e
|
201
|
+
raw_response = response_error(e.response.body)
|
202
|
+
rescue JSON::ParserError
|
203
|
+
raw_response = json_error(raw_response)
|
204
|
+
end
|
205
|
+
|
206
|
+
Response.new(
|
207
|
+
success,
|
208
|
+
raw_response['message_to_purchaser'],
|
209
|
+
raw_response,
|
210
|
+
test: test?,
|
211
|
+
authorization: raw_response['id']
|
212
|
+
)
|
213
|
+
end
|
214
|
+
|
215
|
+
def response_error(raw_response)
|
216
|
+
parse(raw_response)
|
217
|
+
rescue JSON::ParserError
|
218
|
+
json_error(raw_response)
|
219
|
+
end
|
220
|
+
|
221
|
+
def json_error(raw_response)
|
222
|
+
msg = 'Invalid response received from the Conekta API.'
|
223
|
+
msg += " (The raw response returned by the API was #{raw_response.inspect})"
|
224
|
+
{
|
225
|
+
'message' => msg
|
226
|
+
}
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,272 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class CreditcallGateway < Gateway
|
6
|
+
include Empty
|
7
|
+
|
8
|
+
self.test_url = 'https://test.cardeasexml.com/generic.cex'
|
9
|
+
self.live_url = 'https://live.cardeasexml.com/generic.cex'
|
10
|
+
|
11
|
+
self.supported_countries = ['US']
|
12
|
+
self.default_currency = 'USD'
|
13
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
14
|
+
|
15
|
+
self.homepage_url = 'https://www.creditcall.com'
|
16
|
+
self.display_name = 'Creditcall'
|
17
|
+
|
18
|
+
CVV_CODE = {
|
19
|
+
'matched' => 'M',
|
20
|
+
'notmatched' => 'N',
|
21
|
+
'notchecked' => 'P',
|
22
|
+
'partialmatch' => 'N'
|
23
|
+
}
|
24
|
+
|
25
|
+
AVS_CODE = {
|
26
|
+
'matched;matched' => 'D',
|
27
|
+
'matched;notchecked' => 'B',
|
28
|
+
'matched;notmatched' => 'A',
|
29
|
+
'matched;partialmatch' => 'A',
|
30
|
+
'notchecked;matched' => 'P',
|
31
|
+
'notchecked;notchecked' => 'I',
|
32
|
+
'notchecked;notmatched' => 'I',
|
33
|
+
'notchecked;partialmatch' => 'I',
|
34
|
+
'notmatched;matched' => 'W',
|
35
|
+
'notmatched;notchecked' => 'C',
|
36
|
+
'notmatched;notmatched' => 'C',
|
37
|
+
'notmatched;partialmatch' => 'C',
|
38
|
+
'partialmatched;matched' => 'W',
|
39
|
+
'partialmatched;notchecked' => 'C',
|
40
|
+
'partialmatched;notmatched' => 'C',
|
41
|
+
'partialmatched;partialmatch' => 'C'
|
42
|
+
}
|
43
|
+
|
44
|
+
def initialize(options = {})
|
45
|
+
requires!(options, :terminal_id, :transaction_key)
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def purchase(money, payment_method, options = {})
|
50
|
+
multi_response = MultiResponse.run do |r|
|
51
|
+
r.process { authorize(money, payment_method, options) }
|
52
|
+
r.process { capture(money, r.authorization, options) }
|
53
|
+
end
|
54
|
+
|
55
|
+
merged_params = multi_response.responses.map(&:params).reduce({}, :merge)
|
56
|
+
|
57
|
+
Response.new(
|
58
|
+
multi_response.primary_response.success?,
|
59
|
+
multi_response.primary_response.message,
|
60
|
+
merged_params,
|
61
|
+
authorization: multi_response.responses.first.authorization,
|
62
|
+
avs_result: AVSResult.new(code: avs_result_code_from(merged_params)),
|
63
|
+
cvv_result: CVVResult.new(cvv_result_code_from(merged_params)),
|
64
|
+
error_code: error_result_code_from(merged_params),
|
65
|
+
test: test?
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def authorize(money, payment_method, options = {})
|
70
|
+
request = build_xml_request do |xml|
|
71
|
+
add_transaction_details(xml, money, nil, 'Auth', options)
|
72
|
+
add_terminal_details(xml, options)
|
73
|
+
add_card_details(xml, payment_method, options)
|
74
|
+
end
|
75
|
+
|
76
|
+
commit(request)
|
77
|
+
end
|
78
|
+
|
79
|
+
def capture(money, authorization, options = {})
|
80
|
+
request = build_xml_request do |xml|
|
81
|
+
add_transaction_details(xml, money, authorization, 'Conf', options)
|
82
|
+
add_terminal_details(xml, options)
|
83
|
+
end
|
84
|
+
|
85
|
+
commit(request)
|
86
|
+
end
|
87
|
+
|
88
|
+
def refund(money, authorization, options = {})
|
89
|
+
request = build_xml_request do |xml|
|
90
|
+
add_transaction_details(xml, money, authorization, 'Refund', options)
|
91
|
+
add_terminal_details(xml, options)
|
92
|
+
end
|
93
|
+
|
94
|
+
commit(request)
|
95
|
+
end
|
96
|
+
|
97
|
+
def void(authorization, options = {})
|
98
|
+
request = build_xml_request do |xml|
|
99
|
+
add_transaction_details(xml, nil, authorization, 'Void', options)
|
100
|
+
add_terminal_details(xml, options)
|
101
|
+
end
|
102
|
+
|
103
|
+
commit(request)
|
104
|
+
end
|
105
|
+
|
106
|
+
def verify(credit_card, options = {})
|
107
|
+
MultiResponse.run(:use_first_response) do |r|
|
108
|
+
r.process { authorize(100, credit_card, options) }
|
109
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def supports_scrubbing?
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
def scrub(transcript)
|
118
|
+
transcript.
|
119
|
+
gsub(%r((<TransactionKey>).+?(</TransactionKey>))i, '\1[FILTERED]\2').
|
120
|
+
gsub(%r((<PAN>).+?(</PAN>))i, '\1[FILTERED]\2').
|
121
|
+
gsub(%r((<CSC>).+?(</CSC>))i, '\1[FILTERED]\2')
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def avs_result_code_from(params)
|
127
|
+
AVS_CODE["#{params['Address']};#{params['Zip']}"]
|
128
|
+
end
|
129
|
+
|
130
|
+
def cvv_result_code_from(params)
|
131
|
+
CVV_CODE[params['CSC']]
|
132
|
+
end
|
133
|
+
|
134
|
+
def error_result_code_from(params)
|
135
|
+
params['ErrorCode']
|
136
|
+
end
|
137
|
+
|
138
|
+
def build_xml_request
|
139
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
140
|
+
xml.Request(type: 'CardEaseXML', version: '1.0.0') do
|
141
|
+
yield(xml)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
builder.to_xml
|
145
|
+
end
|
146
|
+
|
147
|
+
def add_transaction_details(xml, amount, authorization, type, options = {})
|
148
|
+
xml.TransactionDetails do
|
149
|
+
xml.MessageType type
|
150
|
+
xml.Amount(unit: 'Minor') { xml.text(amount) } if amount
|
151
|
+
xml.CardEaseReference authorization if authorization
|
152
|
+
xml.VoidReason '01' if type == 'Void'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def add_terminal_details(xml, options = {})
|
157
|
+
xml.TerminalDetails do
|
158
|
+
xml.TerminalID @options[:terminal_id]
|
159
|
+
xml.TransactionKey @options[:transaction_key]
|
160
|
+
xml.Software(version: 'SoftwareVersion') { xml.text('SoftwareName') }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def add_card_details(xml, payment_method, options = {})
|
165
|
+
xml.CardDetails do
|
166
|
+
xml.Manual(type: manual_type(options)) do
|
167
|
+
xml.PAN payment_method.number
|
168
|
+
xml.ExpiryDate exp_date(payment_method)
|
169
|
+
xml.CSC payment_method.verification_value unless empty?(payment_method.verification_value)
|
170
|
+
end
|
171
|
+
|
172
|
+
add_additional_verification(xml, options)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def add_additional_verification(xml, options)
|
177
|
+
return unless (options[:verify_zip].to_s == 'true') || (options[:verify_address].to_s == 'true')
|
178
|
+
|
179
|
+
if address = options[:billing_address]
|
180
|
+
xml.AdditionalVerification do
|
181
|
+
xml.Zip address[:zip] if options[:verify_zip].to_s == 'true'
|
182
|
+
xml.Address address[:address1] if options[:verify_address].to_s == 'true'
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def exp_date(payment_method)
|
188
|
+
"#{format(payment_method.year, :two_digits)}#{format(payment_method.month, :two_digits)}"
|
189
|
+
end
|
190
|
+
|
191
|
+
def parse(body)
|
192
|
+
response = {}
|
193
|
+
xml = Nokogiri::XML(body)
|
194
|
+
|
195
|
+
node = xml.xpath('//Response/TransactionDetails')
|
196
|
+
node.children.each do |childnode|
|
197
|
+
response[childnode.name] = childnode.text
|
198
|
+
end
|
199
|
+
|
200
|
+
node = xml.xpath('//Response/Result')
|
201
|
+
node.children.each do |childnode|
|
202
|
+
if childnode.elements.empty?
|
203
|
+
response[childnode.name] = childnode.text
|
204
|
+
else
|
205
|
+
childnode_to_response(response, childnode)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
node = xml.xpath('//Response/CardDetails')
|
210
|
+
node.children.each do |childnode|
|
211
|
+
if childnode.elements.empty?
|
212
|
+
response[childnode.name] = childnode.text
|
213
|
+
else
|
214
|
+
childnode_to_response(response, childnode)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
response
|
219
|
+
end
|
220
|
+
|
221
|
+
def childnode_to_response(response, childnode)
|
222
|
+
childnode.elements.each do |element|
|
223
|
+
if element.name == 'Error'
|
224
|
+
response['ErrorCode'] = element.attr('code')
|
225
|
+
response['ErrorMessage'] = element.text
|
226
|
+
else
|
227
|
+
response[element.name] = element.text
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def commit(parameters)
|
233
|
+
response = parse(ssl_post(url, parameters))
|
234
|
+
|
235
|
+
Response.new(
|
236
|
+
success_from(response),
|
237
|
+
message_from(response),
|
238
|
+
response,
|
239
|
+
authorization: authorization_from(response),
|
240
|
+
avs_result: AVSResult.new(code: avs_result_code_from(response)),
|
241
|
+
cvv_result: CVVResult.new(cvv_result_code_from(response)),
|
242
|
+
error_code: error_result_code_from(response),
|
243
|
+
test: test?
|
244
|
+
)
|
245
|
+
end
|
246
|
+
|
247
|
+
def url
|
248
|
+
test? ? test_url : live_url
|
249
|
+
end
|
250
|
+
|
251
|
+
def success_from(response)
|
252
|
+
response['LocalResult'] == '0' || response['LocalResult'] == '00'
|
253
|
+
end
|
254
|
+
|
255
|
+
def message_from(response)
|
256
|
+
if success_from(response)
|
257
|
+
'Succeeded'
|
258
|
+
else
|
259
|
+
response['ErrorMessage']
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def authorization_from(response)
|
264
|
+
response['CardEaseReference']
|
265
|
+
end
|
266
|
+
|
267
|
+
def manual_type(options)
|
268
|
+
options[:manual_type] || 'ecommerce'
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|