PayTR Link API not only creates payment links but also allows you to deliver these links to your customers via SMS or Email. This article explains the PayTR Link API SMS and Email sending services in detail, supported by sample codes. We also teach correct integration and common mistakes.
Related Guides:
-
Creating Payment Links with PayTR Link API: Step-by-Step Guide
-
PayTR Link API Callback Service: Payment Result Notification and Integration Guide
-
PayTR iFrame API Integration: Step-by-Step Informative Guide
1) PayTR Link API SMS Service
You can send payment link SMS directly to your customers via their mobile phone number.
Required Fields for Token Generation:
-
id: The ID you created the link with
-
merchant_id: Your Merchant ID
-
cell_phone: 11-digit number starting with 05
-
merchant_salt & merchant_key: From your merchant panel
Token Calculation (PHP Example):
$paytr_token = base64_encode(hash_hmac('sha256', $id.$merchant_id.$cell_phone.$merchant_salt, $merchant_key, true));
POST Request Output:
$post_vals = array(
'merchant_id' => $merchant_id,
'id' => $id,
'cell_phone' => $cell_phone,
'debug_on' => 1,
'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);
$result = curl_exec($ch);
curl_close($ch);
print_r(json_decode($result, true));
Returned Values:
-
status: success / error / failed
-
reason: Error message (if any)
2) PayTR Link API Email Service
You can also send the payment link to your customers via Email instead of SMS.
Required Fields for Token Generation:
-
id: Link ID
-
merchant_id: Your Merchant ID
-
email: Recipient email address (max 100 characters)
-
merchant_salt & merchant_key
Token Calculation (PHP Example):
$paytr_token = base64_encode(hash_hmac('sha256', $id.$merchant_id.$email.$merchant_salt, $merchant_key, true));
POST Request Output:
$post_vals = array(
'merchant_id' => $merchant_id,
'id' => $id,
'email' => $email,
'debug_on' => 1,
'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);
$result = curl_exec($ch);
curl_close($ch);
print_r(json_decode($result, true));
3) Common Mistakes and Solutions
Error Status | Reason | Solutions |
---|---|---|
status: error | Incorrect token calculation | Check the hash generation formula |
SMS not sending | Phone number does not start with 05 or is not 11 digits | Pay attention to the format |
Email not sending | Email address is incorrect or character limit exceeded | Verify the email address |
CURL timeout | Server firewall or SSL settings are blocking | Check SSL settings |
4) Sample Successful Responses
For SMS:
{
"status":"success"
}
For Email:
{
"status":"success"
}
5) Recommendations
-
Add double-click control for SMS sending (to prevent multiple sends to one number).
-
Perform MX record and blacklist checks for email sending.
-
Always verify the incoming JSON data with the "status" and "reason" fields.
-
Use "debug_on" = 1 in test mode while developing the integration.
Conclusion: Increase Your Sales with PayTR Link API SMS and Email Sending
PayTR Link API SMS and Email services offer your customers an easy, fast, and direct way to make payments. With regular use, you can increase your collections by up to 30%.
Related Resources:
-
Creating Payment Links with PayTR Link API: Step-by-Step Guide
-
PayTR Link API Callback Service: Payment Result Notification and Integration Guide
-
PayTR iFrame API Integration: Step-by-Step Informative Guide