Integration Guides

Step-by-step guides to integrate Davspay into your application

Quick Start Guide

Get started with Davspay in under 10 minutes. This guide will walk you through creating your first payment integration.

Create Your Account

Sign up for a Davspay account at dashboard.davspaysolution.com. You'll receive instant access to your test API keys.

Get Your API Keys

Navigate to Settings → API Keys in your dashboard. You'll see two sets of keys:

  • Test Keys: For development and testing (begins with test_)
  • Live Keys: For production use (begins with live_)
Important: Never expose your API keys in client-side code or public repositories. Always use them server-side only.

Install the SDK

Install the Davspay SDK for your preferred language:

# Node.js
npm install @davspay/node-sdk

# Python
pip install davspay

# PHP
composer require davspay/sdk

Create Your First Payment

Initialize the SDK and create a payment:

const Davspay = require('@davspay/node-sdk');

// Initialize with your test API key
const davspay = new Davspay({
  apiKey: 'test_your_key_here',
  environment: 'sandbox'
});

// Create a payment
const payment = await davspay.payments.create({
  amount: 100000, // ₹1000 in paise
  currency: 'INR',
  customer: {
    email: 'customer@example.com',
    phone: '+919876543210',
    name: 'John Doe'
  },
  description: 'Test Payment',
  callback_url: 'https://yoursite.com/callback'
});

// Redirect customer to payment URL
console.log(payment.payment_url);

Handle Payment Callback

After payment, the customer will be redirected to your callback_url with payment status:

app.get('/callback', async (req, res) => {
  const { payment_id, status } = req.query;

  // Verify payment status from our server
  const payment = await davspay.payments.retrieve(payment_id);

  if (payment.status === 'captured') {
    // Payment successful - update your database
    res.send('Payment successful!');
  } else {
    // Payment failed or pending
    res.send('Payment failed or pending');
  }
});
Congratulations! You've successfully integrated Davspay payments. Test your integration thoroughly before going live.

Webhook Integration

Webhooks allow you to receive real-time notifications about payment events. This is the recommended way to handle payment confirmations.

Configure Webhook URL

In your Davspay dashboard, go to Settings → Webhooks and add your webhook endpoint URL. This should be a POST endpoint on your server that can receive JSON payloads.

Example: https://yoursite.com/webhooks/davspay

Implement Webhook Handler

Create an endpoint to receive webhook notifications:

const express = require('express');
const app = express();

app.post('/webhooks/davspay',
  express.json(),
  async (req, res) => {
    // Get signature from headers
    const signature = req.headers['x-davspay-signature'];

    // Verify webhook signature
    const isValid = davspay.webhooks.verify(
      req.body,
      signature,
      process.env.WEBHOOK_SECRET
    );

    if (!isValid) {
      return res.status(400).send('Invalid signature');
    }

    // Process webhook event
    const { event, data } = req.body;

    switch (event) {
      case 'payment.captured':
        // Payment successful
        await handleSuccessfulPayment(data);
        break;

      case 'payment.failed':
        // Payment failed
        await handleFailedPayment(data);
        break;

      case 'refund.completed':
        // Refund processed
        await handleRefund(data);
        break;
    }

    // Return 200 to acknowledge receipt
    res.status(200).send('OK');
  }
);

Test Your Webhooks

Use the webhook testing tool in your dashboard to send test events to your endpoint. This helps you verify your integration before going live.

Best Practice: Always verify webhook signatures to ensure requests are coming from Davspay. Store webhook events in your database for audit trails and debugging.

Production Checklist

Before going live, make sure you've completed these essential steps:

  • Switch to Live API Keys: Replace test keys with live keys from your dashboard
  • Complete KYC: Submit your business documents for verification
  • Enable HTTPS: All production integrations must use HTTPS
  • Set Up Webhooks: Configure production webhook endpoints
  • Test Error Scenarios: Handle failed payments, network errors, and timeouts
  • Set Up Monitoring: Implement logging and monitoring for payment flows
  • Security Review: Never expose API keys, validate all webhooks, use HTTPS
Need Help? Our support team is available 24/7 at support@davspaysolution.com or call +91 97588 13335 for immediate assistance.