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,224 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class VerifiGateway < Gateway
|
6
|
+
class VerifiPostData < PostData
|
7
|
+
# Fields that will be sent even if they are blank
|
8
|
+
self.required_fields = %i[amount type ccnumber ccexp firstname lastname
|
9
|
+
company address1 address2 city state zip country phone]
|
10
|
+
end
|
11
|
+
|
12
|
+
self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php'
|
13
|
+
|
14
|
+
RESPONSE_CODE_MESSAGES = {
|
15
|
+
'100' => 'Transaction was Approved',
|
16
|
+
'200' => 'Transaction was Declined by Processor',
|
17
|
+
'201' => 'Do Not Honor',
|
18
|
+
'202' => 'Insufficient Funds',
|
19
|
+
'203' => 'Over Limit',
|
20
|
+
'204' => 'Transaction not allowed',
|
21
|
+
'220' => 'Incorrect payment Data',
|
22
|
+
'221' => 'No Such Card Issuer',
|
23
|
+
'222' => 'No Card Number on file with Issuer',
|
24
|
+
'223' => 'Expired Card',
|
25
|
+
'224' => 'Invalid Expiration Date',
|
26
|
+
'225' => 'Invalid Card Security Code',
|
27
|
+
'240' => 'Call Issuer for Further Information',
|
28
|
+
'250' => 'Pick Up Card',
|
29
|
+
'251' => 'Lost Card',
|
30
|
+
'252' => 'Stolen Card',
|
31
|
+
'253' => 'Fraudulent Card',
|
32
|
+
'260' => 'Declined With further Instructions Available (see response text)',
|
33
|
+
'261' => 'Declined - Stop All Recurring Payments',
|
34
|
+
'262' => 'Declined - Stop this Recurring Program',
|
35
|
+
'263' => 'Declined - Update Cardholder Data Available',
|
36
|
+
'264' => 'Declined - Retry in a few days',
|
37
|
+
'300' => 'Transaction was Rejected by Gateway',
|
38
|
+
'400' => 'Transaction Error Returned by Processor',
|
39
|
+
'410' => 'Invalid Merchant Configuration',
|
40
|
+
'411' => 'Merchant Account is Inactive',
|
41
|
+
'420' => 'Communication Error',
|
42
|
+
'421' => 'Communication Error with Issuer',
|
43
|
+
'430' => 'Duplicate Transaction at Processor',
|
44
|
+
'440' => 'Processor Format Error',
|
45
|
+
'441' => 'Invalid Transaction Information',
|
46
|
+
'460' => 'Processor Feature Not Available',
|
47
|
+
'461' => 'Unsupported Card Type'
|
48
|
+
}
|
49
|
+
|
50
|
+
SUCCESS = 1
|
51
|
+
|
52
|
+
TRANSACTIONS = {
|
53
|
+
authorization: 'auth',
|
54
|
+
purchase: 'sale',
|
55
|
+
capture: 'capture',
|
56
|
+
void: 'void',
|
57
|
+
credit: 'credit',
|
58
|
+
refund: 'refund'
|
59
|
+
}
|
60
|
+
|
61
|
+
self.supported_countries = ['US']
|
62
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
63
|
+
self.homepage_url = 'http://www.verifi.com/'
|
64
|
+
self.display_name = 'Verifi'
|
65
|
+
|
66
|
+
def initialize(options = {})
|
67
|
+
requires!(options, :login, :password)
|
68
|
+
super
|
69
|
+
end
|
70
|
+
|
71
|
+
def purchase(money, credit_card, options = {})
|
72
|
+
sale_authorization_or_credit_template(:purchase, money, credit_card, options)
|
73
|
+
end
|
74
|
+
|
75
|
+
def authorize(money, credit_card, options = {})
|
76
|
+
sale_authorization_or_credit_template(:authorization, money, credit_card, options)
|
77
|
+
end
|
78
|
+
|
79
|
+
def capture(money, authorization, options = {})
|
80
|
+
capture_void_or_refund_template(:capture, money, authorization, options)
|
81
|
+
end
|
82
|
+
|
83
|
+
def void(authorization, options = {})
|
84
|
+
capture_void_or_refund_template(:void, 0, authorization, options)
|
85
|
+
end
|
86
|
+
|
87
|
+
def credit(money, credit_card_or_authorization, options = {})
|
88
|
+
if credit_card_or_authorization.is_a?(String)
|
89
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
90
|
+
refund(money, credit_card_or_authorization, options)
|
91
|
+
else
|
92
|
+
sale_authorization_or_credit_template(:credit, money, credit_card_or_authorization, options)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def refund(money, reference, options = {})
|
97
|
+
capture_void_or_refund_template(:refund, money, reference, options)
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def sale_authorization_or_credit_template(trx_type, money, credit_card, options = {})
|
103
|
+
post = VerifiPostData.new
|
104
|
+
add_security_key_data(post, options, money)
|
105
|
+
add_credit_card(post, credit_card)
|
106
|
+
add_addresses(post, options)
|
107
|
+
add_customer_data(post, options)
|
108
|
+
add_invoice_data(post, options)
|
109
|
+
add_optional_data(post, options)
|
110
|
+
commit(trx_type, money, post)
|
111
|
+
end
|
112
|
+
|
113
|
+
def capture_void_or_refund_template(trx_type, money, authorization, options)
|
114
|
+
post = VerifiPostData.new
|
115
|
+
post[:transactionid] = authorization
|
116
|
+
|
117
|
+
commit(trx_type, money, post)
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_credit_card(post, credit_card)
|
121
|
+
post[:ccnumber] = credit_card.number
|
122
|
+
post[:ccexp] = expdate(credit_card)
|
123
|
+
post[:firstname] = credit_card.first_name
|
124
|
+
post[:lastname] = credit_card.last_name
|
125
|
+
post[:cvv] = credit_card.verification_value
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_addresses(post, options)
|
129
|
+
if billing_address = options[:billing_address] || options[:address]
|
130
|
+
post[:company] = billing_address[:company]
|
131
|
+
post[:address1] = billing_address[:address1]
|
132
|
+
post[:address2] = billing_address[:address2]
|
133
|
+
post[:city] = billing_address[:city]
|
134
|
+
post[:state] = billing_address[:state]
|
135
|
+
post[:zip] = billing_address[:zip]
|
136
|
+
post[:country] = billing_address[:country]
|
137
|
+
post[:phone] = billing_address[:phone]
|
138
|
+
post[:fax] = billing_address[:fax]
|
139
|
+
end
|
140
|
+
|
141
|
+
if shipping_address = options[:shipping_address]
|
142
|
+
post[:shipping_firstname] = shipping_address[:first_name]
|
143
|
+
post[:shipping_lastname] = shipping_address[:last_name]
|
144
|
+
post[:shipping_company] = shipping_address[:company]
|
145
|
+
post[:shipping_address1] = shipping_address[:address1]
|
146
|
+
post[:shipping_address2] = shipping_address[:address2]
|
147
|
+
post[:shipping_city] = shipping_address[:city]
|
148
|
+
post[:shipping_state] = shipping_address[:state]
|
149
|
+
post[:shipping_zip] = shipping_address[:zip]
|
150
|
+
post[:shipping_country] = shipping_address[:country]
|
151
|
+
post[:shipping_email] = shipping_address[:email]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def add_customer_data(post, options)
|
156
|
+
post[:email] = options[:email]
|
157
|
+
post[:ipaddress] = options[:ip]
|
158
|
+
end
|
159
|
+
|
160
|
+
def add_invoice_data(post, options)
|
161
|
+
post[:orderid] = options[:order_id]
|
162
|
+
post[:ponumber] = options[:invoice]
|
163
|
+
post[:orderdescription] = options[:description]
|
164
|
+
post[:tax] = options[:tax]
|
165
|
+
post[:shipping] = options[:shipping]
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_optional_data(post, options)
|
169
|
+
post[:billing_method] = options[:billing_method]
|
170
|
+
post[:website] = options[:website]
|
171
|
+
post[:descriptor] = options[:descriptor]
|
172
|
+
post[:descriptor_phone] = options[:descriptor_phone]
|
173
|
+
post[:cardholder_auth] = options[:cardholder_auth]
|
174
|
+
post[:cavv] = options[:cavv]
|
175
|
+
post[:xid] = options[:xid]
|
176
|
+
post[:customer_receipt] = options[:customer_receipt]
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_security_key_data(post, options, money)
|
180
|
+
# MD5(username|password|orderid|amount|time)
|
181
|
+
now = Time.now.to_i.to_s
|
182
|
+
md5 = Digest::MD5.new
|
183
|
+
md5 << @options[:login].to_s + '|'
|
184
|
+
md5 << @options[:password].to_s + '|'
|
185
|
+
md5 << options[:order_id].to_s + '|'
|
186
|
+
md5 << amount(money).to_s + '|'
|
187
|
+
md5 << now
|
188
|
+
post[:key] = md5.hexdigest
|
189
|
+
post[:time] = now
|
190
|
+
end
|
191
|
+
|
192
|
+
def commit(trx_type, money, post)
|
193
|
+
post[:amount] = amount(money)
|
194
|
+
|
195
|
+
response = parse(ssl_post(self.live_url, post_data(trx_type, post)))
|
196
|
+
|
197
|
+
Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
|
198
|
+
test: test?,
|
199
|
+
authorization: response[:transactionid],
|
200
|
+
avs_result: { code: response[:avsresponse] },
|
201
|
+
cvv_result: response[:cvvresponse])
|
202
|
+
end
|
203
|
+
|
204
|
+
def message_from(response)
|
205
|
+
response[:response_code_message] || ''
|
206
|
+
end
|
207
|
+
|
208
|
+
def parse(body)
|
209
|
+
results = {}
|
210
|
+
CGI.parse(body).each { |key, value| results[key.intern] = value[0] }
|
211
|
+
results[:response_code_message] = RESPONSE_CODE_MESSAGES[results[:response_code]] if results[:response_code]
|
212
|
+
results
|
213
|
+
end
|
214
|
+
|
215
|
+
def post_data(trx_type, post)
|
216
|
+
post[:username] = @options[:login]
|
217
|
+
post[:password] = @options[:password]
|
218
|
+
post[:type] = TRANSACTIONS[trx_type]
|
219
|
+
|
220
|
+
post.to_s
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class ViaklixGateway < Gateway
|
4
|
+
class_attribute :test_url, :live_url, :delimiter, :actions
|
5
|
+
|
6
|
+
self.test_url = 'https://demo.viaklix.com/process.asp'
|
7
|
+
self.live_url = 'https://www.viaklix.com/process.asp'
|
8
|
+
self.delimiter = "\r\n"
|
9
|
+
|
10
|
+
self.actions = {
|
11
|
+
purchase: 'SALE',
|
12
|
+
credit: 'CREDIT'
|
13
|
+
}
|
14
|
+
|
15
|
+
APPROVED = '0'
|
16
|
+
|
17
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
18
|
+
self.supported_countries = ['US']
|
19
|
+
self.display_name = 'ViaKLIX'
|
20
|
+
self.homepage_url = 'http://viaklix.com'
|
21
|
+
|
22
|
+
# Initialize the Gateway
|
23
|
+
#
|
24
|
+
# The gateway requires that a valid login and password be passed
|
25
|
+
# in the +options+ hash.
|
26
|
+
#
|
27
|
+
# ==== Options
|
28
|
+
#
|
29
|
+
# * <tt>:login</tt> -- Merchant ID
|
30
|
+
# * <tt>:password</tt> -- PIN
|
31
|
+
# * <tt>:user</tt> -- Specify a subuser of the account (optional)
|
32
|
+
# * <tt>:test => +true+ or +false+</tt> -- Force test transactions
|
33
|
+
def initialize(options = {})
|
34
|
+
requires!(options, :login, :password)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
# Make a purchase
|
39
|
+
def purchase(money, creditcard, options = {})
|
40
|
+
form = {}
|
41
|
+
add_invoice(form, options)
|
42
|
+
add_creditcard(form, creditcard)
|
43
|
+
add_address(form, options)
|
44
|
+
add_customer_data(form, options)
|
45
|
+
add_test_mode(form, options)
|
46
|
+
commit(:purchase, money, form)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Make a credit to a card (Void can only be done from the virtual terminal)
|
50
|
+
# Viaklix does not support credits by reference. You must pass in the credit card
|
51
|
+
def credit(money, creditcard, options = {})
|
52
|
+
raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card' if creditcard.is_a?(String)
|
53
|
+
|
54
|
+
form = {}
|
55
|
+
add_invoice(form, options)
|
56
|
+
add_creditcard(form, creditcard)
|
57
|
+
add_address(form, options)
|
58
|
+
add_customer_data(form, options)
|
59
|
+
add_test_mode(form, options)
|
60
|
+
commit(:credit, money, form)
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def add_test_mode(form, options)
|
66
|
+
form[:test_mode] = 'TRUE' if options[:test_mode]
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_customer_data(form, options)
|
70
|
+
form[:email] = options[:email].to_s.slice(0, 100) unless options[:email].blank?
|
71
|
+
form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_invoice(form, options)
|
75
|
+
form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
|
76
|
+
form[:description] = options[:description].to_s.slice(0, 255)
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_address(form, options)
|
80
|
+
billing_address = options[:billing_address] || options[:address]
|
81
|
+
|
82
|
+
if billing_address
|
83
|
+
form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
|
84
|
+
form[:address2] = billing_address[:address2].to_s.slice(0, 30)
|
85
|
+
form[:avs_zip] = billing_address[:zip].to_s.slice(0, 10)
|
86
|
+
form[:city] = billing_address[:city].to_s.slice(0, 30)
|
87
|
+
form[:state] = billing_address[:state].to_s.slice(0, 10)
|
88
|
+
form[:company] = billing_address[:company].to_s.slice(0, 50)
|
89
|
+
form[:phone] = billing_address[:phone].to_s.slice(0, 20)
|
90
|
+
form[:country] = billing_address[:country].to_s.slice(0, 50)
|
91
|
+
end
|
92
|
+
|
93
|
+
if shipping_address = options[:shipping_address]
|
94
|
+
first_name, last_name = split_names(shipping_address[:name])
|
95
|
+
form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
|
96
|
+
form[:ship_to_last_name] = last_name.to_s.slice(0, 30)
|
97
|
+
form[:ship_to_address] = shipping_address[:address1].to_s.slice(0, 30)
|
98
|
+
form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30)
|
99
|
+
form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10)
|
100
|
+
form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50)
|
101
|
+
form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50)
|
102
|
+
form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_creditcard(form, creditcard)
|
107
|
+
form[:card_number] = creditcard.number
|
108
|
+
form[:exp_date] = expdate(creditcard)
|
109
|
+
|
110
|
+
add_verification_value(form, creditcard) if creditcard.verification_value?
|
111
|
+
|
112
|
+
form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
|
113
|
+
form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_verification_value(form, creditcard)
|
117
|
+
form[:cvv2cvc2] = creditcard.verification_value
|
118
|
+
form[:cvv2] = 'present'
|
119
|
+
end
|
120
|
+
|
121
|
+
def preamble
|
122
|
+
result = {
|
123
|
+
'merchant_id' => @options[:login],
|
124
|
+
'pin' => @options[:password],
|
125
|
+
'show_form' => 'false',
|
126
|
+
'result_format' => 'ASCII'
|
127
|
+
}
|
128
|
+
|
129
|
+
result['user_id'] = @options[:user] unless @options[:user].blank?
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
133
|
+
def commit(action, money, parameters)
|
134
|
+
parameters[:amount] = amount(money)
|
135
|
+
parameters[:transaction_type] = self.actions[action]
|
136
|
+
|
137
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)))
|
138
|
+
|
139
|
+
Response.new(response['result'] == APPROVED, message_from(response), response,
|
140
|
+
test: @options[:test] || test?,
|
141
|
+
authorization: authorization_from(response),
|
142
|
+
avs_result: { code: response['avs_response'] },
|
143
|
+
cvv_result: response['cvv2_response'])
|
144
|
+
end
|
145
|
+
|
146
|
+
def authorization_from(response)
|
147
|
+
response['txn_id']
|
148
|
+
end
|
149
|
+
|
150
|
+
def message_from(response)
|
151
|
+
response['result_message']
|
152
|
+
end
|
153
|
+
|
154
|
+
def post_data(parameters)
|
155
|
+
result = preamble
|
156
|
+
result.merge!(parameters)
|
157
|
+
result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
158
|
+
end
|
159
|
+
|
160
|
+
# Parse the response message
|
161
|
+
def parse(msg)
|
162
|
+
resp = {}
|
163
|
+
msg.split(self.delimiter).collect { |li|
|
164
|
+
key, value = li.split('=')
|
165
|
+
resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
|
166
|
+
}
|
167
|
+
resp
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class VisanetPeruGateway < Gateway
|
4
|
+
include Empty
|
5
|
+
self.display_name = 'VisaNet Peru Gateway'
|
6
|
+
self.homepage_url = 'http://www.visanet.com.pe'
|
7
|
+
|
8
|
+
self.test_url = 'https://devapi.vnforapps.com/api.tokenization/api/v2/merchant'
|
9
|
+
self.live_url = 'https://api.vnforapps.com/api.tokenization/api/v2/merchant'
|
10
|
+
|
11
|
+
self.supported_countries = %w[US PE]
|
12
|
+
self.default_currency = 'PEN'
|
13
|
+
self.money_format = :dollars
|
14
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
requires!(options, :access_key_id, :secret_access_key, :merchant_id)
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def purchase(amount, payment_method, options = {})
|
22
|
+
MultiResponse.run() do |r|
|
23
|
+
r.process { authorize(amount, payment_method, options) }
|
24
|
+
r.process { capture(amount, r.authorization, options) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(amount, payment_method, options = {})
|
29
|
+
params = {}
|
30
|
+
|
31
|
+
add_invoice(params, amount, options)
|
32
|
+
add_payment_method(params, payment_method)
|
33
|
+
add_antifraud_data(params, options)
|
34
|
+
params[:email] = options[:email] || 'unknown@email.com'
|
35
|
+
params[:createAlias] = false
|
36
|
+
|
37
|
+
commit('authorize', params, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def capture(amount, authorization, options = {})
|
41
|
+
params = {}
|
42
|
+
options[:id_unico] = split_authorization(authorization)[1]
|
43
|
+
add_auth_order_id(params, authorization, options)
|
44
|
+
commit('deposit', params, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def void(authorization, options = {})
|
48
|
+
params = {}
|
49
|
+
add_auth_order_id(params, authorization, options)
|
50
|
+
commit('void', params, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
def refund(amount, authorization, options = {})
|
54
|
+
params = {}
|
55
|
+
params[:amount] = amount(amount) if amount
|
56
|
+
add_auth_order_id(params, authorization, options)
|
57
|
+
response = commit('cancelDeposit', params, options)
|
58
|
+
return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled]
|
59
|
+
|
60
|
+
# Attempt RefundSingleTransaction if unsettled (and stash the original
|
61
|
+
# response message so it will be included it in the follow-up response
|
62
|
+
# message)
|
63
|
+
options[:error_message] = response.message
|
64
|
+
prepare_refund_data(params, authorization, options)
|
65
|
+
commit('refund', params, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def verify(credit_card, options = {})
|
69
|
+
MultiResponse.run(:use_first_response) do |r|
|
70
|
+
r.process { authorize(100, credit_card, options) }
|
71
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def supports_scrubbing?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
def scrub(transcript)
|
80
|
+
transcript.
|
81
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
82
|
+
gsub(%r((\"cardNumber\\\":\\\")\d+), '\1[FILTERED]').
|
83
|
+
gsub(%r((\"cvv2Code\\\":\\\")\d+), '\1[FILTERED]')
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
|
89
|
+
CURRENCY_CODES['USD'] = 840
|
90
|
+
CURRENCY_CODES['PEN'] = 604
|
91
|
+
|
92
|
+
def add_invoice(params, money, options)
|
93
|
+
# Visanet Peru expects a 12-digit alphanumeric purchaseNumber
|
94
|
+
params[:purchaseNumber] = generate_purchase_number_stamp
|
95
|
+
params[:externalTransactionId] = options[:order_id]
|
96
|
+
params[:amount] = amount(money)
|
97
|
+
params[:currencyId] = CURRENCY_CODES[options[:currency] || currency(money)]
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_auth_order_id(params, authorization, options)
|
101
|
+
purchase_number, = split_authorization(authorization)
|
102
|
+
params[:purchaseNumber] = purchase_number
|
103
|
+
params[:externalTransactionId] = options[:order_id]
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_payment_method(params, payment_method)
|
107
|
+
params[:firstName] = payment_method.first_name
|
108
|
+
params[:lastName] = payment_method.last_name
|
109
|
+
params[:cardNumber] = payment_method.number
|
110
|
+
params[:cvv2Code] = payment_method.verification_value
|
111
|
+
params[:expirationYear] = format(payment_method.year, :four_digits)
|
112
|
+
params[:expirationMonth] = format(payment_method.month, :two_digits)
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_antifraud_data(params, options)
|
116
|
+
antifraud = {}
|
117
|
+
|
118
|
+
if billing_address = options[:billing_address] || options[:address]
|
119
|
+
antifraud[:billTo_street1] = billing_address[:address1]
|
120
|
+
antifraud[:billTo_city] = billing_address[:city]
|
121
|
+
antifraud[:billTo_state] = billing_address[:state]
|
122
|
+
antifraud[:billTo_country] = billing_address[:country]
|
123
|
+
antifraud[:billTo_postalCode] = billing_address[:zip]
|
124
|
+
end
|
125
|
+
|
126
|
+
antifraud[:deviceFingerprintId] = options[:device_fingerprint_id] || SecureRandom.hex(16)
|
127
|
+
antifraud[:merchantDefineData] = options[:merchant_define_data] if options[:merchant_define_data]
|
128
|
+
|
129
|
+
params[:antifraud] = antifraud
|
130
|
+
end
|
131
|
+
|
132
|
+
def prepare_refund_data(params, authorization, options)
|
133
|
+
params.delete(:purchaseNumber)
|
134
|
+
params[:externalReferenceId] = params.delete(:externalTransactionId)
|
135
|
+
_, transaction_id = split_authorization(authorization)
|
136
|
+
|
137
|
+
options.update(transaction_id: transaction_id)
|
138
|
+
params[:ruc] = options[:ruc]
|
139
|
+
end
|
140
|
+
|
141
|
+
def split_authorization(authorization)
|
142
|
+
authorization.split('|')
|
143
|
+
end
|
144
|
+
|
145
|
+
def generate_purchase_number_stamp
|
146
|
+
Time.now.to_f.to_s.delete('.')[1..10] + rand(99).to_s
|
147
|
+
end
|
148
|
+
|
149
|
+
def commit(action, params, options = {})
|
150
|
+
raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
|
151
|
+
response = parse(raw_response)
|
152
|
+
rescue ResponseError => e
|
153
|
+
raw_response = e.response.body
|
154
|
+
response_error(raw_response, options, action)
|
155
|
+
rescue JSON::ParserError
|
156
|
+
unparsable_response(raw_response)
|
157
|
+
else
|
158
|
+
Response.new(
|
159
|
+
success_from(response),
|
160
|
+
message_from(response, options, action),
|
161
|
+
response,
|
162
|
+
test: test?,
|
163
|
+
authorization: authorization_from(params, response, options),
|
164
|
+
error_code: response['errorCode']
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
def headers
|
169
|
+
{
|
170
|
+
'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip,
|
171
|
+
'Content-Type' => 'application/json'
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
175
|
+
def url(action, params, options = {})
|
176
|
+
if action == 'authorize'
|
177
|
+
"#{base_url}/#{@options[:merchant_id]}"
|
178
|
+
elsif action == 'refund'
|
179
|
+
"#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}"
|
180
|
+
else
|
181
|
+
"#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def method(action)
|
186
|
+
%w(authorize refund).include?(action) ? :post : :put
|
187
|
+
end
|
188
|
+
|
189
|
+
def authorization_from(params, response, options)
|
190
|
+
id_unico = response['data']['ID_UNICO'] || options[:id_unico]
|
191
|
+
"#{params[:purchaseNumber]}|#{id_unico}"
|
192
|
+
end
|
193
|
+
|
194
|
+
def base_url
|
195
|
+
test? ? test_url : live_url
|
196
|
+
end
|
197
|
+
|
198
|
+
def parse(body)
|
199
|
+
JSON.parse(body)
|
200
|
+
end
|
201
|
+
|
202
|
+
def success_from(response)
|
203
|
+
response['errorCode'] == 0
|
204
|
+
end
|
205
|
+
|
206
|
+
def message_from(response, options, action)
|
207
|
+
message_from_messages(
|
208
|
+
response['errorMessage'],
|
209
|
+
action_code_description(response),
|
210
|
+
options[:error_message]
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
def message_from_messages(*args)
|
215
|
+
args.reject { |m| error_message_empty?(m) }.join(' | ')
|
216
|
+
end
|
217
|
+
|
218
|
+
def action_code_description(response)
|
219
|
+
return nil unless response['data']
|
220
|
+
|
221
|
+
response['data']['DSC_COD_ACCION']
|
222
|
+
end
|
223
|
+
|
224
|
+
def error_message_empty?(error_message)
|
225
|
+
empty?(error_message) || error_message == '[ ]'
|
226
|
+
end
|
227
|
+
|
228
|
+
def response_error(raw_response, options, action)
|
229
|
+
response = parse(raw_response)
|
230
|
+
rescue JSON::ParserError
|
231
|
+
unparsable_response(raw_response)
|
232
|
+
else
|
233
|
+
return Response.new(
|
234
|
+
false,
|
235
|
+
message_from(response, options, action),
|
236
|
+
response,
|
237
|
+
test: test?,
|
238
|
+
authorization: response['transactionUUID'],
|
239
|
+
error_code: response['errorCode']
|
240
|
+
)
|
241
|
+
end
|
242
|
+
|
243
|
+
def unparsable_response(raw_response)
|
244
|
+
message = 'Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message.'
|
245
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
246
|
+
return Response.new(false, message)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|