Arama Yap Mesaj Gönder
Biz Sizi Arayalım
+90
X
X
X
X

Knowledge Base

Homepage Knowledge Base General Creating Payment Links with PayTR L...

Bize Ulaşın

Konum Halkalı merkez mahallesi fatih cd ozgur apt no 46 , Küçükçekmece , İstanbul , 34303 , TR

Creating Payment Links with PayTR Link API: A Step-by-Step Guide

With PayTR Link API, you can create links for your customers to receive payments directly. This method makes it easy to receive online payments for products, services, or invoice collections, even if you don't have an e-commerce site.

In this article, we will explain how to create a payment link step by step with the PayTR Link API and detail the data to be used with sample codes. We also provide backlinks to other related integration steps:


PayTR Link API Usage Steps

1. Token Creation

To create a token, you must calculate a hash value from your product/service information.

Required Fields:

  • name (between 4-200 characters)

  • price (integer multiplied by 100)

  • currency (TL, USD, EUR, GBP, RUB)

  • max_installment (between 2-12)

  • link_type ("product" or "collection")

  • lang ("tr" or "en")

  • merchant_key and merchant_salt (You can get it from your store panel)

Token Calculation Example (PHP):

$required = $name.$price.$currency.$max_installment.$link_type.$lang;
$paytr_token = base64_encode(hash_hmac('sha256', $required.$merchant_salt, $merchant_key, true));

2. Payment Link Creation (POST Request)

A POST request is sent to the following address using the token and other information:

https://www.paytr.com/odeme/api/link/create

POST Parameters:

  • merchant_id

  • name

  • price

  • currency

  • max_installment

  • link_type

  • lang

  • paytr_token

  • (Optional: min_count, max_count, expiry_date, callback_link, callback_id, get_qr, debug_on)

PHP Example POST:

$post_vals = array(
    'merchant_id' => $merchant_id,
    'name' => $name,
    'price' => $price,
    'currency' => $currency,
    'max_installment' => $max_installment,
    'link_type' => $link_type,
    'lang' => $lang,
    'paytr_token' => $paytr_token,
    'debug_on' => 1
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/link/create");
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. Incoming Response

The response comes in JSON format:

  • status: success / error / failed

  • id: unique link ID

  • link: the generated payment link

  • reason: error description (in case of error)

Example Successful Response:

{
  "status":"success",
  "id":"NB2Zlz3",
  "link":"https://www.paytr.com/link/NB2Zlz3"
}

Optional Features

  • get_qr: If you send 1, you can also get the QR code of the link in Base64 format.

  • expiry_date: You can specify the expiration date of the link.

  • callback_link: The URL to be notified of the payment result.

  • max_count: You can set a specific stock quantity limit.


Link Deletion (Delete API)

You can also use the PayTR Link Delete API to delete multiple links at once. For this, you perform the deletion process by sending the "id" values.

PHP Deletion Example:

$hash_str = $id . $merchant_id . $merchant_salt;
$paytr_token = base64_encode(hash_hmac('sha256', $hash_str, $merchant_key, true));

$post_vals = array(
    'merchant_id' => $merchant_id,
    'id' => $id,
    'paytr_token' => $paytr_token,
    'debug_on' => 1
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/link/delete");
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));

Conclusion: Fast and Easy Collection with PayTR Link API

You can create sales or collection links in minutes using the PayTR Link API. You can offer your customers a professional payment experience with systematic use and security measures.

Be sure to review the following articles for more information and related integration guides:

 

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(948 times viewed / 132 people found it helpful)

Call now to get more detailed information about our products and services.

Top