EQGate

Integration Guide

Complete guide to integrating EQGate into your application

Integration Guide

A complete guide to integrating EQGate payment processing into your application.

Payment Flow

Customer → Your App → EQGate API → Blockchain
                ↑         ↓
                └── Webhook ←┘
  1. Customer initiates payment on your website
  2. Your server calls EQGate to create a deposit address
  3. Display the address to the customer
  4. Customer sends payment
  5. EQGate detects the deposit and sends webhook
  6. EQGate forwards funds to your wallet
  7. Your server marks the order as paid

Implementation

1. Create Payment Endpoint

// pages/api/create-payment.js
export default async function handler(req, res) {
  const { orderId, amount, chain, token } = req.body;
 
  const response = await fetch(
    `https://api.eqgate.com/v1/${chain}/${token}/create`,
    {
      method: 'POST',
      headers: {
        'X-API-Key': process.env.EQGATE_API_KEY,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        callback_url: `${process.env.BASE_URL}/api/webhook`,
        expected_amount: amount,
        metadata: { orderId },
        expires_in: 3600,
      }),
    }
  );
 
  const data = await response.json();
 
  // Store in database
  await db.payment.create({
    orderId,
    depositAddress: data.address_in,
    amount,
    status: 'pending',
  });
 
  res.json({
    address: data.address_in,
    chain: data.chain,
    token: data.token,
  });
}

2. Handle Webhooks

// pages/api/webhook.js
export default async function handler(req, res) {
  // Verify signature first!
  const event = req.body;
 
  if (event.event === 'deposit.completed') {
    await db.payment.update({
      where: { depositAddress: event.address },
      data: { status: 'completed' },
    });
 
    // Fulfill the order
    await fulfillOrder(event.metadata.orderId);
  }
 
  res.status(200).json({ received: true });
}

Security Checklist

  • Store API key in environment variables
  • Verify webhook signatures
  • Use HTTPS for webhook endpoint
  • Handle duplicate webhooks (idempotency)
  • Log raw webhook payloads for debugging

On this page