检测信用卡是否来自美国

问题描述

我有一个 WooCommerce 网站的客户遇到了一个骗局,我找不到快速解决方案。

他们主要是一家美国公司,但支付网关接受在美国境外发行的信用卡。客户下订单,完成交易,然后取消信用卡。这导致客户既缺钱又缺产品,因为海外银行通常不关心将钱退还给他。

我可以使用哪些方法/策略来确保访问他网站的所有信用卡都来自美国?

解决方法

看看这个:

https://binlist.net/

现在让我们来看看信用卡:

enter image description here

您现在可以使用此功能和自定义 WooCommerce 过滤器来验证 BIN。你需要想办法获取信用卡号,因为我不知道你用哪个插件进行信用卡支付:

/**
 * Check if credit card is from a us country
 */
add_action( 'woocommerce_after_checkout_validation','validate_credit_card',10,2 );
function validate( $data,$errors ) {
    $bin      = '45717360'; // <-- you need to find a way to get your credit card infos and take the first part with substr()
    $response = wp_safe_remote_get( 'https://lookup.binlist.net/' . $bin );

    if ( isset( $response['body'] ) ) {
        $response_body = json_decode( $response['body'] );

        if ( $response_body->country->alpha2 !== 'US' ) {
            $errors->add( 'credit_card_error','Your credit card is not from a US country.' );
        }
    } else {
        $errors->add( 'credit_card_error','Unable to check your credit card.' );
    }
}
,

如果信用卡是在美国境外发行的,则不允许下单。此外,您还可以根据请求的 IP 地址检查地理位置并将其限制为仅限美国。