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,451 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'date'
|
3
|
+
require 'active_merchant/billing/model'
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
# A +CreditCard+ object represents a physical credit card, and is capable of validating the various
|
8
|
+
# data associated with these.
|
9
|
+
#
|
10
|
+
# At the moment, the following credit card types are supported:
|
11
|
+
#
|
12
|
+
# * Visa
|
13
|
+
# * MasterCard
|
14
|
+
# * Discover
|
15
|
+
# * American Express
|
16
|
+
# * Diner's Club
|
17
|
+
# * JCB
|
18
|
+
# * Dankort
|
19
|
+
# * Maestro
|
20
|
+
# * Forbrugsforeningen
|
21
|
+
# * Sodexo
|
22
|
+
# * Vr
|
23
|
+
# * Carnet
|
24
|
+
# * Synchrony
|
25
|
+
# * Routex
|
26
|
+
# * Elo
|
27
|
+
# * Alelo
|
28
|
+
# * Cabal
|
29
|
+
# * Naranja
|
30
|
+
# * UnionPay
|
31
|
+
# * Alia
|
32
|
+
# * Olimpica
|
33
|
+
# * Creditel
|
34
|
+
# * Confiable
|
35
|
+
# * Mada
|
36
|
+
# * BpPlus
|
37
|
+
# * Passcard
|
38
|
+
# * Edenred
|
39
|
+
# * Anda
|
40
|
+
# * Creditos directos (Tarjeta D)
|
41
|
+
#
|
42
|
+
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
|
43
|
+
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
|
44
|
+
# with the details of particular credit cards or your gateway.
|
45
|
+
#
|
46
|
+
# == Testing With CreditCard
|
47
|
+
# Often when testing we don't care about the particulars of a given card brand. When using the 'test'
|
48
|
+
# mode in your {Gateway}, there are six different valid card numbers: 1, 2, 3, 'success', 'fail',
|
49
|
+
# and 'error'.
|
50
|
+
#
|
51
|
+
# For details, see {CreditCardMethods::ClassMethods#valid_number?}
|
52
|
+
#
|
53
|
+
# == Example Usage
|
54
|
+
# cc = CreditCard.new(
|
55
|
+
# :first_name => 'Steve',
|
56
|
+
# :last_name => 'Smith',
|
57
|
+
# :month => '9',
|
58
|
+
# :year => '2017',
|
59
|
+
# :brand => 'visa',
|
60
|
+
# :number => '4242424242424242',
|
61
|
+
# :verification_value => '424'
|
62
|
+
# )
|
63
|
+
#
|
64
|
+
# cc.validate # => {}
|
65
|
+
# cc.display_number # => XXXX-XXXX-XXXX-4242
|
66
|
+
#
|
67
|
+
class CreditCard < Model
|
68
|
+
include CreditCardMethods
|
69
|
+
|
70
|
+
BRANDS_WITH_SPACES_IN_NUMBER = %w(bp_plus)
|
71
|
+
|
72
|
+
class << self
|
73
|
+
# Inherited, but can be overridden w/o changing parent's value
|
74
|
+
attr_accessor :require_verification_value
|
75
|
+
attr_accessor :require_name
|
76
|
+
end
|
77
|
+
|
78
|
+
self.require_name = true
|
79
|
+
self.require_verification_value = true
|
80
|
+
|
81
|
+
# Returns or sets the credit card number.
|
82
|
+
#
|
83
|
+
# @return [String]
|
84
|
+
attr_reader :number
|
85
|
+
|
86
|
+
def number=(value)
|
87
|
+
@number = (empty?(value) ? value : filter_number(value))
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns or sets the expiry month for the card.
|
91
|
+
#
|
92
|
+
# @return [Integer]
|
93
|
+
attr_reader :month
|
94
|
+
|
95
|
+
# Returns or sets the expiry year for the card.
|
96
|
+
#
|
97
|
+
# @return [Integer]
|
98
|
+
attr_reader :year
|
99
|
+
|
100
|
+
# Returns or sets the credit card brand.
|
101
|
+
#
|
102
|
+
# Valid card types are
|
103
|
+
#
|
104
|
+
# * +'visa'+
|
105
|
+
# * +'master'+
|
106
|
+
# * +'discover'+
|
107
|
+
# * +'american_express'+
|
108
|
+
# * +'diners_club'+
|
109
|
+
# * +'jcb'+
|
110
|
+
# * +'dankort'+
|
111
|
+
# * +'maestro'+
|
112
|
+
# * +'forbrugsforeningen'+
|
113
|
+
# * +'sodexo'+
|
114
|
+
# * +'vr'+
|
115
|
+
# * +'carnet'+
|
116
|
+
# * +'synchrony'+
|
117
|
+
# * +'routex'+
|
118
|
+
# * +'elo'+
|
119
|
+
# * +'alelo'+
|
120
|
+
# * +'cabal'+
|
121
|
+
# * +'naranja'+
|
122
|
+
# * +'union_pay'+
|
123
|
+
# * +'alia'+
|
124
|
+
# * +'olimpica'+
|
125
|
+
# * +'creditel'+
|
126
|
+
# * +'confiable'+
|
127
|
+
# * +'mada'+
|
128
|
+
# * +'bp_plus'+
|
129
|
+
# * +'passcard'+
|
130
|
+
# * +'edenred'+
|
131
|
+
# * +'anda'+
|
132
|
+
# * +'tarjeta-d'+
|
133
|
+
#
|
134
|
+
# Or, if you wish to test your implementation, +'bogus'+.
|
135
|
+
#
|
136
|
+
# @return (String) the credit card brand
|
137
|
+
def brand
|
138
|
+
if !defined?(@brand) || empty?(@brand)
|
139
|
+
self.class.brand?(number)
|
140
|
+
else
|
141
|
+
@brand
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def brand=(value)
|
146
|
+
value = value && value.to_s.dup
|
147
|
+
@brand = (value.respond_to?(:downcase) ? value.downcase : value)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns or sets the first name of the card holder.
|
151
|
+
#
|
152
|
+
# @return [String]
|
153
|
+
attr_accessor :first_name
|
154
|
+
|
155
|
+
# Returns or sets the last name of the card holder.
|
156
|
+
#
|
157
|
+
# @return [String]
|
158
|
+
attr_accessor :last_name
|
159
|
+
|
160
|
+
# Returns or sets the card verification value.
|
161
|
+
#
|
162
|
+
# This attribute is optional but recommended. The verification value is
|
163
|
+
# a {card security code}[http://en.wikipedia.org/wiki/Card_security_code]. If provided,
|
164
|
+
# the gateway will attempt to validate the value.
|
165
|
+
#
|
166
|
+
# @return [String] the verification value
|
167
|
+
attr_accessor :verification_value
|
168
|
+
|
169
|
+
# Sets if the credit card requires a verification value.
|
170
|
+
#
|
171
|
+
# @return [Boolean]
|
172
|
+
def require_verification_value=(value)
|
173
|
+
@require_verification_value_set = true
|
174
|
+
@require_verification_value = value
|
175
|
+
end
|
176
|
+
|
177
|
+
# Returns if this credit card needs a verification value.
|
178
|
+
#
|
179
|
+
# By default this returns the configured value from `CreditCard.require_verification_value`,
|
180
|
+
# but one can set a per instance requirement with `credit_card.require_verification_value = false`.
|
181
|
+
#
|
182
|
+
# @return [Boolean]
|
183
|
+
def requires_verification_value?
|
184
|
+
@require_verification_value_set ||= false
|
185
|
+
if @require_verification_value_set
|
186
|
+
@require_verification_value
|
187
|
+
else
|
188
|
+
self.class.requires_verification_value?
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns or sets the track data for the card
|
193
|
+
#
|
194
|
+
# @return [String]
|
195
|
+
attr_accessor :track_data
|
196
|
+
|
197
|
+
# Returns or sets whether a card has been processed using manual entry.
|
198
|
+
#
|
199
|
+
# This attribute is optional and is only used by gateways who use this information in their transaction risk
|
200
|
+
# calculations. See {this page on 'card not present' transactions}[http://en.wikipedia.org/wiki/Card_not_present_transaction]
|
201
|
+
# for further explanation and examples of this kind of transaction.
|
202
|
+
#
|
203
|
+
# @return [true, false]
|
204
|
+
attr_accessor :manual_entry
|
205
|
+
|
206
|
+
# Returns or sets the ICC/ASN1 credit card data for a EMV transaction, typically this is a BER-encoded TLV string.
|
207
|
+
#
|
208
|
+
# @return [String]
|
209
|
+
attr_accessor :icc_data
|
210
|
+
|
211
|
+
# Returns or sets information about the source of the card data.
|
212
|
+
#
|
213
|
+
# @return [String]
|
214
|
+
attr_accessor :read_method
|
215
|
+
|
216
|
+
READ_METHOD_DESCRIPTIONS = {
|
217
|
+
nil => 'A card reader was not used.',
|
218
|
+
'fallback_no_chip' => 'Magstripe was read because the card has no chip.',
|
219
|
+
'fallback_chip_error' => "Magstripe was read because the card's chip failed.",
|
220
|
+
'contactless' => 'Data was read by a Contactless EMV kernel. Issuer script results are not available.',
|
221
|
+
'contactless_magstripe' => 'Contactless data was read with a non-EMV protocol.',
|
222
|
+
'contact' => 'Data was read using the EMV protocol. Issuer script results may follow.',
|
223
|
+
'contact_quickchip' => 'Data was read by the Quickchip EMV kernel. Issuer script results are not available.'
|
224
|
+
}
|
225
|
+
|
226
|
+
# Returns the ciphertext of the card's encrypted PIN.
|
227
|
+
#
|
228
|
+
# @return [String]
|
229
|
+
attr_accessor :encrypted_pin_cryptogram
|
230
|
+
|
231
|
+
# Returns the Key Serial Number (KSN) of the card's encrypted PIN.
|
232
|
+
#
|
233
|
+
# @return [String]
|
234
|
+
attr_accessor :encrypted_pin_ksn
|
235
|
+
|
236
|
+
def type
|
237
|
+
ActiveMerchant.deprecated 'CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.'
|
238
|
+
brand
|
239
|
+
end
|
240
|
+
|
241
|
+
def type=(value)
|
242
|
+
ActiveMerchant.deprecated 'CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.'
|
243
|
+
self.brand = value
|
244
|
+
end
|
245
|
+
|
246
|
+
# Provides proxy access to an expiry date object
|
247
|
+
#
|
248
|
+
# @return [ExpiryDate]
|
249
|
+
def expiry_date
|
250
|
+
ExpiryDate.new(@month, @year)
|
251
|
+
end
|
252
|
+
|
253
|
+
# Returns whether the credit card has expired.
|
254
|
+
#
|
255
|
+
# @return +true+ if the card has expired, +false+ otherwise
|
256
|
+
def expired?
|
257
|
+
expiry_date.expired?
|
258
|
+
end
|
259
|
+
|
260
|
+
# Returns whether either the +first_name+ or the +last_name+ attributes has been set.
|
261
|
+
def name?
|
262
|
+
first_name? || last_name?
|
263
|
+
end
|
264
|
+
|
265
|
+
# Returns whether the +first_name+ attribute has been set.
|
266
|
+
def first_name?
|
267
|
+
first_name.present?
|
268
|
+
end
|
269
|
+
|
270
|
+
# Returns whether the +last_name+ attribute has been set.
|
271
|
+
def last_name?
|
272
|
+
last_name.present?
|
273
|
+
end
|
274
|
+
|
275
|
+
# Returns the full name of the card holder.
|
276
|
+
#
|
277
|
+
# @return [String] the full name of the card holder
|
278
|
+
def name
|
279
|
+
"#{first_name} #{last_name}".strip
|
280
|
+
end
|
281
|
+
|
282
|
+
def name=(full_name)
|
283
|
+
names = full_name.split
|
284
|
+
self.last_name = names.pop
|
285
|
+
self.first_name = names.join(' ')
|
286
|
+
end
|
287
|
+
|
288
|
+
%w(month year start_month start_year).each do |m|
|
289
|
+
class_eval %(
|
290
|
+
def #{m}=(v)
|
291
|
+
@#{m} = case v
|
292
|
+
when "", nil, 0
|
293
|
+
nil
|
294
|
+
else
|
295
|
+
v.to_i
|
296
|
+
end
|
297
|
+
end
|
298
|
+
)
|
299
|
+
end
|
300
|
+
|
301
|
+
def verification_value?
|
302
|
+
!verification_value.blank?
|
303
|
+
end
|
304
|
+
|
305
|
+
# Returns a display-friendly version of the card number.
|
306
|
+
#
|
307
|
+
# All but the last 4 numbers are replaced with an "X", and hyphens are
|
308
|
+
# inserted in order to improve legibility.
|
309
|
+
#
|
310
|
+
# @example
|
311
|
+
# credit_card = CreditCard.new(:number => "2132542376824338")
|
312
|
+
# credit_card.display_number # "XXXX-XXXX-XXXX-4338"
|
313
|
+
#
|
314
|
+
# @return [String] a display-friendly version of the card number
|
315
|
+
def display_number
|
316
|
+
self.class.mask(number)
|
317
|
+
end
|
318
|
+
|
319
|
+
def first_digits
|
320
|
+
self.class.first_digits(number)
|
321
|
+
end
|
322
|
+
|
323
|
+
def last_digits
|
324
|
+
self.class.last_digits(number)
|
325
|
+
end
|
326
|
+
|
327
|
+
# Validates the credit card details.
|
328
|
+
#
|
329
|
+
# Any validation errors are added to the {#errors} attribute.
|
330
|
+
def validate
|
331
|
+
errors = validate_essential_attributes + validate_verification_value
|
332
|
+
|
333
|
+
# Bogus card is pretty much for testing purposes. Lets just skip these extra tests if its used
|
334
|
+
return errors_hash(errors) if brand == 'bogus'
|
335
|
+
|
336
|
+
errors_hash(
|
337
|
+
errors +
|
338
|
+
validate_card_brand_and_number
|
339
|
+
)
|
340
|
+
end
|
341
|
+
|
342
|
+
def self.requires_verification_value?
|
343
|
+
require_verification_value
|
344
|
+
end
|
345
|
+
|
346
|
+
def self.requires_name?
|
347
|
+
require_name
|
348
|
+
end
|
349
|
+
|
350
|
+
def emv?
|
351
|
+
icc_data.present?
|
352
|
+
end
|
353
|
+
|
354
|
+
def allow_spaces_in_card?(number = nil)
|
355
|
+
BRANDS_WITH_SPACES_IN_NUMBER.include?(self.class.brand?(self.number || number))
|
356
|
+
end
|
357
|
+
|
358
|
+
private
|
359
|
+
|
360
|
+
def filter_number(value)
|
361
|
+
regex = if allow_spaces_in_card?(value)
|
362
|
+
/[^\d ]/
|
363
|
+
else
|
364
|
+
/[^\d]/
|
365
|
+
end
|
366
|
+
value.to_s.gsub(regex, '')
|
367
|
+
end
|
368
|
+
|
369
|
+
def validate_essential_attributes #:nodoc:
|
370
|
+
errors = []
|
371
|
+
|
372
|
+
if self.class.requires_name?
|
373
|
+
errors << [:first_name, 'cannot be empty'] if first_name.blank?
|
374
|
+
errors << [:last_name, 'cannot be empty'] if last_name.blank?
|
375
|
+
end
|
376
|
+
|
377
|
+
if empty?(month) || empty?(year)
|
378
|
+
errors << [:month, 'is required'] if empty?(month)
|
379
|
+
errors << [:year, 'is required'] if empty?(year)
|
380
|
+
else
|
381
|
+
errors << [:month, 'is not a valid month'] if !valid_month?(month)
|
382
|
+
|
383
|
+
if expired?
|
384
|
+
errors << [:year, 'expired']
|
385
|
+
else
|
386
|
+
errors << [:year, 'is not a valid year'] if !valid_expiry_year?(year)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
errors
|
391
|
+
end
|
392
|
+
|
393
|
+
def validate_card_brand_and_number #:nodoc:
|
394
|
+
errors = []
|
395
|
+
|
396
|
+
if !empty?(brand)
|
397
|
+
errors << [:brand, 'is invalid'] if !CreditCard.card_companies.include?(brand)
|
398
|
+
end
|
399
|
+
|
400
|
+
if empty?(number)
|
401
|
+
errors << [:number, 'is required']
|
402
|
+
elsif !CreditCard.valid_number?(number)
|
403
|
+
errors << [:number, 'is not a valid credit card number']
|
404
|
+
end
|
405
|
+
|
406
|
+
if errors.empty?
|
407
|
+
errors << [:brand, 'does not match the card number'] if !CreditCard.matching_brand?(number, brand)
|
408
|
+
end
|
409
|
+
|
410
|
+
errors
|
411
|
+
end
|
412
|
+
|
413
|
+
def validate_verification_value #:nodoc:
|
414
|
+
errors = []
|
415
|
+
|
416
|
+
if verification_value?
|
417
|
+
errors << [:verification_value, "should be #{card_verification_value_length(brand)} digits"] unless valid_card_verification_value?(verification_value, brand)
|
418
|
+
elsif requires_verification_value? && !valid_card_verification_value?(verification_value, brand)
|
419
|
+
errors << [:verification_value, 'is required']
|
420
|
+
end
|
421
|
+
errors
|
422
|
+
end
|
423
|
+
|
424
|
+
class ExpiryDate #:nodoc:
|
425
|
+
attr_reader :month, :year
|
426
|
+
def initialize(month, year)
|
427
|
+
@month = month.to_i
|
428
|
+
@year = year.to_i
|
429
|
+
end
|
430
|
+
|
431
|
+
def expired? #:nodoc:
|
432
|
+
Time.now.utc > expiration
|
433
|
+
end
|
434
|
+
|
435
|
+
def expiration #:nodoc:
|
436
|
+
Time.utc(year, month, month_days, 23, 59, 59)
|
437
|
+
rescue ArgumentError
|
438
|
+
Time.at(0).utc
|
439
|
+
end
|
440
|
+
|
441
|
+
private
|
442
|
+
|
443
|
+
def month_days
|
444
|
+
mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
445
|
+
mdays[2] = 29 if Date.leap?(year)
|
446
|
+
mdays[month]
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module CreditCardFormatting
|
4
|
+
def expdate(credit_card)
|
5
|
+
"#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
# This method is used to format numerical information pertaining to credit cards.
|
9
|
+
#
|
10
|
+
# format(2005, :two_digits) # => "05"
|
11
|
+
# format(05, :four_digits) # => "0005"
|
12
|
+
def format(number, option)
|
13
|
+
return '' if number.blank?
|
14
|
+
|
15
|
+
case option
|
16
|
+
when :two_digits then sprintf('%.2i', number.to_i)[-2..-1]
|
17
|
+
when :four_digits then sprintf('%.4i', number.to_i)[-4..-1]
|
18
|
+
when :four_digits_year then number.to_s.length == 2 ? '20' + number.to_s : format(number, :four_digits)
|
19
|
+
else number
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|