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,260 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'openssl'
|
3
|
+
require 'digest'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
module ActiveMerchant #:nodoc:
|
7
|
+
module Billing #:nodoc:
|
8
|
+
class MitGateway < Gateway
|
9
|
+
self.live_url = 'https://wpy.mitec.com.mx/ModuloUtilWS/activeCDP.htm'
|
10
|
+
|
11
|
+
self.supported_countries = ['MX']
|
12
|
+
self.default_currency = 'MXN'
|
13
|
+
self.supported_cardtypes = %i[visa master]
|
14
|
+
|
15
|
+
self.homepage_url = 'http://www.centrodepagos.com.mx/'
|
16
|
+
self.display_name = 'MIT Centro de pagos'
|
17
|
+
|
18
|
+
self.money_format = :dollars
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
requires!(options, :commerce_id, :user, :api_key, :key_session)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def purchase(money, payment, options = {})
|
26
|
+
MultiResponse.run do |r|
|
27
|
+
r.process { authorize(money, payment, options) }
|
28
|
+
r.process { capture(money, r.authorization, options) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def cipher_key
|
33
|
+
@options[:key_session]
|
34
|
+
end
|
35
|
+
|
36
|
+
def decrypt(val, keyinhex)
|
37
|
+
# Splits the first 16 bytes (the IV bytes) in array format
|
38
|
+
unpacked = val.unpack('m')
|
39
|
+
iv_base64 = unpacked[0].bytes.slice(0, 16)
|
40
|
+
# Splits the second bytes (the encrypted text bytes) these would be the
|
41
|
+
# original message
|
42
|
+
full_data = unpacked[0].bytes.slice(16, unpacked[0].bytes.length)
|
43
|
+
# Creates the engine
|
44
|
+
engine = OpenSSL::Cipher::AES128.new(:CBC)
|
45
|
+
# Set engine as decrypt mode
|
46
|
+
engine.decrypt
|
47
|
+
# Converts the key from hex to bytes
|
48
|
+
engine.key = [keyinhex].pack('H*')
|
49
|
+
# Converts the ivBase64 array into bytes
|
50
|
+
engine.iv = iv_base64.pack('c*')
|
51
|
+
# Decrypts the texts and returns the original string
|
52
|
+
engine.update(full_data.pack('c*')) + engine.final
|
53
|
+
end
|
54
|
+
|
55
|
+
def encrypt(val, keyinhex)
|
56
|
+
# Creates the engine motor
|
57
|
+
engine = OpenSSL::Cipher::AES128.new(:CBC)
|
58
|
+
# Set engine as encrypt mode
|
59
|
+
engine.encrypt
|
60
|
+
# Converts the key from hex to bytes
|
61
|
+
engine.key = [keyinhex].pack('H*')
|
62
|
+
# Generates a random iv with this settings
|
63
|
+
iv_rand = engine.random_iv
|
64
|
+
# Packs IV as a Base64 string
|
65
|
+
iv_base64 = [iv_rand].pack('m')
|
66
|
+
# Converts the packed key into bytes
|
67
|
+
unpacked = iv_base64.unpack('m')
|
68
|
+
iv = unpacked[0]
|
69
|
+
# Sets the IV into the engine
|
70
|
+
engine.iv = iv
|
71
|
+
# Encrypts the texts and stores the bytes
|
72
|
+
encrypted_bytes = engine.update(val) + engine.final
|
73
|
+
# Concatenates the (a) IV bytes and (b) the encrypted bytes then returns a
|
74
|
+
# base64 representation
|
75
|
+
[iv << encrypted_bytes].pack('m')
|
76
|
+
end
|
77
|
+
|
78
|
+
def authorize(money, payment, options = {})
|
79
|
+
post = {
|
80
|
+
operation: 'Authorize',
|
81
|
+
commerce_id: @options[:commerce_id],
|
82
|
+
user: @options[:user],
|
83
|
+
apikey: @options[:api_key],
|
84
|
+
testMode: (test? ? 'YES' : 'NO')
|
85
|
+
}
|
86
|
+
add_invoice(post, money, options)
|
87
|
+
# Payments contains the card information
|
88
|
+
add_payment(post, payment)
|
89
|
+
add_customer_data(post, options)
|
90
|
+
post[:key_session] = @options[:key_session]
|
91
|
+
|
92
|
+
post_to_json = post.to_json
|
93
|
+
post_to_json_encrypt = encrypt(post_to_json, @options[:key_session])
|
94
|
+
|
95
|
+
final_post = '<authorization>' + post_to_json_encrypt + '</authorization><dataID>' + @options[:user] + '</dataID>'
|
96
|
+
json_post = {}
|
97
|
+
json_post[:payload] = final_post
|
98
|
+
commit('sale', json_post)
|
99
|
+
end
|
100
|
+
|
101
|
+
def capture(money, authorization, options = {})
|
102
|
+
post = {
|
103
|
+
operation: 'Capture',
|
104
|
+
commerce_id: @options[:commerce_id],
|
105
|
+
user: @options[:user],
|
106
|
+
apikey: @options[:api_key],
|
107
|
+
testMode: (test? ? 'YES' : 'NO'),
|
108
|
+
transaction_id: authorization,
|
109
|
+
amount: amount(money)
|
110
|
+
}
|
111
|
+
post[:key_session] = @options[:key_session]
|
112
|
+
|
113
|
+
post_to_json = post.to_json
|
114
|
+
post_to_json_encrypt = encrypt(post_to_json, @options[:key_session])
|
115
|
+
|
116
|
+
final_post = '<capture>' + post_to_json_encrypt + '</capture><dataID>' + @options[:user] + '</dataID>'
|
117
|
+
json_post = {}
|
118
|
+
json_post[:payload] = final_post
|
119
|
+
commit('capture', json_post)
|
120
|
+
end
|
121
|
+
|
122
|
+
def refund(money, authorization, options = {})
|
123
|
+
post = {
|
124
|
+
operation: 'Refund',
|
125
|
+
commerce_id: @options[:commerce_id],
|
126
|
+
user: @options[:user],
|
127
|
+
apikey: @options[:api_key],
|
128
|
+
testMode: (test? ? 'YES' : 'NO'),
|
129
|
+
transaction_id: authorization,
|
130
|
+
auth: authorization,
|
131
|
+
amount: amount(money)
|
132
|
+
}
|
133
|
+
post[:key_session] = @options[:key_session]
|
134
|
+
|
135
|
+
post_to_json = post.to_json
|
136
|
+
post_to_json_encrypt = encrypt(post_to_json, @options[:key_session])
|
137
|
+
|
138
|
+
final_post = '<refund>' + post_to_json_encrypt + '</refund><dataID>' + @options[:user] + '</dataID>'
|
139
|
+
json_post = {}
|
140
|
+
json_post[:payload] = final_post
|
141
|
+
commit('refund', json_post)
|
142
|
+
end
|
143
|
+
|
144
|
+
def supports_scrubbing?
|
145
|
+
true
|
146
|
+
end
|
147
|
+
|
148
|
+
def scrub(transcript)
|
149
|
+
ret_transcript = transcript
|
150
|
+
auth_origin = ret_transcript[/<authorization>(.*?)<\/authorization>/, 1]
|
151
|
+
unless auth_origin.nil?
|
152
|
+
auth_decrypted = decrypt(auth_origin, @options[:key_session])
|
153
|
+
auth_json = JSON.parse(auth_decrypted)
|
154
|
+
auth_json['card'] = '[FILTERED]'
|
155
|
+
auth_json['cvv'] = '[FILTERED]'
|
156
|
+
auth_json['apikey'] = '[FILTERED]'
|
157
|
+
auth_json['key_session'] = '[FILTERED]'
|
158
|
+
auth_to_json = auth_json.to_json
|
159
|
+
auth_tagged = '<authorization>' + auth_to_json + '</authorization>'
|
160
|
+
ret_transcript = ret_transcript.gsub(/<authorization>(.*?)<\/authorization>/, auth_tagged)
|
161
|
+
end
|
162
|
+
|
163
|
+
cap_origin = ret_transcript[/<capture>(.*?)<\/capture>/, 1]
|
164
|
+
unless cap_origin.nil?
|
165
|
+
cap_decrypted = decrypt(cap_origin, @options[:key_session])
|
166
|
+
cap_json = JSON.parse(cap_decrypted)
|
167
|
+
cap_json['apikey'] = '[FILTERED]'
|
168
|
+
cap_json['key_session'] = '[FILTERED]'
|
169
|
+
cap_to_json = cap_json.to_json
|
170
|
+
cap_tagged = '<capture>' + cap_to_json + '</capture>'
|
171
|
+
ret_transcript = ret_transcript.gsub(/<capture>(.*?)<\/capture>/, cap_tagged)
|
172
|
+
end
|
173
|
+
|
174
|
+
ref_origin = ret_transcript[/<refund>(.*?)<\/refund>/, 1]
|
175
|
+
unless ref_origin.nil?
|
176
|
+
ref_decrypted = decrypt(ref_origin, @options[:key_session])
|
177
|
+
ref_json = JSON.parse(ref_decrypted)
|
178
|
+
ref_json['apikey'] = '[FILTERED]'
|
179
|
+
ref_json['key_session'] = '[FILTERED]'
|
180
|
+
ref_to_json = ref_json.to_json
|
181
|
+
ref_tagged = '<refund>' + ref_to_json + '</refund>'
|
182
|
+
ret_transcript = ret_transcript.gsub(/<refund>(.*?)<\/refund>/, ref_tagged)
|
183
|
+
end
|
184
|
+
|
185
|
+
res_origin = ret_transcript[/#{Regexp.escape('reading ')}(.*?)#{Regexp.escape('read')}/m, 1]
|
186
|
+
loop do
|
187
|
+
break if res_origin.nil?
|
188
|
+
|
189
|
+
resp_origin = res_origin[/#{Regexp.escape('"')}(.*?)#{Regexp.escape('"')}/m, 1]
|
190
|
+
resp_decrypted = decrypt(resp_origin, @options[:key_session])
|
191
|
+
ret_transcript[/#{Regexp.escape('reading ')}(.*?)#{Regexp.escape('read')}/m, 1] = resp_decrypted
|
192
|
+
ret_transcript = ret_transcript.sub('reading ', 'response: ')
|
193
|
+
res_origin = ret_transcript[/#{Regexp.escape('reading ')}(.*?)#{Regexp.escape('read')}/m, 1]
|
194
|
+
end
|
195
|
+
|
196
|
+
ret_transcript
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
def add_customer_data(post, options)
|
202
|
+
post[:email] = options[:email] || 'nadie@mit.test'
|
203
|
+
end
|
204
|
+
|
205
|
+
def add_invoice(post, money, options)
|
206
|
+
post[:amount] = amount(money)
|
207
|
+
post[:currency] = (options[:currency] || currency(money))
|
208
|
+
post[:reference] = options[:order_id]
|
209
|
+
post[:transaction_id] = options[:order_id]
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_payment(post, payment)
|
213
|
+
post[:installments] = 1
|
214
|
+
post[:card] = payment.number
|
215
|
+
post[:expmonth] = payment.month
|
216
|
+
post[:expyear] = payment.year
|
217
|
+
post[:cvv] = payment.verification_value
|
218
|
+
post[:name_client] = [payment.first_name, payment.last_name].join(' ')
|
219
|
+
end
|
220
|
+
|
221
|
+
def commit(action, parameters)
|
222
|
+
json_str = JSON.generate(parameters)
|
223
|
+
cleaned_str = json_str.gsub('\n', '')
|
224
|
+
raw_response = ssl_post(live_url, cleaned_str, { 'Content-type' => 'application/json' })
|
225
|
+
response = JSON.parse(decrypt(raw_response, @options[:key_session]))
|
226
|
+
|
227
|
+
Response.new(
|
228
|
+
success_from(response),
|
229
|
+
message_from(response),
|
230
|
+
response,
|
231
|
+
authorization: authorization_from(response),
|
232
|
+
avs_result: AVSResult.new(code: response['some_avs_response_key']),
|
233
|
+
cvv_result: CVVResult.new(response['some_cvv_response_key']),
|
234
|
+
test: test?,
|
235
|
+
error_code: error_code_from(response)
|
236
|
+
)
|
237
|
+
end
|
238
|
+
|
239
|
+
def success_from(response)
|
240
|
+
response['response'] == 'approved'
|
241
|
+
end
|
242
|
+
|
243
|
+
def message_from(response)
|
244
|
+
response['response']
|
245
|
+
end
|
246
|
+
|
247
|
+
def authorization_from(response)
|
248
|
+
response['reference']
|
249
|
+
end
|
250
|
+
|
251
|
+
def post_data(action, parameters = {})
|
252
|
+
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
253
|
+
end
|
254
|
+
|
255
|
+
def error_code_from(response)
|
256
|
+
response['message'].split(' -- ', 2)[0] unless success_from(response)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'active_merchant/billing/gateways/modern_payments_cim'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class ModernPaymentsGateway < Gateway
|
6
|
+
self.supported_countries = ModernPaymentsCimGateway.supported_countries
|
7
|
+
self.supported_cardtypes = ModernPaymentsCimGateway.supported_cardtypes
|
8
|
+
self.homepage_url = ModernPaymentsCimGateway.homepage_url
|
9
|
+
self.display_name = ModernPaymentsCimGateway.display_name
|
10
|
+
|
11
|
+
self.abstract_class = true
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
requires!(options, :login, :password)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def purchase(money, credit_card, options = {})
|
19
|
+
customer_response = cim.create_customer(options)
|
20
|
+
return customer_response unless customer_response.success?
|
21
|
+
|
22
|
+
customer_id = customer_response.params['create_customer_result']
|
23
|
+
|
24
|
+
card_response = cim.modify_customer_credit_card(customer_id, credit_card)
|
25
|
+
return card_response unless card_response.success?
|
26
|
+
|
27
|
+
cim.authorize_credit_card_payment(customer_id, money)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def cim
|
33
|
+
@cim ||= ModernPaymentsCimGateway.new(@options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class ModernPaymentsCimGateway < Gateway #:nodoc:
|
4
|
+
self.test_url = 'https://secure.modpay.com/netservices/test/ModpayTest.asmx'
|
5
|
+
self.live_url = 'https://secure.modpay.com/ws/modpay.asmx'
|
6
|
+
|
7
|
+
LIVE_XMLNS = 'https://secure.modpay.com/ws/'
|
8
|
+
TEST_XMLNS = 'https://secure.modpay.com/netservices/test/'
|
9
|
+
|
10
|
+
self.supported_countries = ['US']
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
12
|
+
self.homepage_url = 'http://www.modpay.com'
|
13
|
+
self.display_name = 'Modern Payments'
|
14
|
+
|
15
|
+
SUCCESS_MESSAGE = 'Transaction accepted'
|
16
|
+
FAILURE_MESSAGE = 'Transaction failed'
|
17
|
+
ERROR_MESSAGE = 'Transaction error'
|
18
|
+
|
19
|
+
PAYMENT_METHOD = {
|
20
|
+
check: 1,
|
21
|
+
credit_card: 2
|
22
|
+
}
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
requires!(options, :login, :password)
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_customer(options = {})
|
30
|
+
post = {}
|
31
|
+
add_customer_data(post, options)
|
32
|
+
add_address(post, options)
|
33
|
+
|
34
|
+
commit('CreateCustomer', post)
|
35
|
+
end
|
36
|
+
|
37
|
+
def modify_customer_credit_card(customer_id, credit_card)
|
38
|
+
raise ArgumentError, 'The customer_id cannot be blank' if customer_id.blank?
|
39
|
+
|
40
|
+
post = {}
|
41
|
+
add_customer_id(post, customer_id)
|
42
|
+
add_credit_card(post, credit_card)
|
43
|
+
|
44
|
+
commit('ModifyCustomerCreditCard', post)
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorize_credit_card_payment(customer_id, amount)
|
48
|
+
raise ArgumentError, 'The customer_id cannot be blank' if customer_id.blank?
|
49
|
+
|
50
|
+
post = {}
|
51
|
+
add_customer_id(post, customer_id)
|
52
|
+
add_amount(post, amount)
|
53
|
+
|
54
|
+
commit('AuthorizeCreditCardPayment', post)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_payment(customer_id, amount, options = {})
|
58
|
+
raise ArgumentError, 'The customer_id cannot be blank' if customer_id.blank?
|
59
|
+
|
60
|
+
post = {}
|
61
|
+
add_customer_id(post, customer_id)
|
62
|
+
add_amount(post, amount)
|
63
|
+
add_payment_details(post, options)
|
64
|
+
|
65
|
+
commit('CreatePayment', post)
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def add_payment_details(post, options)
|
71
|
+
post[:pmtDate] = (options[:payment_date] || Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
|
72
|
+
post[:pmtType] = PAYMENT_METHOD[options[:payment_method] || :credit_card]
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_amount(post, money)
|
76
|
+
post[:pmtAmount] = amount(money)
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_customer_id(post, customer_id)
|
80
|
+
post[:custId] = customer_id
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_customer_data(post, options)
|
84
|
+
post[:acctNum] = options[:customer]
|
85
|
+
end
|
86
|
+
|
87
|
+
def add_address(post, options)
|
88
|
+
address = options[:billing_address] || options[:address] || {}
|
89
|
+
|
90
|
+
if name = address[:name]
|
91
|
+
post[:firstName], post[:lastName] = split_names(name)
|
92
|
+
else
|
93
|
+
post[:firstName] = address[:first_name]
|
94
|
+
post[:lastName] = address[:last_name]
|
95
|
+
end
|
96
|
+
|
97
|
+
post[:address] = address[:address1]
|
98
|
+
post[:city] = address[:city]
|
99
|
+
post[:state] = address[:state]
|
100
|
+
post[:zip] = address[:zip]
|
101
|
+
post[:phone] = address[:phone]
|
102
|
+
post[:fax] = address[:fax]
|
103
|
+
post[:email] = options[:email]
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_credit_card(post, credit_card)
|
107
|
+
post[:ccName] = credit_card.name
|
108
|
+
post[:ccNum] = credit_card.number
|
109
|
+
post[:expMonth] = credit_card.month
|
110
|
+
post[:expYear] = credit_card.year
|
111
|
+
end
|
112
|
+
|
113
|
+
def build_request(action, params)
|
114
|
+
xml = Builder::XmlMarkup.new indent: 2
|
115
|
+
xml.instruct!
|
116
|
+
xml.tag! 'env:Envelope',
|
117
|
+
{ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
118
|
+
'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
|
119
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' } do
|
120
|
+
|
121
|
+
xml.tag! 'env:Body' do
|
122
|
+
xml.tag! action, { 'xmlns' => xmlns(action) } do
|
123
|
+
xml.tag! 'clientId', @options[:login]
|
124
|
+
xml.tag! 'clientCode', @options[:password]
|
125
|
+
params.each { |key, value| xml.tag! key, value }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
xml.target!
|
130
|
+
end
|
131
|
+
|
132
|
+
def xmlns(action)
|
133
|
+
if test? && action == 'AuthorizeCreditCardPayment'
|
134
|
+
TEST_XMLNS
|
135
|
+
else
|
136
|
+
LIVE_XMLNS
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def url(action)
|
141
|
+
if test? && action == 'AuthorizeCreditCardPayment'
|
142
|
+
self.test_url
|
143
|
+
else
|
144
|
+
self.live_url
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def commit(action, params)
|
149
|
+
data = ssl_post(url(action), build_request(action, params),
|
150
|
+
{ 'Content-Type' => 'text/xml; charset=utf-8',
|
151
|
+
'SOAPAction' => "#{xmlns(action)}#{action}" })
|
152
|
+
|
153
|
+
response = parse(action, data)
|
154
|
+
Response.new(successful?(action, response), message_from(action, response), response,
|
155
|
+
test: test?,
|
156
|
+
authorization: authorization_from(action, response),
|
157
|
+
avs_result: { code: response[:avs_code] })
|
158
|
+
end
|
159
|
+
|
160
|
+
def authorization_from(action, response)
|
161
|
+
response[authorization_key(action)]
|
162
|
+
end
|
163
|
+
|
164
|
+
def authorization_key(action)
|
165
|
+
action == 'AuthorizeCreditCardPayment' ? :trans_id : "#{action.underscore}_result".to_sym
|
166
|
+
end
|
167
|
+
|
168
|
+
def successful?(action, response)
|
169
|
+
key = authorization_key(action)
|
170
|
+
|
171
|
+
if key == :trans_id
|
172
|
+
response[:approved] == 'true'
|
173
|
+
else
|
174
|
+
response[key].to_i > 0
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def message_from(action, response)
|
179
|
+
if response[:faultcode]
|
180
|
+
ERROR_MESSAGE
|
181
|
+
elsif successful?(action, response)
|
182
|
+
SUCCESS_MESSAGE
|
183
|
+
else
|
184
|
+
FAILURE_MESSAGE
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def parse(action, xml)
|
189
|
+
response = {}
|
190
|
+
response[:action] = action
|
191
|
+
|
192
|
+
xml = REXML::Document.new(xml)
|
193
|
+
if root = REXML::XPath.first(xml, "//#{action}Response")
|
194
|
+
root.elements.to_a.each do |node|
|
195
|
+
parse_element(response, node)
|
196
|
+
end
|
197
|
+
elsif root = REXML::XPath.first(xml, '//soap:Fault')
|
198
|
+
root.elements.to_a.each do |node|
|
199
|
+
response[node.name.underscore.to_sym] = node.text
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
response
|
204
|
+
end
|
205
|
+
|
206
|
+
def parse_element(response, node)
|
207
|
+
if node.has_elements?
|
208
|
+
node.elements.each { |e| parse_element(response, e) }
|
209
|
+
else
|
210
|
+
response[node.name.underscore.to_sym] = node.text.to_s.strip
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|