Step 1: Log in to the merchant portal and create a new LinkPay link.
More information about how to create a new LinkPay link can be found here.
Step 2: In the LinkPay settings, enable the fields you want to customize dynamically (e.g., amount, name, email) and mark them as "URL Changeable".
Step 3: Save the LinkPay configuration.
Step 4: Use the following PHP code to programmatically generate the payment URL with dynamic parameters:
php
<?php
$linkpay_prefix = 'https://payment.sandbox.lhv.ee/lp/'; // Base LinkPay URL
$api_secret = 'apisecret123456789'; // API secret from portal settings
// Define the parameters to be included in the payment link
$params = [
'transaction_amount' => '10',
'customer_name' => 'Your Customer Name',
'customer_email' => 'customer@email.com',
'order_reference' => 'YourOrderReference',
'linkpay_token' => '123abcd' // Token from the LinkPay setup
];
// Convert parameters to a query string
$query = http_build_query($params);
// Replace "+" with "%20" for proper URL encoding
$query = str_replace("+", "%20", $query);
// Generate the HMAC signature
$hmac = hash_hmac('sha256', $query, $api_secret);
// Combine everything into a final URL
$url = "${linkpay_prefix}?${query}&hmac=${hmac}";
// Output the link
echo $url;
?>
Step 5: Copy the generated URL.
Step 6: Send the link to your customer to complete the payment.
