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,327 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardknoxGateway < Gateway
|
4
|
+
self.live_url = 'https://x1.cardknox.com/gateway'
|
5
|
+
|
6
|
+
self.supported_countries = %w[US CA GB]
|
7
|
+
self.default_currency = 'USD'
|
8
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
9
|
+
|
10
|
+
self.homepage_url = 'https://www.cardknox.com/'
|
11
|
+
self.display_name = 'Cardknox'
|
12
|
+
|
13
|
+
COMMANDS = {
|
14
|
+
credit_card: {
|
15
|
+
purchase: 'cc:sale',
|
16
|
+
authorization: 'cc:authonly',
|
17
|
+
capture: 'cc:capture',
|
18
|
+
refund: 'cc:refund',
|
19
|
+
void: 'cc:void',
|
20
|
+
save: 'cc:save'
|
21
|
+
},
|
22
|
+
check: {
|
23
|
+
purchase: 'check:sale',
|
24
|
+
refund: 'check:refund',
|
25
|
+
void: 'check:void',
|
26
|
+
save: 'check:save'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
def initialize(options = {})
|
31
|
+
requires!(options, :api_key)
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
# There are three sources for doing a purchase transation:
|
36
|
+
# - credit card
|
37
|
+
# - check
|
38
|
+
# - cardknox token, which is returned in the the authorization string "ref_num;token;command"
|
39
|
+
|
40
|
+
def purchase(amount, source, options = {})
|
41
|
+
post = {}
|
42
|
+
add_amount(post, amount, options)
|
43
|
+
add_invoice(post, options)
|
44
|
+
add_source(post, source)
|
45
|
+
add_address(post, source, options)
|
46
|
+
add_customer_data(post, options)
|
47
|
+
add_custom_fields(post, options)
|
48
|
+
commit(:purchase, source_type(source), post)
|
49
|
+
end
|
50
|
+
|
51
|
+
def authorize(amount, source, options = {})
|
52
|
+
post = {}
|
53
|
+
add_amount(post, amount)
|
54
|
+
add_invoice(post, options)
|
55
|
+
add_source(post, source)
|
56
|
+
add_address(post, source, options)
|
57
|
+
add_customer_data(post, options)
|
58
|
+
add_custom_fields(post, options)
|
59
|
+
commit(:authorization, source_type(source), post)
|
60
|
+
end
|
61
|
+
|
62
|
+
def capture(amount, authorization, options = {})
|
63
|
+
post = {}
|
64
|
+
add_reference(post, authorization)
|
65
|
+
add_amount(post, amount)
|
66
|
+
commit(:capture, source_type(authorization), post)
|
67
|
+
end
|
68
|
+
|
69
|
+
def refund(amount, authorization, options = {})
|
70
|
+
post = {}
|
71
|
+
add_reference(post, authorization)
|
72
|
+
add_amount(post, amount)
|
73
|
+
commit(:refund, source_type(authorization), post)
|
74
|
+
end
|
75
|
+
|
76
|
+
def void(authorization, options = {})
|
77
|
+
post = {}
|
78
|
+
add_reference(post, authorization)
|
79
|
+
commit(:void, source_type(authorization), post)
|
80
|
+
end
|
81
|
+
|
82
|
+
def verify(credit_card, options = {})
|
83
|
+
MultiResponse.run(:use_first_response) do |r|
|
84
|
+
r.process { authorize(100, credit_card, options) }
|
85
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def store(source, options = {})
|
90
|
+
post = {}
|
91
|
+
add_source(post, source)
|
92
|
+
add_address(post, source, options)
|
93
|
+
add_invoice(post, options)
|
94
|
+
add_customer_data(post, options)
|
95
|
+
add_custom_fields(post, options)
|
96
|
+
commit(:save, source_type(source), post)
|
97
|
+
end
|
98
|
+
|
99
|
+
def supports_scrubbing?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def scrub(transcript)
|
104
|
+
transcript.
|
105
|
+
gsub(%r((xCardNum=)\d+), '\1[FILTERED]').
|
106
|
+
gsub(%r((xCVV=)\d+), '\1[FILTERED]').
|
107
|
+
gsub(%r((xAccount=)\d+), '\1[FILTERED]').
|
108
|
+
gsub(%r((xRouting=)\d+), '\1[FILTERED]').
|
109
|
+
gsub(%r((xKey=)\w+), '\1[FILTERED]')
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def split_authorization(authorization)
|
115
|
+
authorization.split(';')
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_reference(post, reference)
|
119
|
+
reference, = split_authorization(reference)
|
120
|
+
post[:Refnum] = reference
|
121
|
+
end
|
122
|
+
|
123
|
+
def source_type(source)
|
124
|
+
if source.respond_to?(:brand)
|
125
|
+
:credit_card
|
126
|
+
elsif source.respond_to?(:routing_number)
|
127
|
+
:check
|
128
|
+
elsif source.kind_of?(String)
|
129
|
+
source_type_from(source)
|
130
|
+
else
|
131
|
+
raise ArgumentError, "Unknown source #{source.inspect}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def source_type_from(authorization)
|
136
|
+
_, _, source_type = split_authorization(authorization)
|
137
|
+
(source_type || 'credit_card').to_sym
|
138
|
+
end
|
139
|
+
|
140
|
+
def add_source(post, source)
|
141
|
+
if source.respond_to?(:brand)
|
142
|
+
add_credit_card(post, source)
|
143
|
+
elsif source.respond_to?(:routing_number)
|
144
|
+
add_check(post, source)
|
145
|
+
elsif source.kind_of?(String)
|
146
|
+
add_cardknox_token(post, source)
|
147
|
+
else
|
148
|
+
raise ArgumentError, "Invalid payment source #{source.inspect}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Subtotal + Tax + Tip = Amount.
|
153
|
+
|
154
|
+
def add_amount(post, money, options = {})
|
155
|
+
post[:Tip] = amount(options[:tip])
|
156
|
+
post[:Amount] = amount(money)
|
157
|
+
end
|
158
|
+
|
159
|
+
def expdate(credit_card)
|
160
|
+
year = format(credit_card.year, :two_digits)
|
161
|
+
month = format(credit_card.month, :two_digits)
|
162
|
+
"#{month}#{year}"
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_customer_data(post, options)
|
166
|
+
address = options[:billing_address] || {}
|
167
|
+
post[:Street] = address[:address1]
|
168
|
+
post[:Zip] = address[:zip]
|
169
|
+
post[:PONum] = options[:po_number]
|
170
|
+
post[:Fax] = options[:fax]
|
171
|
+
post[:Email] = options[:email]
|
172
|
+
post[:IP] = options[:ip]
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_address(post, source, options)
|
176
|
+
add_address_for_type(:billing, post, source, options[:billing_address]) if options[:billing_address]
|
177
|
+
add_address_for_type(:shipping, post, source, options[:shipping_address]) if options[:shipping_address]
|
178
|
+
end
|
179
|
+
|
180
|
+
def add_address_for_type(type, post, source, address)
|
181
|
+
prefix = address_key_prefix(type)
|
182
|
+
if source.respond_to?(:first_name)
|
183
|
+
post[address_key(prefix, 'FirstName')] = source.first_name
|
184
|
+
post[address_key(prefix, 'LastName')] = source.last_name
|
185
|
+
else
|
186
|
+
post[address_key(prefix, 'FirstName')] = address[:first_name]
|
187
|
+
post[address_key(prefix, 'LastName')] = address[:last_name]
|
188
|
+
end
|
189
|
+
post[address_key(prefix, 'MiddleName')] = address[:middle_name]
|
190
|
+
|
191
|
+
post[address_key(prefix, 'Company')] = address[:company]
|
192
|
+
post[address_key(prefix, 'Street')] = address[:address1]
|
193
|
+
post[address_key(prefix, 'Street2')] = address[:address2]
|
194
|
+
post[address_key(prefix, 'City')] = address[:city]
|
195
|
+
post[address_key(prefix, 'State')] = address[:state]
|
196
|
+
post[address_key(prefix, 'Zip')] = address[:zip]
|
197
|
+
post[address_key(prefix, 'Country')] = address[:country]
|
198
|
+
post[address_key(prefix, 'Phone')] = address[:phone]
|
199
|
+
post[address_key(prefix, 'Mobile')] = address[:mobile]
|
200
|
+
end
|
201
|
+
|
202
|
+
def address_key_prefix(type)
|
203
|
+
case type
|
204
|
+
when :shipping then 'Ship'
|
205
|
+
when :billing then 'Bill'
|
206
|
+
else
|
207
|
+
raise ArgumentError, "Unknown address key prefix: #{type}"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def address_key(prefix, key)
|
212
|
+
"#{prefix}#{key}".to_sym
|
213
|
+
end
|
214
|
+
|
215
|
+
def add_invoice(post, options)
|
216
|
+
post[:Invoice] = options[:invoice]
|
217
|
+
post[:OrderID] = options[:order_id]
|
218
|
+
post[:Comments] = options[:comments]
|
219
|
+
post[:Description] = options[:description]
|
220
|
+
post[:Tax] = amount(options[:tax])
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_custom_fields(post, options)
|
224
|
+
options.keys.grep(/^custom(?:[01]\d|20)$/) do |key|
|
225
|
+
post[key.to_s.capitalize] = options[key]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def add_credit_card(post, credit_card)
|
230
|
+
if credit_card.track_data.present?
|
231
|
+
post[:Magstripe] = credit_card.track_data
|
232
|
+
post[:Cardpresent] = true
|
233
|
+
else
|
234
|
+
post[:CardNum] = credit_card.number
|
235
|
+
post[:CVV] = credit_card.verification_value
|
236
|
+
post[:Exp] = expdate(credit_card)
|
237
|
+
post[:Name] = credit_card.name
|
238
|
+
post[:CardPresent] = true if credit_card.manual_entry
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def add_check(post, check)
|
243
|
+
post[:Routing] = check.routing_number
|
244
|
+
post[:Account] = check.account_number
|
245
|
+
post[:Name] = check.name
|
246
|
+
post[:CheckNum] = check.number
|
247
|
+
end
|
248
|
+
|
249
|
+
def add_cardknox_token(post, authorization)
|
250
|
+
_, token, = split_authorization(authorization)
|
251
|
+
|
252
|
+
post[:Token] = token
|
253
|
+
end
|
254
|
+
|
255
|
+
def parse(body)
|
256
|
+
fields = {}
|
257
|
+
for line in body.split('&')
|
258
|
+
key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
|
259
|
+
fields[key] = CGI.unescape(value.to_s)
|
260
|
+
end
|
261
|
+
|
262
|
+
{
|
263
|
+
result: fields['xResult'],
|
264
|
+
status: fields['xStatus'],
|
265
|
+
error: fields['xError'],
|
266
|
+
auth_code: fields['xAuthCode'],
|
267
|
+
ref_num: fields['xRefNum'],
|
268
|
+
current_ref_num: fields['xRefNumCurrent'],
|
269
|
+
token: fields['xToken'],
|
270
|
+
batch: fields['xBatch'],
|
271
|
+
avs_result: fields['xAvsResult'],
|
272
|
+
avs_result_code: fields['xAvsResultCode'],
|
273
|
+
cvv_result: fields['xCvvResult'],
|
274
|
+
cvv_result_code: fields['xCvvResultCode'],
|
275
|
+
remaining_balance: fields['xRemainingBalance'],
|
276
|
+
amount: fields['xAuthAmount'],
|
277
|
+
masked_card_num: fields['xMaskedCardNumber'],
|
278
|
+
masked_account_number: fields['MaskedAccountNumber']
|
279
|
+
}.delete_if { |_k, v| v.nil? }
|
280
|
+
end
|
281
|
+
|
282
|
+
def commit(action, source_type, parameters)
|
283
|
+
response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters)))
|
284
|
+
|
285
|
+
Response.new(
|
286
|
+
(response[:status] == 'Approved'),
|
287
|
+
message_from(response),
|
288
|
+
response,
|
289
|
+
authorization: authorization_from(response, source_type),
|
290
|
+
avs_result: { code: response[:avs_result_code] },
|
291
|
+
cvv_result: response[:cvv_result_code]
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
def message_from(response)
|
296
|
+
if response[:status] == 'Approved'
|
297
|
+
'Success'
|
298
|
+
elsif response[:error].blank?
|
299
|
+
'Unspecified error'
|
300
|
+
else
|
301
|
+
response[:error]
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def authorization_from(response, source_type)
|
306
|
+
"#{response[:ref_num]};#{response[:token]};#{source_type}"
|
307
|
+
end
|
308
|
+
|
309
|
+
def post_data(command, parameters = {})
|
310
|
+
initial_parameters = {
|
311
|
+
Key: @options[:api_key],
|
312
|
+
Version: '4.5.4',
|
313
|
+
SoftwareName: 'Active Merchant',
|
314
|
+
SoftwareVersion: ActiveMerchant::VERSION.to_s,
|
315
|
+
Command: command
|
316
|
+
}
|
317
|
+
|
318
|
+
seed = SecureRandom.hex(32).upcase
|
319
|
+
hash = Digest::SHA1.hexdigest("#{initial_parameters[:command]}:#{@options[:pin]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
|
320
|
+
initial_parameters[:Hash] = "s/#{seed}/#{hash}/n" unless @options[:pin].blank?
|
321
|
+
parameters = initial_parameters.merge(parameters)
|
322
|
+
|
323
|
+
parameters.reject { |_k, v| v.blank? }.collect { |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardprocessGateway < Gateway
|
4
|
+
self.test_url = 'https://test.vr-pay-ecommerce.de/v1/payments'
|
5
|
+
self.live_url = 'https://vr-pay-ecommerce.de/v1/payments'
|
6
|
+
|
7
|
+
self.supported_countries = %w[ BE BG CZ DK DE EE IE ES FR HR IT CY LV LT LU
|
8
|
+
MT HU NL AT PL PT RO SI SK FI SE GB IS LI NO
|
9
|
+
CH ME MK AL RS TR BA ]
|
10
|
+
self.default_currency = 'EUR'
|
11
|
+
self.supported_cardtypes = %i[visa master american_express diners_club jcb]
|
12
|
+
|
13
|
+
self.homepage_url = 'https://vr-pay-ecommerce.docs.oppwa.com/'
|
14
|
+
self.display_name = 'CardProcess VR-Pay'
|
15
|
+
self.money_format = :dollars
|
16
|
+
|
17
|
+
STANDARD_ERROR_CODE_MAPPING = {}
|
18
|
+
|
19
|
+
# Creates a new CardProcess Gateway
|
20
|
+
#
|
21
|
+
# The gateway requires a valid login, password, and entity ID
|
22
|
+
# to be passed in the +options+ hash.
|
23
|
+
#
|
24
|
+
# === Options
|
25
|
+
#
|
26
|
+
# * <tt>:user_id</tt> -- The CardProcess user ID
|
27
|
+
# * <tt>:password</tt> -- The CardProcess password
|
28
|
+
# * <tt>:entity_id</tt> -- The CardProcess channel or entity ID for any transactions
|
29
|
+
def initialize(options = {})
|
30
|
+
requires!(options, :user_id, :password, :entity_id)
|
31
|
+
super
|
32
|
+
# This variable exists purely to allow remote tests to force error codes;
|
33
|
+
# the lack of a setter despite its usage is intentional.
|
34
|
+
@test_options = {}
|
35
|
+
end
|
36
|
+
|
37
|
+
def purchase(money, payment, options = {})
|
38
|
+
post = {}
|
39
|
+
add_invoice(post, money, options)
|
40
|
+
add_payment(post, payment)
|
41
|
+
add_address(post, payment, options)
|
42
|
+
add_customer_data(post, options)
|
43
|
+
|
44
|
+
commit('DB', post)
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorize(money, payment, options = {})
|
48
|
+
post = {}
|
49
|
+
add_invoice(post, money, options)
|
50
|
+
add_payment(post, payment)
|
51
|
+
add_address(post, payment, options)
|
52
|
+
add_customer_data(post, options)
|
53
|
+
|
54
|
+
commit('PA', post)
|
55
|
+
end
|
56
|
+
|
57
|
+
def capture(money, authorization, options = {})
|
58
|
+
post = {
|
59
|
+
id: authorization
|
60
|
+
}
|
61
|
+
add_invoice(post, money, options)
|
62
|
+
commit('CP', post)
|
63
|
+
end
|
64
|
+
|
65
|
+
def refund(money, authorization, options = {})
|
66
|
+
post = {
|
67
|
+
id: authorization
|
68
|
+
}
|
69
|
+
add_invoice(post, money, options)
|
70
|
+
commit('RF', post)
|
71
|
+
end
|
72
|
+
|
73
|
+
def credit(money, payment, options = {})
|
74
|
+
post = {}
|
75
|
+
add_invoice(post, money, options)
|
76
|
+
add_payment(post, payment)
|
77
|
+
add_address(post, payment, options)
|
78
|
+
add_customer_data(post, options)
|
79
|
+
|
80
|
+
commit('CD', post)
|
81
|
+
end
|
82
|
+
|
83
|
+
def void(authorization, _options = {})
|
84
|
+
post = {
|
85
|
+
id: authorization
|
86
|
+
}
|
87
|
+
commit('RV', post)
|
88
|
+
end
|
89
|
+
|
90
|
+
def verify(credit_card, options = {})
|
91
|
+
MultiResponse.run do |r|
|
92
|
+
r.process { authorize(100, credit_card, options) }
|
93
|
+
r.process { void(r.authorization, options) }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def supports_scrubbing?
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
def scrub(transcript)
|
102
|
+
transcript.
|
103
|
+
gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]').
|
104
|
+
gsub(%r{(card\.number=)\d+}, '\1[FILTERED]').
|
105
|
+
gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2')
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def add_customer_data(post, options)
|
111
|
+
post['customer.ip'] = options[:ip] if options[:ip]
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_address(post, _card, options)
|
115
|
+
if (address = options[:billing_address] || options[:address])
|
116
|
+
post[:billing] = hashify_address(address)
|
117
|
+
end
|
118
|
+
|
119
|
+
if (shipping = options[:shipping_address])
|
120
|
+
post[:shipping] = hashify_address(shipping)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_invoice(post, money, options)
|
125
|
+
return if money.nil?
|
126
|
+
|
127
|
+
post[:amount] = amount(money)
|
128
|
+
post[:currency] = (options[:currency] || currency(money))
|
129
|
+
post[:merchantInvoiceId] = options[:merchant_invoice_id] if options[:merchant_invoice_id]
|
130
|
+
post[:merchantTransactionId] = options[:merchant_transaction_id] if options[:merchant_transaction_id]
|
131
|
+
post[:transactionCategory] = options[:transaction_category] if options[:transaction_category]
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_payment(post, payment)
|
135
|
+
return if payment.is_a?(String)
|
136
|
+
|
137
|
+
post[:paymentBrand] = payment.brand.upcase if payment.brand
|
138
|
+
post[:card] ||= {}
|
139
|
+
post[:card][:number] = payment.number
|
140
|
+
post[:card][:holder] = payment.name
|
141
|
+
post[:card][:expiryMonth] = sprintf('%02d', payment.month)
|
142
|
+
post[:card][:expiryYear] = sprintf('%02d', payment.year)
|
143
|
+
post[:card][:cvv] = payment.verification_value
|
144
|
+
end
|
145
|
+
|
146
|
+
def parse(body)
|
147
|
+
JSON.parse(body)
|
148
|
+
end
|
149
|
+
|
150
|
+
def commit(action, parameters)
|
151
|
+
url = (test? ? test_url : live_url)
|
152
|
+
if (id = parameters.delete(:id))
|
153
|
+
url += "/#{id}"
|
154
|
+
end
|
155
|
+
|
156
|
+
begin
|
157
|
+
raw_response = ssl_post(url, post_data(action, parameters.merge(@test_options)))
|
158
|
+
rescue ResponseError => e
|
159
|
+
raw_response = e.response.body
|
160
|
+
end
|
161
|
+
response = parse(raw_response)
|
162
|
+
|
163
|
+
Response.new(
|
164
|
+
success_from(response),
|
165
|
+
message_from(response),
|
166
|
+
response,
|
167
|
+
authorization: authorization_from(response),
|
168
|
+
avs_result: AVSResult.new(code: response['result']['avsResponse']),
|
169
|
+
cvv_result: CVVResult.new(response['result']['cvvResponse']),
|
170
|
+
test: test?,
|
171
|
+
error_code: error_code_from(response)
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
175
|
+
def success_from(response)
|
176
|
+
!(response['result']['code'] =~ /^(000\.000\.|000\.100\.1|000\.[36])/).nil?
|
177
|
+
end
|
178
|
+
|
179
|
+
def message_from(response)
|
180
|
+
response['result']['description']
|
181
|
+
end
|
182
|
+
|
183
|
+
def authorization_from(response)
|
184
|
+
response['id']
|
185
|
+
end
|
186
|
+
|
187
|
+
def post_data(action, parameters = {})
|
188
|
+
post = parameters.clone
|
189
|
+
post[:authentication] ||= {}
|
190
|
+
post[:authentication][:userId] = @options[:user_id]
|
191
|
+
post[:authentication][:password] = @options[:password]
|
192
|
+
post[:authentication][:entityId] = @options[:entity_id]
|
193
|
+
post[:paymentType] = action
|
194
|
+
dot_flatten_hash(post).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
195
|
+
end
|
196
|
+
|
197
|
+
def error_code_from(response)
|
198
|
+
unless success_from(response)
|
199
|
+
case response['result']['code']
|
200
|
+
when '100.100.101'
|
201
|
+
STANDARD_ERROR_CODE[:incorrect_number]
|
202
|
+
when '100.100.303'
|
203
|
+
STANDARD_ERROR_CODE[:expired_card]
|
204
|
+
when /100\.100\.(201|301|305)/
|
205
|
+
STANDARD_ERROR_CODE[:invalid_expiry_date]
|
206
|
+
when /100.100.60[01]/
|
207
|
+
STANDARD_ERROR_CODE[:invalid_cvc]
|
208
|
+
when '800.100.151'
|
209
|
+
STANDARD_ERROR_CODE[:invalid_number]
|
210
|
+
when '800.100.153'
|
211
|
+
STANDARD_ERROR_CODE[:incorrect_cvc]
|
212
|
+
when /800.800.(102|302)/
|
213
|
+
STANDARD_ERROR_CODE[:incorrect_address]
|
214
|
+
when '800.800.202'
|
215
|
+
STANDARD_ERROR_CODE[:invalid_zip]
|
216
|
+
when '800.100.166'
|
217
|
+
STANDARD_ERROR_CODE[:incorrect_pin]
|
218
|
+
when '800.100.171'
|
219
|
+
STANDARD_ERROR_CODE[:pickup_card]
|
220
|
+
when /^(200|700)\./
|
221
|
+
STANDARD_ERROR_CODE[:config_error]
|
222
|
+
when /^(800\.[17]00|800\.800\.[123])/
|
223
|
+
STANDARD_ERROR_CODE[:card_declined]
|
224
|
+
when /^(900\.[1234]00)/
|
225
|
+
STANDARD_ERROR_CODE[:processing_error]
|
226
|
+
else
|
227
|
+
STANDARD_ERROR_CODE[:processing_error]
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def hashify_address(address)
|
233
|
+
hash = {}
|
234
|
+
hash[:street1] = address[:address1] if address[:address1]
|
235
|
+
hash[:street2] = address[:address2] if address[:address2]
|
236
|
+
hash[:city] = address[:city] if address[:city]
|
237
|
+
hash[:state] = address[:state] if address[:state]
|
238
|
+
hash[:postcode] = address[:zip] if address[:zip]
|
239
|
+
hash[:country] = address[:country] if address[:country]
|
240
|
+
hash
|
241
|
+
end
|
242
|
+
|
243
|
+
def dot_flatten_hash(hash, prefix = '')
|
244
|
+
h = {}
|
245
|
+
hash.each_pair do |k, v|
|
246
|
+
if v.is_a?(Hash)
|
247
|
+
h.merge!(dot_flatten_hash(v, prefix + k.to_s + '.'))
|
248
|
+
else
|
249
|
+
h[prefix + k.to_s] = v
|
250
|
+
end
|
251
|
+
end
|
252
|
+
h
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|