activemerchant 1.43.3 → 1.44.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG +133 -3
- data/CONTRIBUTORS +25 -0
- data/README.md +14 -39
- data/lib/active_merchant.rb +43 -2
- data/lib/active_merchant/billing.rb +3 -1
- data/lib/active_merchant/billing/base.rb +10 -2
- data/lib/active_merchant/billing/check.rb +29 -22
- data/lib/active_merchant/billing/compatibility.rb +120 -0
- data/lib/active_merchant/billing/credit_card.rb +129 -60
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
- data/lib/active_merchant/billing/credit_card_methods.rb +60 -43
- data/lib/active_merchant/billing/cvv_result.rb +15 -15
- data/lib/active_merchant/billing/gateway.rb +46 -11
- data/lib/active_merchant/billing/gateways/adyen.rb +205 -0
- data/lib/active_merchant/billing/gateways/app55.rb +1 -9
- data/lib/active_merchant/billing/gateways/authorize_net.rb +7 -391
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +20 -4
- data/lib/active_merchant/billing/gateways/balanced.rb +127 -367
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +1 -1
- data/lib/active_merchant/billing/gateways/beanstream.rb +25 -6
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -3
- data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -3
- data/lib/active_merchant/billing/gateways/bogus.rb +1 -13
- data/lib/active_merchant/billing/gateways/borgun.rb +211 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +31 -13
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +184 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +3 -2
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +56 -81
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +3 -1
- data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
- data/lib/active_merchant/billing/gateways/elavon.rb +45 -9
- data/lib/active_merchant/billing/gateways/epay.rb +2 -2
- data/lib/active_merchant/billing/gateways/eway.rb +1 -12
- data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +233 -202
- data/lib/active_merchant/billing/gateways/exact.rb +1 -1
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +1 -1
- data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
- data/lib/active_merchant/billing/gateways/finansbank.rb +2 -1
- data/lib/active_merchant/billing/gateways/first_pay.rb +108 -124
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +43 -13
- data/lib/active_merchant/billing/gateways/garanti.rb +2 -2
- data/lib/active_merchant/billing/gateways/hps.rb +281 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +2 -2
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +1 -4
- data/lib/active_merchant/billing/gateways/inspire.rb +0 -8
- data/lib/active_merchant/billing/gateways/iridium.rb +25 -3
- data/lib/active_merchant/billing/gateways/jetpay.rb +1 -1
- data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -13
- data/lib/active_merchant/billing/gateways/litle.rb +10 -4
- data/lib/active_merchant/billing/gateways/maxipago.rb +7 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +0 -6
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +4 -11
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +3 -10
- data/lib/active_merchant/billing/gateways/mercury.rb +0 -7
- data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -20
- data/lib/active_merchant/billing/gateways/migs.rb +1 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +29 -21
- data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -11
- data/lib/active_merchant/billing/gateways/money_movers.rb +1 -8
- data/lib/active_merchant/billing/gateways/nab_transact.rb +16 -15
- data/lib/active_merchant/billing/gateways/net_registry.rb +1 -1
- data/lib/active_merchant/billing/gateways/netbilling.rb +0 -7
- data/lib/active_merchant/billing/gateways/network_merchants.rb +21 -18
- data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
- data/lib/active_merchant/billing/gateways/openpay.rb +1 -8
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +34 -23
- data/lib/active_merchant/billing/gateways/orbital.rb +121 -4
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +2 -9
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +3 -13
- data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +1 -9
- data/lib/active_merchant/billing/gateways/payex.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +7 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +15 -15
- data/lib/active_merchant/billing/gateways/payflow_express.rb +19 -19
- data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/paymill.rb +7 -2
- data/lib/active_merchant/billing/gateways/paypal.rb +25 -14
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +16 -2
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +3 -2
- data/lib/active_merchant/billing/gateways/paypal_express.rb +25 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +1 -8
- data/lib/active_merchant/billing/gateways/pin.rb +39 -7
- data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
- data/lib/active_merchant/billing/gateways/psigate.rb +1 -12
- data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
- data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
- data/lib/active_merchant/billing/gateways/quickpay.rb +17 -15
- data/lib/active_merchant/billing/gateways/realex.rb +3 -12
- data/lib/active_merchant/billing/gateways/sage.rb +1 -1
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +2 -8
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +1 -1
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +1 -1
- data/lib/active_merchant/billing/gateways/sage_pay.rb +93 -28
- data/lib/active_merchant/billing/gateways/secure_net.rb +1 -8
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -3
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
- data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -2
- data/lib/active_merchant/billing/gateways/smart_ps.rb +8 -2
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -1
- data/lib/active_merchant/billing/gateways/stripe.rb +14 -15
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +0 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +4 -9
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +46 -43
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +7 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
- data/lib/active_merchant/billing/gateways/viaklix.rb +0 -6
- data/lib/active_merchant/billing/gateways/vindicia.rb +68 -44
- data/lib/active_merchant/billing/gateways/webpay.rb +1 -9
- data/lib/active_merchant/billing/gateways/wirecard.rb +117 -11
- data/lib/active_merchant/billing/gateways/worldpay.rb +50 -22
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +20 -15
- data/lib/active_merchant/country.rb +327 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +29 -0
- data/lib/active_merchant/offsite_payments_shim.rb +19 -0
- data/lib/active_merchant/version.rb +1 -1
- metadata +60 -243
- metadata.gz.sig +0 -0
- data/gem-public_cert.pem +0 -21
- data/lib/active_merchant/billing/expiry_date.rb +0 -34
- data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
- data/lib/active_merchant/billing/gateways/orbital/cvv_result.rb +0 -34
- data/lib/active_merchant/billing/integrations.rb +0 -17
- data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
- data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
- data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
- data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -78
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
- data/lib/active_merchant/billing/integrations/bit_pay.rb +0 -30
- data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +0 -66
- data/lib/active_merchant/billing/integrations/bit_pay/notification.rb +0 -74
- data/lib/active_merchant/billing/integrations/bit_pay/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
- data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/citrus.rb +0 -28
- data/lib/active_merchant/billing/integrations/citrus/helper.rb +0 -57
- data/lib/active_merchant/billing/integrations/citrus/notification.rb +0 -133
- data/lib/active_merchant/billing/integrations/citrus/return.rb +0 -40
- data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
- data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
- data/lib/active_merchant/billing/integrations/doku.rb +0 -24
- data/lib/active_merchant/billing/integrations/doku/helper.rb +0 -102
- data/lib/active_merchant/billing/integrations/doku/notification.rb +0 -69
- data/lib/active_merchant/billing/integrations/doku/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
- data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
- data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
- data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
- data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
- data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
- data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
- data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
- data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
- data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
- data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
- data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
- data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
- data/lib/active_merchant/billing/integrations/epay.rb +0 -21
- data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
- data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
- data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
- data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
- data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
- data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/helper.rb +0 -123
- data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
- data/lib/active_merchant/billing/integrations/ipay88.rb +0 -23
- data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -118
- data/lib/active_merchant/billing/integrations/ipay88/notification.rb +0 -103
- data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -29
- data/lib/active_merchant/billing/integrations/klarna.rb +0 -71
- data/lib/active_merchant/billing/integrations/klarna/helper.rb +0 -123
- data/lib/active_merchant/billing/integrations/klarna/notification.rb +0 -103
- data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
- data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
- data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
- data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
- data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
- data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
- data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
- data/lib/active_merchant/billing/integrations/mollie_ideal.rb +0 -98
- data/lib/active_merchant/billing/integrations/mollie_ideal/helper.rb +0 -67
- data/lib/active_merchant/billing/integrations/mollie_ideal/notification.rb +0 -69
- data/lib/active_merchant/billing/integrations/mollie_ideal/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -123
- data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
- data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/notification.rb +0 -71
- data/lib/active_merchant/billing/integrations/pag_seguro.rb +0 -53
- data/lib/active_merchant/billing/integrations/pag_seguro/helper.rb +0 -121
- data/lib/active_merchant/billing/integrations/pag_seguro/notification.rb +0 -104
- data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
- data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
- data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
- data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
- data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
- data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
- data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
- data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
- data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/paydollar.rb +0 -59
- data/lib/active_merchant/billing/integrations/paydollar/helper.rb +0 -41
- data/lib/active_merchant/billing/integrations/paydollar/notification.rb +0 -64
- data/lib/active_merchant/billing/integrations/paydollar/return.rb +0 -15
- data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
- data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
- data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
- data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
- data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
- data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -39
- data/lib/active_merchant/billing/integrations/payu_in.rb +0 -36
- data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -76
- data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -154
- data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
- data/lib/active_merchant/billing/integrations/payu_in_paisa.rb +0 -30
- data/lib/active_merchant/billing/integrations/payu_in_paisa/helper.rb +0 -19
- data/lib/active_merchant/billing/integrations/payu_in_paisa/notification.rb +0 -13
- data/lib/active_merchant/billing/integrations/payu_in_paisa/return.rb +0 -16
- data/lib/active_merchant/billing/integrations/platron.rb +0 -28
- data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
- data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
- data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -113
- data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
- data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
- data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -96
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
- data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
- data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
- data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
- data/lib/active_merchant/billing/integrations/return.rb +0 -42
- data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
- data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
- data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
- data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
- data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
- data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -107
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -171
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -58
- data/lib/active_merchant/billing/integrations/universal.rb +0 -23
- data/lib/active_merchant/billing/integrations/universal/helper.rb +0 -76
- data/lib/active_merchant/billing/integrations/universal/notification.rb +0 -52
- data/lib/active_merchant/billing/integrations/universal/return.rb +0 -18
- data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
- data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
- data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
- data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
- data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
- data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
- data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
- data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
- data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
- data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
- data/lib/active_merchant/billing/integrations/wirecard_checkout_page.rb +0 -39
- data/lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb +0 -104
- data/lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb +0 -145
- data/lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb +0 -101
- data/lib/active_merchant/billing/integrations/wirecard_checkout_page/return.rb +0 -35
- data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
@@ -0,0 +1,120 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
module Compatibility
|
4
|
+
module Model
|
5
|
+
def valid?
|
6
|
+
Compatibility.deprecated
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def errors
|
11
|
+
Compatibility.deprecated
|
12
|
+
internal_errors
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
@rails_required = false
|
17
|
+
def self.rails_required!
|
18
|
+
@rails_required = true
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.deprecated
|
22
|
+
ActiveMerchant.deprecated(
|
23
|
+
%(Implicit inclusion of Rails-specific functionality is deprecated.) +
|
24
|
+
%( Explicitly require "active_merchant/billing/rails" if you need it.)
|
25
|
+
) unless @rails_required
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.humanize(lower_case_and_underscored_word)
|
29
|
+
result = lower_case_and_underscored_word.to_s.dup
|
30
|
+
result.gsub!(/_id$/, "")
|
31
|
+
result.gsub!(/_/, ' ')
|
32
|
+
result.gsub(/([a-z\d]*)/i) { |match|
|
33
|
+
match.downcase
|
34
|
+
}.gsub(/^\w/) { $&.upcase }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# This lives in compatibility until we remove the deprecation for implicitly
|
41
|
+
# requiring Rails
|
42
|
+
module ActiveMerchant
|
43
|
+
module Billing
|
44
|
+
module Rails
|
45
|
+
module Model
|
46
|
+
def valid?
|
47
|
+
internal_errors.clear
|
48
|
+
|
49
|
+
validate.each do |attribute, errors|
|
50
|
+
errors.each do |error|
|
51
|
+
internal_errors.add(attribute, error)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
internal_errors.empty?
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def internal_errors
|
61
|
+
@errors ||= Errors.new
|
62
|
+
end
|
63
|
+
|
64
|
+
class Errors < Hash
|
65
|
+
def initialize
|
66
|
+
super(){|h, k| h[k] = []}
|
67
|
+
end
|
68
|
+
|
69
|
+
alias count size
|
70
|
+
|
71
|
+
def [](key)
|
72
|
+
super(key.to_s)
|
73
|
+
end
|
74
|
+
|
75
|
+
def []=(key, value)
|
76
|
+
super(key.to_s, value)
|
77
|
+
end
|
78
|
+
|
79
|
+
def empty?
|
80
|
+
all?{|k, v| v && v.empty?}
|
81
|
+
end
|
82
|
+
|
83
|
+
def on(field)
|
84
|
+
self[field].to_a.first
|
85
|
+
end
|
86
|
+
|
87
|
+
def add(field, error)
|
88
|
+
self[field] << error
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_to_base(error)
|
92
|
+
add(:base, error)
|
93
|
+
end
|
94
|
+
|
95
|
+
def each_full
|
96
|
+
full_messages.each{|msg| yield msg}
|
97
|
+
end
|
98
|
+
|
99
|
+
def full_messages
|
100
|
+
result = []
|
101
|
+
|
102
|
+
self.each do |key, messages|
|
103
|
+
next unless(messages && !messages.empty?)
|
104
|
+
if key == 'base'
|
105
|
+
result << "#{messages.first}"
|
106
|
+
else
|
107
|
+
result << "#{Compatibility.humanize(key)} #{messages.first}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
result
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Compatibility::Model.send(:include, Rails::Model)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'date'
|
3
|
-
require
|
3
|
+
require "active_merchant/billing/model"
|
4
4
|
|
5
5
|
module ActiveMerchant #:nodoc:
|
6
6
|
module Billing #:nodoc:
|
@@ -43,12 +43,11 @@ module ActiveMerchant #:nodoc:
|
|
43
43
|
# :number => '4242424242424242'
|
44
44
|
# )
|
45
45
|
#
|
46
|
-
# cc.
|
46
|
+
# cc.validate # => {}
|
47
47
|
# cc.display_number # => XXXX-XXXX-XXXX-4242
|
48
48
|
#
|
49
|
-
class CreditCard
|
49
|
+
class CreditCard < Model
|
50
50
|
include CreditCardMethods
|
51
|
-
include Validateable
|
52
51
|
|
53
52
|
cattr_accessor :require_verification_value
|
54
53
|
self.require_verification_value = true
|
@@ -56,17 +55,21 @@ module ActiveMerchant #:nodoc:
|
|
56
55
|
# Returns or sets the credit card number.
|
57
56
|
#
|
58
57
|
# @return [String]
|
59
|
-
|
58
|
+
attr_reader :number
|
59
|
+
|
60
|
+
def number=(value)
|
61
|
+
@number = (empty?(value) ? value : value.to_s.gsub(/[^\d]/, ""))
|
62
|
+
end
|
60
63
|
|
61
64
|
# Returns or sets the expiry month for the card.
|
62
65
|
#
|
63
66
|
# @return [Integer]
|
64
|
-
|
67
|
+
attr_reader :month
|
65
68
|
|
66
69
|
# Returns or sets the expiry year for the card.
|
67
70
|
#
|
68
71
|
# @return [Integer]
|
69
|
-
|
72
|
+
attr_reader :year
|
70
73
|
|
71
74
|
# Returns or sets the credit card brand.
|
72
75
|
#
|
@@ -88,7 +91,18 @@ module ActiveMerchant #:nodoc:
|
|
88
91
|
# Or, if you wish to test your implementation, +'bogus'+.
|
89
92
|
#
|
90
93
|
# @return (String) the credit card brand
|
91
|
-
|
94
|
+
def brand
|
95
|
+
if !defined?(@brand) || empty?(@brand)
|
96
|
+
self.class.brand?(number)
|
97
|
+
else
|
98
|
+
@brand
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def brand=(value)
|
103
|
+
value = value && value.to_s.dup
|
104
|
+
@brand = (value.respond_to?(:downcase) ? value.downcase : value)
|
105
|
+
end
|
92
106
|
|
93
107
|
# Returns or sets the first name of the card holder.
|
94
108
|
#
|
@@ -101,7 +115,8 @@ module ActiveMerchant #:nodoc:
|
|
101
115
|
attr_accessor :last_name
|
102
116
|
|
103
117
|
# Required for Switch / Solo cards
|
104
|
-
|
118
|
+
attr_reader :start_month, :start_year
|
119
|
+
attr_accessor :issue_number
|
105
120
|
|
106
121
|
# Returns or sets the card verification value.
|
107
122
|
#
|
@@ -118,12 +133,12 @@ module ActiveMerchant #:nodoc:
|
|
118
133
|
attr_accessor :track_data
|
119
134
|
|
120
135
|
def type
|
121
|
-
|
136
|
+
ActiveMerchant.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead."
|
122
137
|
brand
|
123
138
|
end
|
124
139
|
|
125
140
|
def type=(value)
|
126
|
-
|
141
|
+
ActiveMerchant.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead."
|
127
142
|
self.brand = value
|
128
143
|
end
|
129
144
|
|
@@ -148,19 +163,19 @@ module ActiveMerchant #:nodoc:
|
|
148
163
|
|
149
164
|
# Returns whether the +first_name+ attribute has been set.
|
150
165
|
def first_name?
|
151
|
-
|
166
|
+
first_name.present?
|
152
167
|
end
|
153
168
|
|
154
169
|
# Returns whether the +last_name+ attribute has been set.
|
155
170
|
def last_name?
|
156
|
-
|
171
|
+
last_name.present?
|
157
172
|
end
|
158
173
|
|
159
174
|
# Returns the full name of the card holder.
|
160
175
|
#
|
161
176
|
# @return [String] the full name of the card holder
|
162
177
|
def name
|
163
|
-
[
|
178
|
+
[first_name, last_name].compact.join(' ')
|
164
179
|
end
|
165
180
|
|
166
181
|
def name=(full_name)
|
@@ -169,8 +184,21 @@ module ActiveMerchant #:nodoc:
|
|
169
184
|
self.first_name = names.join(" ")
|
170
185
|
end
|
171
186
|
|
187
|
+
%w(month year start_month start_year).each do |m|
|
188
|
+
class_eval %(
|
189
|
+
def #{m}=(v)
|
190
|
+
@#{m} = case v
|
191
|
+
when "", nil, 0
|
192
|
+
nil
|
193
|
+
else
|
194
|
+
v.to_i
|
195
|
+
end
|
196
|
+
end
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
172
200
|
def verification_value?
|
173
|
-
|
201
|
+
!verification_value.blank?
|
174
202
|
end
|
175
203
|
|
176
204
|
# Returns a display-friendly version of the card number.
|
@@ -199,15 +227,16 @@ module ActiveMerchant #:nodoc:
|
|
199
227
|
#
|
200
228
|
# Any validation errors are added to the {#errors} attribute.
|
201
229
|
def validate
|
202
|
-
validate_essential_attributes
|
230
|
+
errors = validate_essential_attributes + validate_verification_value
|
203
231
|
|
204
232
|
# Bogus card is pretty much for testing purposes. Lets just skip these extra tests if its used
|
205
|
-
return if brand == 'bogus'
|
233
|
+
return errors_hash(errors) if brand == 'bogus'
|
206
234
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
235
|
+
errors_hash(
|
236
|
+
errors +
|
237
|
+
validate_card_brand_and_number +
|
238
|
+
validate_switch_or_solo_attributes
|
239
|
+
)
|
211
240
|
end
|
212
241
|
|
213
242
|
def self.requires_verification_value?
|
@@ -216,66 +245,106 @@ module ActiveMerchant #:nodoc:
|
|
216
245
|
|
217
246
|
private
|
218
247
|
|
219
|
-
def
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
248
|
+
def validate_essential_attributes #:nodoc:
|
249
|
+
errors = []
|
250
|
+
|
251
|
+
errors << [:first_name, "cannot be empty"] if first_name.blank?
|
252
|
+
errors << [:last_name, "cannot be empty"] if last_name.blank?
|
253
|
+
|
254
|
+
if(empty?(month) || empty?(year))
|
255
|
+
errors << [:month, "is required"] if empty?(month)
|
256
|
+
errors << [:year, "is required"] if empty?(year)
|
257
|
+
else
|
258
|
+
errors << [:month, "is not a valid month"] if !valid_month?(month)
|
259
|
+
|
260
|
+
if expired?
|
261
|
+
errors << [:year, "expired"]
|
262
|
+
else
|
263
|
+
errors << [:year, "is not a valid year"] if !valid_expiry_year?(year)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
errors
|
227
268
|
end
|
228
269
|
|
229
|
-
def
|
230
|
-
|
231
|
-
|
270
|
+
def validate_card_brand_and_number #:nodoc:
|
271
|
+
errors = []
|
272
|
+
|
273
|
+
if !empty?(brand)
|
274
|
+
errors << [:brand, "is invalid"] if !CreditCard.card_companies.keys.include?(brand)
|
275
|
+
end
|
276
|
+
|
277
|
+
if empty?(number)
|
278
|
+
errors << [:number, "is required"]
|
232
279
|
elsif !CreditCard.valid_number?(number)
|
233
|
-
errors
|
280
|
+
errors << [:number, "is not a valid credit card number"]
|
234
281
|
end
|
235
282
|
|
236
|
-
|
237
|
-
errors
|
283
|
+
if errors.empty?
|
284
|
+
errors << [:brand, "does not match the card number"] if !CreditCard.matching_brand?(number, brand)
|
238
285
|
end
|
239
|
-
end
|
240
286
|
|
241
|
-
|
242
|
-
errors.add :brand, "is required" if brand.blank? && number.present?
|
243
|
-
errors.add :brand, "is invalid" unless brand.blank? || CreditCard.card_companies.keys.include?(brand)
|
287
|
+
errors
|
244
288
|
end
|
245
289
|
|
246
|
-
|
247
|
-
|
248
|
-
def validate_essential_attributes #:nodoc:
|
249
|
-
errors.add :first_name, "cannot be empty" if @first_name.blank?
|
250
|
-
errors.add :last_name, "cannot be empty" if @last_name.blank?
|
290
|
+
def validate_verification_value #:nodoc:
|
291
|
+
errors = []
|
251
292
|
|
252
|
-
if
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
errors
|
258
|
-
errors.add :year, "is not a valid year" unless expired? || valid_expiry_year?(@year)
|
293
|
+
if verification_value?
|
294
|
+
unless valid_card_verification_value?(verification_value, brand)
|
295
|
+
errors << [:verification_value, "should be #{card_verification_value_length(brand)} digits"]
|
296
|
+
end
|
297
|
+
elsif CreditCard.requires_verification_value?
|
298
|
+
errors << [:verification_value, "is required"]
|
259
299
|
end
|
300
|
+
errors
|
260
301
|
end
|
261
302
|
|
262
303
|
def validate_switch_or_solo_attributes #:nodoc:
|
304
|
+
errors = []
|
305
|
+
|
263
306
|
if %w[switch solo].include?(brand)
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
307
|
+
valid_start_month = valid_month?(start_month)
|
308
|
+
valid_start_year = valid_start_year?(start_year)
|
309
|
+
|
310
|
+
if((!valid_start_month || !valid_start_year) && !valid_issue_number?(issue_number))
|
311
|
+
if empty?(issue_number)
|
312
|
+
errors << [:issue_number, "cannot be empty"]
|
313
|
+
errors << [:start_month, "is invalid"] if !valid_start_month
|
314
|
+
errors << [:start_year, "is invalid"] if !valid_start_year
|
269
315
|
else
|
270
|
-
errors
|
316
|
+
errors << [:issue_number, "is invalid"] if !valid_issue_number?(issue_number)
|
271
317
|
end
|
272
318
|
end
|
273
319
|
end
|
320
|
+
|
321
|
+
errors
|
274
322
|
end
|
275
323
|
|
276
|
-
|
277
|
-
|
278
|
-
|
324
|
+
class ExpiryDate #:nodoc:
|
325
|
+
attr_reader :month, :year
|
326
|
+
def initialize(month, year)
|
327
|
+
@month = month.to_i
|
328
|
+
@year = year.to_i
|
329
|
+
end
|
330
|
+
|
331
|
+
def expired? #:nodoc:
|
332
|
+
Time.now.utc > expiration
|
333
|
+
end
|
334
|
+
|
335
|
+
def expiration #:nodoc:
|
336
|
+
begin
|
337
|
+
Time.utc(year, month, month_days, 23, 59, 59)
|
338
|
+
rescue ArgumentError
|
339
|
+
Time.at(0).utc
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
private
|
344
|
+
def month_days
|
345
|
+
mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
|
346
|
+
mdays[2] = 29 if Date.leap?(year)
|
347
|
+
mdays[month]
|
279
348
|
end
|
280
349
|
end
|
281
350
|
end
|
@@ -2,6 +2,10 @@ module ActiveMerchant #:nodoc:
|
|
2
2
|
module Billing #:nodoc:
|
3
3
|
module CreditCardFormatting
|
4
4
|
|
5
|
+
def expdate(credit_card)
|
6
|
+
"#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
|
7
|
+
end
|
8
|
+
|
5
9
|
# This method is used to format numerical information pertaining to credit cards.
|
6
10
|
#
|
7
11
|
# format(2005, :two_digits) # => "05"
|
@@ -15,7 +19,6 @@ module ActiveMerchant #:nodoc:
|
|
15
19
|
else number
|
16
20
|
end
|
17
21
|
end
|
18
|
-
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc:
|
|
2
2
|
module Billing #:nodoc:
|
3
3
|
# Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
|
4
4
|
module CreditCardMethods
|
5
|
-
CARD_COMPANIES = {
|
5
|
+
CARD_COMPANIES = {
|
6
6
|
'visa' => /^4\d{12}(\d{3})?$/,
|
7
7
|
'master' => /^(5[1-5]\d{4}|677189)\d{10}$/,
|
8
8
|
'discover' => /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/,
|
@@ -16,116 +16,133 @@ module ActiveMerchant #:nodoc:
|
|
16
16
|
'forbrugsforeningen' => /^600722\d{10}$/,
|
17
17
|
'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/
|
18
18
|
}
|
19
|
-
|
19
|
+
|
20
20
|
def self.included(base)
|
21
21
|
base.extend(ClassMethods)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def valid_month?(month)
|
25
25
|
(1..12).include?(month.to_i)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def valid_expiry_year?(year)
|
29
29
|
(Time.now.year..Time.now.year + 20).include?(year.to_i)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def valid_start_year?(year)
|
33
|
-
year.to_s =~ /^\d{4}$/ && year.to_i > 1987
|
33
|
+
((year.to_s =~ /^\d{4}$/) && (year.to_i > 1987))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Credit card providers have 3 digit verification values
|
37
|
+
# This isn't standardised, these are called various names such as
|
38
|
+
# CVC, CVV, CID, CSC and more
|
39
|
+
# See: http://en.wikipedia.org/wiki/Card_security_code
|
40
|
+
# American Express is the exception with 4 digits
|
41
|
+
#
|
42
|
+
# Below are links from the card providers with their requirements
|
43
|
+
# visa: http://usa.visa.com/personal/security/3-digit-security-code.jsp
|
44
|
+
# master: http://www.mastercard.com/ca/merchant/en/getstarted/Anatomy_MasterCard.html
|
45
|
+
# jcb: http://www.jcbcard.com/security/info.html
|
46
|
+
# diners_club: http://www.dinersclub.com/assets/DinersClub_card_ID_features.pdf
|
47
|
+
# discover: https://www.discover.com/credit-cards/help-center/glossary.html
|
48
|
+
# american_express: https://online.americanexpress.com/myca/fuidfyp/us/action?request_type=un_fuid&Face=en_US
|
49
|
+
def valid_card_verification_value?(cvv, brand)
|
50
|
+
cvv.to_s =~ /^\d{#{card_verification_value_length(brand)}}$/
|
34
51
|
end
|
35
52
|
|
36
|
-
def
|
37
|
-
|
53
|
+
def card_verification_value_length(brand)
|
54
|
+
brand == 'american_express' ? 4 : 3
|
38
55
|
end
|
39
56
|
|
57
|
+
def valid_issue_number?(number)
|
58
|
+
(number.to_s =~ /^\d{1,2}$/)
|
59
|
+
end
|
60
|
+
|
40
61
|
module ClassMethods
|
41
|
-
# Returns true if it validates. Optionally, you can pass a card brand as an argument and
|
62
|
+
# Returns true if it validates. Optionally, you can pass a card brand as an argument and
|
42
63
|
# make sure it is of the correct brand.
|
43
64
|
#
|
44
65
|
# References:
|
45
66
|
# - http://perl.about.com/compute/perl/library/nosearch/P073000.htm
|
46
67
|
# - http://www.beachnet.com/~hstiles/cardtype.html
|
47
68
|
def valid_number?(number)
|
48
|
-
valid_test_mode_card_number?(number) ||
|
49
|
-
valid_card_number_length?(number) &&
|
69
|
+
valid_test_mode_card_number?(number) ||
|
70
|
+
valid_card_number_length?(number) &&
|
50
71
|
valid_checksum?(number)
|
51
72
|
end
|
52
|
-
|
73
|
+
|
53
74
|
# Regular expressions for the known card companies.
|
54
|
-
#
|
55
|
-
# References:
|
56
|
-
# - http://en.wikipedia.org/wiki/Credit_card_number
|
57
|
-
# - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html
|
75
|
+
#
|
76
|
+
# References:
|
77
|
+
# - http://en.wikipedia.org/wiki/Credit_card_number
|
78
|
+
# - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html
|
58
79
|
def card_companies
|
59
80
|
CARD_COMPANIES
|
60
81
|
end
|
61
|
-
|
82
|
+
|
62
83
|
# Returns a string containing the brand of card from the list of known information below.
|
63
84
|
# Need to check the cards in a particular order, as there is some overlap of the allowable ranges
|
64
85
|
#--
|
65
|
-
# TODO Refactor this method. We basically need to tighten up the Maestro Regexp.
|
66
|
-
#
|
67
|
-
# Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten
|
68
|
-
# things up, we can boil this whole thing down to something like...
|
69
|
-
#
|
86
|
+
# TODO Refactor this method. We basically need to tighten up the Maestro Regexp.
|
87
|
+
#
|
88
|
+
# Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten
|
89
|
+
# things up, we can boil this whole thing down to something like...
|
90
|
+
#
|
70
91
|
# def brand?(number)
|
71
92
|
# return 'visa' if valid_test_mode_card_number?(number)
|
72
93
|
# card_companies.find([nil]) { |brand, regexp| number =~ regexp }.first.dup
|
73
94
|
# end
|
74
|
-
#
|
95
|
+
#
|
75
96
|
def brand?(number)
|
76
97
|
return 'bogus' if valid_test_mode_card_number?(number)
|
77
98
|
|
78
99
|
card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern|
|
79
|
-
return company.dup if number =~ pattern
|
100
|
+
return company.dup if number =~ pattern
|
80
101
|
end
|
81
|
-
|
102
|
+
|
82
103
|
return 'maestro' if number =~ card_companies['maestro']
|
83
104
|
|
84
105
|
return nil
|
85
106
|
end
|
86
107
|
|
87
108
|
def type?(number)
|
88
|
-
deprecated "CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead."
|
109
|
+
ActiveMerchant.deprecated "CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead."
|
89
110
|
brand?(number)
|
90
111
|
end
|
91
|
-
|
112
|
+
|
92
113
|
def first_digits(number)
|
93
|
-
number.to_s.slice(0,6)
|
114
|
+
number.to_s.slice(0,6)
|
94
115
|
end
|
95
|
-
|
96
|
-
def last_digits(number)
|
97
|
-
number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
|
116
|
+
|
117
|
+
def last_digits(number)
|
118
|
+
number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
|
98
119
|
end
|
99
|
-
|
120
|
+
|
100
121
|
def mask(number)
|
101
122
|
"XXXX-XXXX-XXXX-#{last_digits(number)}"
|
102
123
|
end
|
103
|
-
|
124
|
+
|
104
125
|
# Checks to see if the calculated brand matches the specified brand
|
105
126
|
def matching_brand?(number, brand)
|
106
127
|
brand?(number) == brand
|
107
128
|
end
|
108
129
|
|
109
130
|
def matching_type?(number, brand)
|
110
|
-
deprecated "CreditCard#matching_type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#matching_brand? instead."
|
131
|
+
ActiveMerchant.deprecated "CreditCard#matching_type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#matching_brand? instead."
|
111
132
|
matching_brand?(number, brand)
|
112
133
|
end
|
113
134
|
|
114
|
-
def deprecated(message)
|
115
|
-
warn(Kernel.caller[1] + message)
|
116
|
-
end
|
117
|
-
|
118
135
|
private
|
119
|
-
|
136
|
+
|
120
137
|
def valid_card_number_length?(number) #:nodoc:
|
121
138
|
number.to_s.length >= 12
|
122
139
|
end
|
123
|
-
|
140
|
+
|
124
141
|
def valid_test_mode_card_number?(number) #:nodoc:
|
125
|
-
ActiveMerchant::Billing::Base.test? &&
|
142
|
+
ActiveMerchant::Billing::Base.test? &&
|
126
143
|
%w[1 2 3 success failure error].include?(number.to_s)
|
127
144
|
end
|
128
|
-
|
145
|
+
|
129
146
|
# Checks the validity of a card number by use of the Luhn Algorithm.
|
130
147
|
# Please see http://en.wikipedia.org/wiki/Luhn_algorithm for details.
|
131
148
|
def valid_checksum?(number) #:nodoc:
|
@@ -134,7 +151,7 @@ module ActiveMerchant #:nodoc:
|
|
134
151
|
weight = number[-1 * (i + 2), 1].to_i * (2 - (i % 2))
|
135
152
|
sum += (weight < 10) ? weight : weight - 9
|
136
153
|
end
|
137
|
-
|
154
|
+
|
138
155
|
(number[-1,1].to_i == (10 - sum % 10) % 10)
|
139
156
|
end
|
140
157
|
end
|