MRNPay integration
Create request links, verify outcomes, and retry safely when a connection fails.
Create a request link
Send the request from your server. Store your site’s API key in an environment variable. The customer enters the amount on the request screen.
JavaScriptServer-side
const response = await fetch(
'https://api.yasfinans.com/api/v1/checkout/payment-links',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': process.env.MRNPAY_SITE_API_KEY,
},
body: JSON.stringify({
orderReference: order.reference,
idempotencyKey: order.paymentAttemptId,
currency: 'TRY',
customerReference: customer.id,
}),
signal: AbortSignal.timeout(15_000),
},
);
if (!response.ok) throw new Error(`MRNPay: ${response.status}`);
const { checkoutUrl } = await response.json();
return new Response(null, { status: 303, headers: { Location: checkoutUrl } });Use your own order and customer records. Use the returned link as provided and mask the link token in your logs.
Verify the outcome notification
X-Finbex-Timestamp · X-Finbex-Signature
Check both headers before parsing the raw request body. The signed content is the timestamp, a period, and the raw body.
- Verify the HMAC-SHA256 signature with the key in your site settings.
- Match the outcome to your own order and customer records.
- Store the unique notification ID and apply each update once.
- Return a successful HTTP response after the update is stored.
Retry the same attempt after a network error
Keep the same request body and idempotencyKey for the same attempt. Generate a new key for a new attempt.
Separate test and production
Use a test account and test records. For production, configure the relevant site’s key and notification URL.
Request a demo