Delete Card

DELETING THE USER CARD (CAPI DELETE)

1- To delete a card from a user's registered cards, make a request by sending the following parameters to https://www.paytr.com/odeme/capi/delete

Required parameters for token creation

Field name / Type Description Mandatory Limitations
utoken User Token: User specific token notified to you by PAYTR system in post-payment notification Yes -
ctoken Token information on your user's card from the CAPI LIST service 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)
ctoken (string) Yes Card Token: The token that identifies the user's registered card.


2- The values in the table below will return to JSON format. You can inform your user according to the response.

Variable / Type Explanation Possible / Sample Values
status (string) Status: Indicates that the card deletion request made was successful or failed. success or error
err_msg (string) Error Message: If the request is unsuccessful, the error reason is returned in err_msg Example: No card or previously deleted


    <?php

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

    $utoken = "";

    $ctoken = "";

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

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/capi/delete");
    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 Delete connection error. err:".curl_error($ch));

    curl_close($ch);

    $result=json_decode($result,1);

    if($result['status']=='success')
        echo "Kart silindi!";
    else
        die("PAYTR CAPI Delete failed. Error:".$result['err_msg']);

    ?>

Delete Card Service sample codes Click to download.