swiss-activemerchant 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +249 -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 +243 -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 +227 -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 +312 -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 +120 -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,235 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CashnetGateway < Gateway
|
4
|
+
include Empty
|
5
|
+
|
6
|
+
self.live_url = 'https://commerce.cashnet.com/'
|
7
|
+
self.test_url = 'https://train.cashnet.com/'
|
8
|
+
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
11
|
+
self.homepage_url = 'https://transactcampus.com'
|
12
|
+
self.display_name = 'Cashnet'
|
13
|
+
self.money_format = :dollars
|
14
|
+
self.max_retries = 0
|
15
|
+
|
16
|
+
# Creates a new CashnetGateway
|
17
|
+
#
|
18
|
+
# ==== Options
|
19
|
+
#
|
20
|
+
# * <tt>:merchant</tt> -- Gateway Merchant (REQUIRED)
|
21
|
+
# * <tt>:operator</tt> -- Operator (REQUIRED)
|
22
|
+
# * <tt>:password</tt> -- Password (REQUIRED)
|
23
|
+
# * <tt>:merchant_gateway_name</tt> -- Site name (REQUIRED)
|
24
|
+
# * <tt>:station</tt> -- Station (defaults to "WEB")
|
25
|
+
# * <tt>:custcode</tt> -- Customer code (defaults to
|
26
|
+
# "ActiveMerchant/#{ActiveMerchant::VERSION}")
|
27
|
+
# * <tt>:default_item_code</tt> -- Default item code (defaults to "FEE",
|
28
|
+
# can be overridden on a per-transaction basis with options[:item_code])
|
29
|
+
def initialize(options = {})
|
30
|
+
requires!(
|
31
|
+
options,
|
32
|
+
:merchant,
|
33
|
+
:operator,
|
34
|
+
:password,
|
35
|
+
:merchant_gateway_name
|
36
|
+
)
|
37
|
+
options[:default_item_code] ||= 'FEE'
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def purchase(money, payment_object, options = {})
|
42
|
+
post = {}
|
43
|
+
add_creditcard(post, payment_object)
|
44
|
+
add_invoice(post, money, options)
|
45
|
+
add_address(post, options)
|
46
|
+
add_customer_data(post, options)
|
47
|
+
commit('SALE', money, post)
|
48
|
+
end
|
49
|
+
|
50
|
+
def refund(money, identification, options = {})
|
51
|
+
post = {}
|
52
|
+
post[:origtx] = identification
|
53
|
+
add_invoice(post, money, options)
|
54
|
+
add_customer_data(post, options)
|
55
|
+
commit('REFUND', money, post)
|
56
|
+
end
|
57
|
+
|
58
|
+
def supports_scrubbing?
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
def scrub(transcript)
|
63
|
+
transcript.
|
64
|
+
gsub(%r{(password=)[^&]+}, '\1[FILTERED]').
|
65
|
+
gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]').
|
66
|
+
gsub(%r{(cid=)[^&]+}, '\1[FILTERED]')
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def commit(action, money, fields)
|
72
|
+
url = (test? ? test_url : live_url) + CGI.escape(@options[:merchant_gateway_name])
|
73
|
+
raw_response = ssl_post(url, post_data(action, fields))
|
74
|
+
parsed_response = parse(raw_response)
|
75
|
+
|
76
|
+
return unparsable_response(raw_response) unless parsed_response
|
77
|
+
|
78
|
+
success = success?(parsed_response)
|
79
|
+
Response.new(
|
80
|
+
success,
|
81
|
+
CASHNET_CODES[parsed_response[:result]],
|
82
|
+
parsed_response,
|
83
|
+
test: test?,
|
84
|
+
authorization: (success ? parsed_response[:tx] : '')
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
def success?(response)
|
89
|
+
response[:result] == '0'
|
90
|
+
end
|
91
|
+
|
92
|
+
def post_data(action, parameters = {})
|
93
|
+
post = {}
|
94
|
+
|
95
|
+
post[:command] = action
|
96
|
+
post[:merchant] = @options[:merchant]
|
97
|
+
post[:operator] = @options[:operator]
|
98
|
+
post[:password] = @options[:password]
|
99
|
+
post[:station] = (@options[:station] || 'WEB')
|
100
|
+
post[:custcode] = (@options[:custcode] || "ActiveMerchant/#{ActiveMerchant::VERSION}")
|
101
|
+
post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
102
|
+
end
|
103
|
+
|
104
|
+
def add_creditcard(post, creditcard)
|
105
|
+
post[:cardno] = creditcard.number
|
106
|
+
post[:cid] = creditcard.verification_value
|
107
|
+
post[:expdate] = expdate(creditcard)
|
108
|
+
post[:card_name_g] = creditcard.name
|
109
|
+
post[:fname] = creditcard.first_name
|
110
|
+
post[:lname] = creditcard.last_name
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_invoice(post, money, options)
|
114
|
+
post[:order_number] = options[:order_id] if options[:order_id].present?
|
115
|
+
|
116
|
+
if options[:item_codes].present?
|
117
|
+
codes_and_amounts = options[:item_codes].transform_keys { |key| key.to_s.delete('_') }
|
118
|
+
codes_and_amounts.each do |key, value|
|
119
|
+
post[key] = value if key.start_with?('itemcode')
|
120
|
+
post[key] = amount(value.to_i) if key.start_with?('amount')
|
121
|
+
end
|
122
|
+
else
|
123
|
+
post[:itemcode] = (options[:item_code] || @options[:default_item_code])
|
124
|
+
post[:amount] = amount(money.to_i)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_address(post, options)
|
129
|
+
if address = (options[:shipping_address] || options[:billing_address] || options[:address])
|
130
|
+
post[:addr_g] = String(address[:address1]) + ',' + String(address[:address2])
|
131
|
+
post[:city_g] = address[:city]
|
132
|
+
post[:state_g] = address[:state]
|
133
|
+
post[:zip_g] = address[:zip]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def add_customer_data(post, options)
|
138
|
+
post[:email_g] = options[:email]
|
139
|
+
post[:custcode] = options[:custcode] unless empty?(options[:custcode])
|
140
|
+
end
|
141
|
+
|
142
|
+
def expdate(creditcard)
|
143
|
+
year = format(creditcard.year, :two_digits)
|
144
|
+
month = format(creditcard.month, :two_digits)
|
145
|
+
|
146
|
+
"#{month}#{year}"
|
147
|
+
end
|
148
|
+
|
149
|
+
def parse(body)
|
150
|
+
match = body.match(/<cngateway>(.*)<\/cngateway>/)
|
151
|
+
return nil unless match
|
152
|
+
|
153
|
+
Hash[CGI::parse(match[1]).map { |k, v| [k.to_sym, v.first] }]
|
154
|
+
end
|
155
|
+
|
156
|
+
def handle_response(response)
|
157
|
+
if (200...300).cover?(response.code.to_i)
|
158
|
+
return response.body
|
159
|
+
elsif response.code.to_i == 302
|
160
|
+
return ssl_get(URI.parse(response['location']))
|
161
|
+
end
|
162
|
+
|
163
|
+
raise ResponseError.new(response)
|
164
|
+
end
|
165
|
+
|
166
|
+
def unparsable_response(raw_response)
|
167
|
+
message = 'Unparsable response received from Cashnet. Please contact Cashnet if you continue to receive this message.'
|
168
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
169
|
+
return Response.new(false, message)
|
170
|
+
end
|
171
|
+
|
172
|
+
CASHNET_CODES = {
|
173
|
+
'0' => 'Success',
|
174
|
+
'1' => 'Invalid customer code, no customer code specified',
|
175
|
+
'2' => 'Invalid operator code, no operator specified',
|
176
|
+
'3' => 'Invalid workstation code, no station specified',
|
177
|
+
'4' => 'Invalid item code, no code specified',
|
178
|
+
'5' => 'Negative amount is not allowed',
|
179
|
+
'6' => 'Invalid credit card number, no credit card number provided',
|
180
|
+
'7' => 'Invalid expiration date, no expiration date provided',
|
181
|
+
'8' => 'Please only provide either ACH or credit card information',
|
182
|
+
'9' => 'Invalid ACH account number, no account number provided',
|
183
|
+
'10' => 'Invalid routing/transit number, no routing/transit number provided',
|
184
|
+
'11' => 'Invalid account type, no account type provided',
|
185
|
+
'12' => 'Invalid check digit for routing/transit number',
|
186
|
+
'13' => 'No ACH merchant account set up for the location of the station being used',
|
187
|
+
'21' => 'Invalid merchant code, no merchant code provided',
|
188
|
+
'22' => 'Invalid client code, no client code provided',
|
189
|
+
'23' => 'Invalid password, no password provided',
|
190
|
+
'24' => 'Invalid transaction type, no transaction type provided',
|
191
|
+
'25' => 'Invalid amount, amount not provided',
|
192
|
+
'26' => 'Invalid payment code provided',
|
193
|
+
'27' => 'Invalid version number, version not found',
|
194
|
+
'31' => 'Application amount exceeds account balance',
|
195
|
+
'150' => 'Invalid payment information, no payment information provided',
|
196
|
+
'200' => 'Invalid command',
|
197
|
+
'201' => 'Customer not on file',
|
198
|
+
'205' => 'Invalid operator or password',
|
199
|
+
'206' => 'Operator is not authorized for this function',
|
200
|
+
'208' => 'Customer/PIN authentication unsuccessful',
|
201
|
+
'209' => 'Credit card error',
|
202
|
+
'211' => 'Credit card error',
|
203
|
+
'212' => 'Customer/PIN not on file',
|
204
|
+
'213' => 'Customer information not on file',
|
205
|
+
'215' => 'Old PIN does not validate ',
|
206
|
+
'221' => 'Invalid credit card processor type specified in location or payment code',
|
207
|
+
'222' => 'Credit card processor error',
|
208
|
+
'230' => 'Host Error (USE VOID OR REVERSAL TO REFUND UNSETTLED TRANSACTIONS)',
|
209
|
+
'280' => 'SmartPay transaction not posted',
|
210
|
+
'301' => 'Original transaction not found for this customer',
|
211
|
+
'302' => 'Amount to refund exceeds original payment amount or is missing',
|
212
|
+
'304' => 'Original credit card payment not found or corrupted',
|
213
|
+
'305' => 'Refund amounts should be expressed as positive amounts',
|
214
|
+
'306' => 'Original ACH payment not found',
|
215
|
+
'307' => 'Original electronic payment not found',
|
216
|
+
'308' => 'Invalid original transaction number, original transaction number not found',
|
217
|
+
'310' => 'Refund amount exceeds amount still available for a refund',
|
218
|
+
'321' => 'Store has not been implemented',
|
219
|
+
'501' => 'Unable to roll over batch',
|
220
|
+
'502' => 'Batch not found',
|
221
|
+
'503' => 'Batch information not available',
|
222
|
+
'650' => 'Invalid quick code',
|
223
|
+
'651' => 'Transaction amount does not match amount specified in quick code',
|
224
|
+
'652' => 'Invalid item code in the detail of the quick code',
|
225
|
+
'701' => 'This website has been disabled. Please contact the system administrator.',
|
226
|
+
'702' => 'Improper merchant code. Please contact the system administrator.',
|
227
|
+
'703' => 'This site is temporarily down for maintenance. We regret the inconvenience. Please try again later.',
|
228
|
+
'704' => 'Duplicate item violation. Please contact the system administrator.',
|
229
|
+
'705' => 'An invalid reference type has been passed into the system. Please contact the system administrator',
|
230
|
+
'706' => 'Items violating unique selection have been passed in. Please contact the system administrator.',
|
231
|
+
'999' => 'An unexpected error has occurred. Please consult the event log.'
|
232
|
+
}
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# CC5 API is used by many banks in Turkey. Extend this base class to provide
|
4
|
+
# concrete implementations.
|
5
|
+
class CC5Gateway < Gateway
|
6
|
+
self.default_currency = 'TRY'
|
7
|
+
|
8
|
+
CURRENCY_CODES = {
|
9
|
+
'TRY' => 949,
|
10
|
+
'YTL' => 949,
|
11
|
+
'TRL' => 949,
|
12
|
+
'TL' => 949,
|
13
|
+
'USD' => 840,
|
14
|
+
'EUR' => 978,
|
15
|
+
'GBP' => 826,
|
16
|
+
'JPY' => 392
|
17
|
+
}
|
18
|
+
|
19
|
+
def initialize(options = {})
|
20
|
+
requires!(options, :login, :password, :client_id)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def purchase(money, creditcard, options = {})
|
25
|
+
commit(build_sale_request('Auth', money, creditcard, options))
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(money, creditcard, options = {})
|
29
|
+
commit(build_sale_request('PreAuth', money, creditcard, options))
|
30
|
+
end
|
31
|
+
|
32
|
+
def capture(money, authorization, options = {})
|
33
|
+
commit(build_capture_request(money, authorization, options))
|
34
|
+
end
|
35
|
+
|
36
|
+
def void(authorization, options = {})
|
37
|
+
commit(build_void_request(authorization, options))
|
38
|
+
end
|
39
|
+
|
40
|
+
def refund(money, authorization, options = {})
|
41
|
+
commit(build_authorization_credit_request(money, authorization, options))
|
42
|
+
end
|
43
|
+
|
44
|
+
def credit(money, creditcard, options = {})
|
45
|
+
commit(build_creditcard_credit_request(money, creditcard, options))
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def build_sale_request(type, money, creditcard, options = {})
|
51
|
+
requires!(options, :order_id)
|
52
|
+
|
53
|
+
xml = Builder::XmlMarkup.new indent: 2
|
54
|
+
|
55
|
+
xml.tag! 'CC5Request' do
|
56
|
+
add_login_tags(xml)
|
57
|
+
xml.tag! 'OrderId', options[:order_id]
|
58
|
+
xml.tag! 'Type', type
|
59
|
+
xml.tag! 'Number', creditcard.number
|
60
|
+
xml.tag! 'Expires', [format(creditcard.month, :two_digits), format(creditcard.year, :two_digits)].join('/')
|
61
|
+
xml.tag! 'Cvv2Val', creditcard.verification_value
|
62
|
+
add_amount_tags(money, options, xml)
|
63
|
+
xml.tag! 'Email', options[:email] if options[:email]
|
64
|
+
|
65
|
+
if (address = (options[:billing_address] || options[:address]))
|
66
|
+
xml.tag! 'BillTo' do
|
67
|
+
add_address(xml, address)
|
68
|
+
end
|
69
|
+
xml.tag! 'ShipTo' do
|
70
|
+
add_address(xml, address)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
xml.target!
|
76
|
+
end
|
77
|
+
|
78
|
+
def build_capture_request(money, authorization, options = {})
|
79
|
+
xml = Builder::XmlMarkup.new indent: 2
|
80
|
+
|
81
|
+
xml.tag! 'CC5Request' do
|
82
|
+
add_login_tags(xml)
|
83
|
+
xml.tag! 'OrderId', authorization
|
84
|
+
xml.tag! 'Type', 'PostAuth'
|
85
|
+
add_amount_tags(money, options, xml)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def build_void_request(authorization, options = {})
|
90
|
+
xml = Builder::XmlMarkup.new indent: 2
|
91
|
+
|
92
|
+
xml.tag! 'CC5Request' do
|
93
|
+
add_login_tags(xml)
|
94
|
+
xml.tag! 'OrderId', authorization
|
95
|
+
xml.tag! 'Type', 'Void'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_authorization_credit_request(money, authorization, options = {})
|
100
|
+
xml = Builder::XmlMarkup.new indent: 2
|
101
|
+
|
102
|
+
xml.tag! 'CC5Request' do
|
103
|
+
add_login_tags(xml)
|
104
|
+
xml.tag! 'OrderId', authorization
|
105
|
+
xml.tag! 'Type', 'Credit'
|
106
|
+
add_amount_tags(money, options, xml)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def build_creditcard_credit_request(money, creditcard, options = {})
|
111
|
+
xml = Builder::XmlMarkup.new indent: 2
|
112
|
+
|
113
|
+
xml.tag! 'CC5Request' do
|
114
|
+
add_login_tags(xml)
|
115
|
+
xml.tag! 'Type', 'Credit'
|
116
|
+
xml.tag! 'Number', creditcard.number
|
117
|
+
|
118
|
+
add_amount_tags(money, options, xml)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_address(xml, address)
|
123
|
+
xml.tag! 'Name', normalize(address[:name])
|
124
|
+
xml.tag! 'Street1', normalize(address[:address1])
|
125
|
+
xml.tag! 'Street2', normalize(address[:address2]) if address[:address2]
|
126
|
+
xml.tag! 'City', normalize(address[:city])
|
127
|
+
xml.tag! 'PostalCode', address[:zip]
|
128
|
+
xml.tag! 'Country', normalize(address[:country])
|
129
|
+
xml.tag! 'Company', normalize(address[:company])
|
130
|
+
xml.tag! 'TelVoice', address[:phone].to_s.gsub(/[^0-9]/, '') if address[:phone]
|
131
|
+
end
|
132
|
+
|
133
|
+
def add_login_tags(xml)
|
134
|
+
xml.tag! 'Name', @options[:login]
|
135
|
+
xml.tag! 'Password', @options[:password]
|
136
|
+
xml.tag! 'ClientId', @options[:client_id]
|
137
|
+
xml.tag! 'Mode', (test? ? 'T' : 'P')
|
138
|
+
end
|
139
|
+
|
140
|
+
def add_amount_tags(money, options, xml)
|
141
|
+
xml.tag! 'Total', amount(money)
|
142
|
+
xml.tag! 'Currency', currency_code(options[:currency] || currency(money))
|
143
|
+
end
|
144
|
+
|
145
|
+
def currency_code(currency)
|
146
|
+
(CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency])
|
147
|
+
end
|
148
|
+
|
149
|
+
def commit(request)
|
150
|
+
raw_response = ssl_post((test? ? self.test_url : self.live_url), 'DATA=' + request)
|
151
|
+
|
152
|
+
response = parse(raw_response)
|
153
|
+
|
154
|
+
success = success?(response)
|
155
|
+
|
156
|
+
Response.new(
|
157
|
+
success,
|
158
|
+
(success ? 'Approved' : "Declined (Reason: #{response[:proc_return_code]} - #{response[:err_msg]})"),
|
159
|
+
response,
|
160
|
+
test: test?,
|
161
|
+
authorization: response[:order_id]
|
162
|
+
)
|
163
|
+
end
|
164
|
+
|
165
|
+
def parse(body)
|
166
|
+
xml = REXML::Document.new(body)
|
167
|
+
|
168
|
+
response = {}
|
169
|
+
xml.root.elements.to_a.each do |node|
|
170
|
+
parse_element(response, node)
|
171
|
+
end
|
172
|
+
response
|
173
|
+
end
|
174
|
+
|
175
|
+
def parse_element(response, node)
|
176
|
+
if node.has_elements?
|
177
|
+
node.elements.each { |element| parse_element(response, element) }
|
178
|
+
else
|
179
|
+
response[node.name.underscore.to_sym] = node.text
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def success?(response)
|
184
|
+
(response[:response] == 'Approved')
|
185
|
+
end
|
186
|
+
|
187
|
+
def normalize(text)
|
188
|
+
return unless text
|
189
|
+
|
190
|
+
if ActiveSupport::Inflector.method(:transliterate).arity == -2
|
191
|
+
ActiveSupport::Inflector.transliterate(text, '')
|
192
|
+
else
|
193
|
+
text.gsub(/[^\x00-\x7F]+/, '')
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CecabankGateway < Gateway
|
4
|
+
self.test_url = 'https://tpv.ceca.es'
|
5
|
+
self.live_url = 'https://pgw.ceca.es'
|
6
|
+
|
7
|
+
self.supported_countries = ['ES']
|
8
|
+
self.supported_cardtypes = %i[visa master american_express]
|
9
|
+
self.homepage_url = 'http://www.ceca.es/es/'
|
10
|
+
self.display_name = 'Cecabank'
|
11
|
+
self.default_currency = 'EUR'
|
12
|
+
self.money_format = :cents
|
13
|
+
|
14
|
+
#### CECA's MAGIC NUMBERS
|
15
|
+
CECA_NOTIFICATIONS_URL = 'NONE'
|
16
|
+
CECA_ENCRIPTION = 'SHA2'
|
17
|
+
CECA_DECIMALS = '2'
|
18
|
+
CECA_MODE = 'SSL'
|
19
|
+
CECA_UI_LESS_LANGUAGE = 'XML'
|
20
|
+
CECA_UI_LESS_LANGUAGE_REFUND = '1'
|
21
|
+
CECA_UI_LESS_REFUND_PAGE = 'anulacion_xml'
|
22
|
+
CECA_ACTION_REFUND = 'anulaciones/anularParcial' # use partial refund's URL to avoid time frame limitations and decision logic on client side
|
23
|
+
CECA_ACTION_PURCHASE = 'tpv/compra'
|
24
|
+
CECA_CURRENCIES_DICTIONARY = { 'EUR' => 978, 'USD' => 840, 'GBP' => 826 }
|
25
|
+
|
26
|
+
# Creates a new CecabankGateway
|
27
|
+
#
|
28
|
+
# The gateway requires four values for connection to be passed
|
29
|
+
# in the +options+ hash.
|
30
|
+
#
|
31
|
+
# ==== Options
|
32
|
+
#
|
33
|
+
# * <tt>:merchant_id</tt> -- Cecabank's merchant_id (REQUIRED)
|
34
|
+
# * <tt>:acquirer_bin</tt> -- Cecabank's acquirer_bin (REQUIRED)
|
35
|
+
# * <tt>:terminal_id</tt> -- Cecabank's terminal_id (REQUIRED)
|
36
|
+
# * <tt>:key</tt> -- Cecabank's cypher key (REQUIRED)
|
37
|
+
# * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
|
38
|
+
# Otherwise, perform transactions against the production server.
|
39
|
+
def initialize(options = {})
|
40
|
+
requires!(options, :merchant_id, :acquirer_bin, :terminal_id, :key)
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
45
|
+
#
|
46
|
+
# ==== Parameters
|
47
|
+
#
|
48
|
+
# * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
|
49
|
+
# * <tt>creditcard</tt> -- The CreditCard details for the transaction.
|
50
|
+
# * <tt>options</tt> -- A hash of optional parameters.
|
51
|
+
#
|
52
|
+
# ==== Options
|
53
|
+
#
|
54
|
+
# * <tt>:order_id</tt> -- order_id passed used purchase. (REQUIRED)
|
55
|
+
# * <tt>:currency</tt> -- currency. Supported: EUR, USD, GBP.
|
56
|
+
# * <tt>:description</tt> -- description to be pased to the gateway.
|
57
|
+
def purchase(money, creditcard, options = {})
|
58
|
+
requires!(options, :order_id)
|
59
|
+
|
60
|
+
post = { 'Descripcion' => options[:description],
|
61
|
+
'Num_operacion' => options[:order_id],
|
62
|
+
'Idioma' => CECA_UI_LESS_LANGUAGE,
|
63
|
+
'Pago_soportado' => CECA_MODE,
|
64
|
+
'URL_OK' => CECA_NOTIFICATIONS_URL,
|
65
|
+
'URL_NOK' => CECA_NOTIFICATIONS_URL,
|
66
|
+
'Importe' => amount(money),
|
67
|
+
'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)] }
|
68
|
+
|
69
|
+
add_creditcard(post, creditcard)
|
70
|
+
|
71
|
+
commit(CECA_ACTION_PURCHASE, post)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Refund a transaction.
|
75
|
+
#
|
76
|
+
# This transaction indicates to the gateway that
|
77
|
+
# money should flow from the merchant to the customer.
|
78
|
+
#
|
79
|
+
# ==== Parameters
|
80
|
+
#
|
81
|
+
# * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
|
82
|
+
# * <tt>identification</tt> -- The reference given from the gateway on purchase (reference, not operation).
|
83
|
+
# * <tt>options</tt> -- A hash of parameters.
|
84
|
+
def refund(money, identification, options = {})
|
85
|
+
reference, order_id = split_authorization(identification)
|
86
|
+
|
87
|
+
post = { 'Referencia' => reference,
|
88
|
+
'Num_operacion' => order_id,
|
89
|
+
'Idioma' => CECA_UI_LESS_LANGUAGE_REFUND,
|
90
|
+
'Pagina' => CECA_UI_LESS_REFUND_PAGE,
|
91
|
+
'Importe' => amount(money),
|
92
|
+
'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)] }
|
93
|
+
|
94
|
+
commit(CECA_ACTION_REFUND, post)
|
95
|
+
end
|
96
|
+
|
97
|
+
def supports_scrubbing
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
def scrub(transcript)
|
102
|
+
transcript.
|
103
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
104
|
+
gsub(%r((&?pan=)[^&]*)i, '\1[FILTERED]').
|
105
|
+
gsub(%r((&?cvv2=)[^&]*)i, '\1[FILTERED]')
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def add_creditcard(post, creditcard)
|
111
|
+
post['PAN'] = creditcard.number
|
112
|
+
post['Caducidad'] = expdate(creditcard)
|
113
|
+
post['CVV2'] = creditcard.verification_value
|
114
|
+
post['Pago_elegido'] = CECA_MODE
|
115
|
+
end
|
116
|
+
|
117
|
+
def expdate(creditcard)
|
118
|
+
"#{format(creditcard.year, :four_digits)}#{format(creditcard.month, :two_digits)}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def parse(body)
|
122
|
+
response = {}
|
123
|
+
|
124
|
+
root = REXML::Document.new(body).root
|
125
|
+
|
126
|
+
response[:success] = (root.attributes['valor'] == 'OK')
|
127
|
+
response[:date] = root.attributes['fecha']
|
128
|
+
response[:operation_number] = root.attributes['numeroOperacion']
|
129
|
+
response[:message] = root.attributes['valor']
|
130
|
+
|
131
|
+
if root.elements['OPERACION']
|
132
|
+
response[:operation_type] = root.elements['OPERACION'].attributes['tipo']
|
133
|
+
response[:amount] = root.elements['OPERACION/importe'].text.strip
|
134
|
+
end
|
135
|
+
|
136
|
+
response[:description] = root.elements['OPERACION/descripcion'].text if root.elements['OPERACION/descripcion']
|
137
|
+
response[:authorization_number] = root.elements['OPERACION/numeroAutorizacion'].text if root.elements['OPERACION/numeroAutorizacion']
|
138
|
+
response[:reference] = root.elements['OPERACION/referencia'].text if root.elements['OPERACION/referencia']
|
139
|
+
response[:pan] = root.elements['OPERACION/pan'].text if root.elements['OPERACION/pan']
|
140
|
+
|
141
|
+
if root.elements['ERROR']
|
142
|
+
response[:error_code] = root.elements['ERROR/codigo'].text
|
143
|
+
response[:error_message] = root.elements['ERROR/descripcion'].text
|
144
|
+
else
|
145
|
+
if root.elements['OPERACION'].attributes['numeroOperacion'] == '000'
|
146
|
+
response[:authorization] = root.elements['OPERACION/numeroAutorizacion'].text if root.elements['OPERACION/numeroAutorizacion']
|
147
|
+
else
|
148
|
+
response[:authorization] = root.attributes['numeroOperacion']
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
return response
|
153
|
+
rescue REXML::ParseException => e
|
154
|
+
response[:success] = false
|
155
|
+
response[:message] = 'Unable to parse the response.'
|
156
|
+
response[:error_message] = e.message
|
157
|
+
response
|
158
|
+
end
|
159
|
+
|
160
|
+
def commit(action, parameters)
|
161
|
+
parameters.merge!(
|
162
|
+
'Cifrado' => CECA_ENCRIPTION,
|
163
|
+
'Firma' => generate_signature(action, parameters),
|
164
|
+
'Exponente' => CECA_DECIMALS,
|
165
|
+
'MerchantID' => options[:merchant_id],
|
166
|
+
'AcquirerBIN' => options[:acquirer_bin],
|
167
|
+
'TerminalID' => options[:terminal_id]
|
168
|
+
)
|
169
|
+
url = (test? ? self.test_url : self.live_url) + "/tpvweb/#{action}.action"
|
170
|
+
xml = ssl_post("#{url}?", post_data(parameters))
|
171
|
+
response = parse(xml)
|
172
|
+
Response.new(
|
173
|
+
response[:success],
|
174
|
+
message_from(response),
|
175
|
+
response,
|
176
|
+
test: test?,
|
177
|
+
authorization: build_authorization(response),
|
178
|
+
error_code: response[:error_code]
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
def message_from(response)
|
183
|
+
if response[:message] == 'ERROR' && response[:error_message]
|
184
|
+
response[:error_message]
|
185
|
+
elsif response[:error_message]
|
186
|
+
"#{response[:message]} #{response[:error_message]}"
|
187
|
+
else
|
188
|
+
response[:message]
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def post_data(params)
|
193
|
+
return nil unless params
|
194
|
+
|
195
|
+
params.map do |key, value|
|
196
|
+
next if value.blank?
|
197
|
+
|
198
|
+
if value.is_a?(Hash)
|
199
|
+
h = {}
|
200
|
+
value.each do |k, v|
|
201
|
+
h["#{key}.#{k}"] = v unless v.blank?
|
202
|
+
end
|
203
|
+
post_data(h)
|
204
|
+
else
|
205
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
206
|
+
end
|
207
|
+
end.compact.join('&')
|
208
|
+
end
|
209
|
+
|
210
|
+
def build_authorization(response)
|
211
|
+
[response[:reference], response[:authorization]].join('|')
|
212
|
+
end
|
213
|
+
|
214
|
+
def split_authorization(authorization)
|
215
|
+
authorization.split('|')
|
216
|
+
end
|
217
|
+
|
218
|
+
def generate_signature(action, parameters)
|
219
|
+
signature_fields =
|
220
|
+
case action
|
221
|
+
when CECA_ACTION_REFUND
|
222
|
+
options[:key].to_s +
|
223
|
+
options[:merchant_id].to_s +
|
224
|
+
options[:acquirer_bin].to_s +
|
225
|
+
options[:terminal_id].to_s +
|
226
|
+
parameters['Num_operacion'].to_s +
|
227
|
+
parameters['Importe'].to_s +
|
228
|
+
parameters['TipoMoneda'].to_s +
|
229
|
+
CECA_DECIMALS +
|
230
|
+
parameters['Referencia'].to_s +
|
231
|
+
CECA_ENCRIPTION
|
232
|
+
else
|
233
|
+
options[:key].to_s +
|
234
|
+
options[:merchant_id].to_s +
|
235
|
+
options[:acquirer_bin].to_s +
|
236
|
+
options[:terminal_id].to_s +
|
237
|
+
parameters['Num_operacion'].to_s +
|
238
|
+
parameters['Importe'].to_s +
|
239
|
+
parameters['TipoMoneda'].to_s +
|
240
|
+
CECA_DECIMALS +
|
241
|
+
CECA_ENCRIPTION +
|
242
|
+
CECA_NOTIFICATIONS_URL +
|
243
|
+
CECA_NOTIFICATIONS_URL
|
244
|
+
end
|
245
|
+
Digest::SHA2.hexdigest(signature_fields)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|