4.3 BIN Lookup Service

You can send a BIN number to access the detailed information of the card using that service.

1- A request is made to the BIN Lookup Service https://www.paytr.com/odeme/api/bin-detail along with BIN number of the card(The first 6 or 8 digits of the card number) and the fields that must be sent.

Required parameters for token creation

Field name / Type Explanation Compulsory Limitations
bin_number The first 6 or 8 digits of the card number of the card to be questioned. Use 8 digits for maximum verification. Yes Maximum 8 digits.
merchant_id Store Number: Store number given to you by PAYTR Yes -
merchant_salt Merchant secret key Yes -
merchant_key Merchant password Yes -


Values to be sent in POST REQUEST content:

Variable / Type Compulsory Explanation
merchant_id(integer) Yes Store Number: Store number given to you by PAYTR
bin_number(string) Yes The first 6 or 8 digits of the card number of the card to be questioned. Use 8 digits for maximum verification.
paytr_token(string) Yes paytr_token: This value is the one you need to create to make sure the request is coming from you and that the values it contains have not changed.


2- Your response to this request is returned in JSON format. a. If the BIN Number is not defined (For example, if it is a foreign card), the status value returns "failed". b. If the BIN number is defined, the status value returns as "success" with the information in the table below returns. c. If you have an error in the request, the status value returns "error". In this case, you should check the "err_msg" for error details.

When the status value is successful, the returned values are in the table below.

Variable / Type Values Explanation
status (string) success, error or failed Status: Result of the request (Response)
cardType (string) credit / debit credit / debit
businessCard (string) y / n Company Card: Whether the card is a company card or not
bank (string) Example: Yapı Kredi Bank: The bank of the card
brand (string) Example: axess, bonus,cardfinans, combo,world, paraf, advantage,maximum,saglamkart Program partners: (If the card is not included in a program partnership, the value will be none. In this case, installment payment can not be made with the card on PayTR)
schema (string) VISA, MASTERCARD, AMEX, TROY, OTHER Information on which scheme the card belongs to. (If it is not known which scheme the card belongs to, answer returns as OTHER)
bankCode (int) Example: 0010 Bank Code: Card bank code
allow_non3d (string) Y(yes) ve N(no) Non-3D processing suitability result


<?php

    $merchant_id    = 'XXXXXX';
    $merchant_key   = 'XXXXXX';
    $merchant_salt  = 'XXXXXX';

    $bin_number = "";

    $hash_str = $bin_number . $merchant_id . $merchant_salt;
    $paytr_token=base64_encode(hash_hmac('sha256', $hash_str, $merchant_key, true));
    $post_vals=array(
        'merchant_id'=>$merchant_id,
        'bin_number'=>$bin_number,
        'paytr_token'=>$paytr_token
    );

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/bin-detail");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1) ;
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);

    $result = @curl_exec($ch);

    if(curl_errno($ch))
        die("PAYTR BIN detail request timeout. err:".curl_error($ch));

    curl_close($ch);

    $result=json_decode($result,1);

    if($result['status']=='error')
        die("PAYTR BIN detail request error. Error:".$result['err_msg']);
    elseif($result['status']=='failed')
        die("BIN tanımlı değil. (Örneğin bir yurtdışı kartı)");
    else
        print_r($result);

?>


BIN Lookup Service sample codes Click to download.