To complete the use of PayTR Link API and ensure payment collection, Callback Service integration is critical. In this article, we will explain step by step how to receive successful payment notifications for PayTR payment links, hash verification, and correct integration recommendations.
We also recommend that you take a look at these guides for other PayTR API steps:
-
Creating a Payment Link with PayTR Link API: Step-by-Step Guide
-
PayTR iFrame API Integration: Step-by-Step Informative Guide
-
PayTR Notification URL (Step 2) Integration: Payment Result Confirmation Guide
What is PayTR Link API Callback?
-
It only works when a successful payment is made.
-
It POSTs to the callback_url address you specified in the Create request.
-
It is separate from the Notification URL in the Merchant Panel and only works for the Link API.
Information: If you did not specify a callback_url when creating the link, you do not need to do this integration.
POST Parameters Received with Callback
Parameter | Description |
---|---|
hash | Used to check the accuracy of the notification values |
merchant_oid | Order number (created by PayTR) |
status | success (always comes for success) |
total_amount | The actual amount collected (in cents) |
payment_amount | Order amount |
payment_type | Payment type (card, bex, etc.) |
currency | Currency (TL, USD, EUR, GBP, RUB) |
callback_id | ID you specified when creating the link |
merchant_id | Your merchant number |
test_mode | Indicates whether it was done in test mode |
Callback URL Integration Steps
1. Get POST Data
$post = $_POST;
2. Perform Hash Verification
$merchant_key = 'Your_Merchant_Key';
$merchant_salt = 'Your_Merchant_Salt';
$hash = base64_encode( hash_hmac('sha256', $post['callback_id'].$post['merchant_oid'].$merchant_salt.$post['status'].$post['total_amount'], $merchant_key, true) );
if( $hash != $post['hash'] ) {
die('PAYTR notification failed: bad hash');
}
3. Payment Confirmation Procedures
if( $post['status'] == 'success' ) {
// Confirm the payment in your database
// You can send SMS/E-mail notifications to the customer
}
4. Be Sure to Return OK Response
echo "OK";
exit;
IMPORTANT: If the "OK" response is not sent, the PayTR system considers the notification unsuccessful and may send it repeatedly.
Common Mistakes in Callback Service
-
Returning a non-OK output.
-
Not doing POST hash verification.
-
Trying to use session variables.
-
Processing the same order repeatedly in multiple notifications.
Test Stages
-
Create a Payment Link (callback_url defined).
-
Make a test payment.
-
If a notification is coming to your Callback URL and the "OK" response is returned correctly, the Transaction will appear as "Successful" in the PayTR Merchant Panel.
Important Note:
If you are using SSL, save the callback_url with the HTTPS protocol.
Conclusion: Seamless Payment Confirmation with PayTR Link API Callback Service
The Callback URL service must be implemented correctly so that payments made via Link API can be professionally integrated into your system. The entire process can be carried out without problems with hash verification, OK response, and idempotent (counting recurring transactions as one) structure.
Related Informative Articles:
-
Creating a Payment Link with PayTR Link API: Step-by-Step Guide
-
PayTR iFrame API Integration: Step-by-Step Informative Guide
-
PayTR Notification URL (Step 2) Integration: Payment Result Confirmation Guide