GETTING THE USER'S REGISTERED CARD LIST (CAPI LIST)
1) In order to list the cards registered in PAYTR to the user when a user starts the payment process, make a request to https://www.paytr.com/odeme/capi/list with the following parameters.
Required parameters for token creation
Field name / Type | Description | Mandatory | Limitations |
---|---|---|---|
utoken | User specific token notified to you by PAYTR system in post-payment payment notification. | Yes | - |
merchant_salt | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | Yes | - |
merchant_key | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | 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 |
utoken (string) | Yes | User Token: User specific token notified to you by PAYTR system in post-payment notification |
paytr_token (string) | Yes | PayTR Token: It is the value that you will create to make sure that the request comes from you and that the content has not changed (You should look at the sample codes regarding the calculation) |
2- The values in the table below will return to JSON format. When no match is found with the information you sent, the
answer is returned as empty JSON.
Variable / Type | Explanation | Possible / Sample Values |
---|---|---|
status (string) | Status: Returns an error in the event of an error, not an operation when successful | error |
err_msg (string) | Error Message: If the request is unsuccessful, the error reason is returned in err_msg | Example: Connection error occurred |
ctoken (string) | Card Token: Token that identifies the user's registered card | |
last_4 (string) | Last 4: Last 4 digits of the registered card | |
require_cvv (string) | The require_cvv parameter of the card selected by the user is checked, and if it is 1, the field to enter CVV is displayed. | 0 or 1 |
month (string) | Month: Month information of the card's expiration date | Example: 05 |
year (string) | Year: Year information of the card's expiration date | Example: 28 |
c_bank (string) | Bank: The bank of the card | Example: Yapı Kredi |
c_name | Name Surname: Name surname entered by the user during card registration | |
c_brand (string) | Card Program Partnership Name | Example: maximum, bonus,world etc. |
c_type (string) | Card Program Partnership Name | credit or debit |
businessCard (string) | Company Card: Information whether the card is a company card | y / n |
initial (string) | Card Scheme: 2 and 5 MasterCard, 3 Amex, 4 VISA, 9 TROY | 2,3,4,5,9 |
schema (string) | Card Scheme: If it is not known which scheme the card belongs to, answer returns as OTHER. | VISA, MASTERCARD, AMEX, TROY, etc. |
3- List the registered cards that the user can choose by getting the returning card information.
4- Start the payment using the ctoken information of the selected registered card and the utoken information of the user (If the require_cvv value is 1 for the selected card, you must provide the user with a field to enter a CVV and send the CVV in the payment request)
As a result of this operation, the registered card list returnes in JSON format.
<?php
$merchant_id = 'XXXXXX';
$merchant_key = 'YYYYYYYYYYYYYY';
$merchant_salt = 'ZZZZZZZZZZZZZZ';
$utoken = "";
$hash_str = $utoken . $merchant_salt;
$paytr_token=base64_encode(hash_hmac('sha256', $hash_str, $merchant_key, true));
$post_vals=array(
'merchant_id'=>$merchant_id,
'utoken'=>$utoken,
'paytr_token'=>$paytr_token
);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/capi/list");
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 CAPI List connection error. err:".curl_error($ch));
curl_close($ch);
$result=json_decode($result,1);
if($result['status']=='error')
die("PAYTR CAPI list failed. Error:".$result['err_msg']);
else
print_r($result);
?>
List Card Service sample codes Click to download .