Link API SMS&EMAIL

1-) SENDING A SMS

Using this service, you can send the link of the page to your customer's phone number.

1- The token data is generated with the information below that must be sent.

2- A request is made to the create service (https://www.paytr.com/odeme/api/link/send-sms) along with the generated token and the fields that must be sent.

Required parameters for token creation

Field name / Type Description Mandatory Limitations & Notes
id (integer) Link API Returned value from Create method Yes -
merchant_id(integer) A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. Yes -
cell_phone(integer) Phone number to which you want to send the link Yes Number to send SMS. Must start with 05 and have 11 digits
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:

Field name / Type Description Mandatory Limitations
merchant_id (integer) Merchant number: Merchant number given to you by PayTR Yes -
id (integer) It is the value returned in the create method. Yes -
cell_phone(integer) Phone number you want to send the link to Yes The number to send the SMS. Must start with 05 and have 11 digits.
debug_on(int) Error message (Send as 1 for integration and test errors) No 0(closed) or 1(open)
paytr_token(string) 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. Evet HPlease check the sample codes for calculation



<?php

    $merchant_id    = 'AAAAAA';
    $merchant_key   = 'XXXXXXXXXXXXXXXX';
    $merchant_salt  = 'XXXXXXXXXXXXXXXX';

    $id             = "XXXYYY";         
    $cell_phone     = "05000000000";    
    $debug_on       = 1;                

    $paytr_token=base64_encode(hash_hmac('sha256', $id.$merchant_id.$cell_phone.$merchant_salt, $merchant_key, true));
    $post_vals=array(
        'merchant_id'       => $merchant_id,
        'id'                => $id,
        'cell_phone'        => $cell_phone,
        'debug_on'          => $debug_on,
        'paytr_token'       => $paytr_token
    );

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/link/send-sms");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1) ;
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $result = @curl_exec($ch);

    if(curl_errno($ch))
        die("PAYTR LINK SEND SMS API request timeout. err:".curl_error($ch));

    curl_close($ch);

    $result=json_decode($result,1);

    if($result['status']=='error')
        die($result['err_msg']);
    elseif($result['status']=='failed')
        print_r($result);
    else
        print_r($result);

For Link API SMS&EMAIL service sample codes Click to download

2) SENDING AN E-MAIL

Using this service, you can send the link of the page to your customer's e-mail address.

1- The token data is generated with the information below that must be sent.

2- A request is made to the create service (https://www.paytr.com/odeme/api/link/send-email) along with the generated token and the fields that must be sent.

Required parameters for token creation

Field name / Type Description Mandatory Limitations & Notes
id (integer) Link API Returned value from Create method Yes -
merchant_id(integer) Merchant Number Yes Merchant number: Merchant number given to you by PayTR
email(string) Email information you want to send the link to Yes It can contain up to 100 characters
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:

Field name / Type Description Mandatory Limitations
merchant_id (integer) Merchant number: Merchant number given to you by PayTR Yes -
id (integer) It is the value returned in the create method. Yes -
email (string) Email information you want to send the link to Yes It can contain up to 100 characters
debug_on(int) Error message (Send as 1 for integration and test errors) No 0(closed) or 1(open)
paytr_token(string) 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. Evet HPlease check the sample codes for calculation



<?php

    $merchant_id    = 'AAAAAA';
    $merchant_key   = 'XXXXXXXXXXXXXXXX';
    $merchant_salt  = 'XXXXXXXXXXXXXXXX';

    $id             = "XXXYYY";         
    $email          = "test@mail.com";  
    $debug_on       = 1;                

    $paytr_token=base64_encode(hash_hmac('sha256', $id.$merchant_id.$email.$merchant_salt, $merchant_key, true));
    $post_vals=array(
        'merchant_id'       => $merchant_id,
        'id'                => $id,
        'email'             => $email,
        'debug_on'          => $debug_on,
        'paytr_token'       => $paytr_token
    );

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/link/send-email");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1) ;
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $result = @curl_exec($ch);

    if(curl_errno($ch))
        die("PAYTR LINK SEND MAIL API request timeout. err:".curl_error($ch));

    curl_close($ch);

    $result=json_decode($result,1);

    if($result['status']=='error')
        die($result['err_msg']);
    elseif($result['status']=='failed')
        print_r($result);
    else
        print_r($result);

For Link API SMS&EMAIL service sample codes Click to download.

3) RESPONS

Description Field name / Type Values
Response status (string) success, error or failed
Request description (in case of error) reason (string) Example: Process failed. Invalid id