Learn how to integrate Paycrypt payments into your website
https://example.com
import { NextResponse } from "next/server"; import prisma from "../../lib/db"; interface PaymentWebhookPayload { id: string; merchant_id: string; currency: string; amount: number; amount_usd: number; tx_hash: string; address: string; sender_address: string; status: string; network: string; payment_link_id: string; checkout_session_id: string; is_paid_to_merchant: boolean; confirmed_at: string | null; created_at: string; expires_at: string; webhook_secret: string; Webhook: string; txID: string; hash: string; timestamp: string; email: string; } export async function POST(request: Request) { try { // Verify webhook signature const signature = request.headers.get("X-Webhook-Signature"); const webhookSecret = process.env.WEBHOOK_SECRET; if (!signature || !webhookSecret || signature !== webhookSecret) { return NextResponse.json( { error: "Invalid webhook signature" }, { status: 401 } ); } const payload = await request.json() as PaymentWebhookPayload; // Find the user by email and update their status to Pro const user = await prisma.user.update({ where: { email: payload.email }, data: { isPro: true, }, }); if (!user) { return NextResponse.json({ error: "User not found" }, { status: 404 }); } return NextResponse.json({ success: true, message: "User upgraded to Pro successfully", paymentId: payload.id }); } catch (error) { console.error("Error processing webhook:", error); return NextResponse.json( { error: "Failed to process webhook" }, { status: 500 } ); } }
X-Webhook-Signature
<a href="https://sandbox.pay.paycrypt.tech/link/1c90b6bc-8031-406c-98cd-812668383559?email=yfw111realone@gmail.com" class="paycrypt-button"> Pay Now </a>
pnpm add @paycrypt/sdk
import { PaycryptButton } from '@paycrypt/sdk'; function CheckoutPage() { return ( <PaycryptButton amount={100} currency="USD" onSuccess={(payment) => { console.log('Payment successful:', payment); }} onError={(error) => { console.error('Payment failed:', error); }} /> ); }