You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ActiveMerchant gem不支持万事达卡2-BIN范围问题咨询

Fixing "Brand does not match the card number" for Mastercard's 222100–272099 BIN Range in ActiveMerchant

Great question—this is a common pain point when dealing with Mastercard's expanded BIN range in older versions of the Active Merchant gem. Here's how to resolve it:

  • First, check and update your gem version
    The Active Merchant team did add official support for Mastercard's 222100–272099 BIN range in a later release. If you're running an outdated version, that's almost certainly the issue. Run this command to check your current version:

    gem list activemerchant
    

    Then update to the latest stable release with:

    bundle update activemerchant
    

    After updating, test the card number 2221000000000009 again—this should fix the brand mismatch error for most cases.

  • If updating isn't an option, manually add the BIN range
    If you're stuck on an older gem version for compatibility reasons, you can manually inject the new BIN range into Mastercard's brand recognition rules. Add this code to an initializer file (like config/initializers/active_merchant_mastercard_bins.rb):

    ActiveMerchant::Billing::Mastercard.add_brand_range('222100'..'272099')
    

    This tells Active Merchant to treat any card starting with numbers in that range as a Mastercard, which will resolve the validation error for your test card.

  • Double-check your test card
    Quick confirmation: the number 2221000000000009 is a valid Mastercard test card, so once the BIN range is recognized, validation should pass without issues.

内容的提问来源于stack exchange,提问作者Manish Nagdewani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:15:40