npm install @link2pay/sdkimport { Link2PayClient } from "@link2pay/sdk";
const client = new Link2PayClient({
apiKey: process.env.LINK2PAY_API_KEY!,
environment: "sandbox"
});Use environment: "production" for live traffic.
const paymentLink = await client.paymentLinks.create({
amount: "49.00",
currency: "USD",
reference: "order_2048",
customerEmail: "buyer@example.com",
redirectUrl: "https://merchant.example/checkout/success"
});
console.log(paymentLink.id, paymentLink.url);const fetched = await client.paymentLinks.retrieve(paymentLink.id);
console.log(fetched.status, fetched.settlementStatus);import { verifyWebhookSignature } from "@link2pay/sdk/webhooks";
const isValid = verifyWebhookSignature({
payload: rawBody,
signatureHeader: request.headers["link2pay-signature"],
secret: process.env.LINK2PAY_WEBHOOK_SECRET!
});
if (!isValid) {
throw new Error("Invalid webhook signature");
}