Step-by-step guides to integrate Pecify into your application
Get started with Pecify in under 10 minutes. This guide will walk you through creating your first payment integration.
Sign up for a Pecify account at dashboard.pecifysolution.com. You'll receive instant access to your test API keys.
Navigate to Settings → API Keys in your dashboard. You'll see two sets of keys:
Install the Pecify SDK for your preferred language:
# Node.js npm install @pecify/node-sdk # Python pip install pecify # PHP composer require pecify/sdk
Initialize the SDK and create a payment:
const Pecify = require('@pecify/node-sdk');
// Initialize with your test API key
const pecify = new Pecify({
apiKey: 'test_your_key_here',
environment: 'sandbox'
});
// Create a payment
const payment = await pecify.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);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 pecify.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');
}
});Webhooks allow you to receive real-time notifications about payment events. This is the recommended way to handle payment confirmations.
In your Pecify 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.
Create an endpoint to receive webhook notifications:
const express = require('express');
const app = express();
app.post('/webhooks/pecify',
express.json(),
async (req, res) => {
// Get signature from headers
const signature = req.headers['x-pecify-signature'];
// Verify webhook signature
const isValid = pecify.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');
}
);Use the webhook testing tool in your dashboard to send test events to your endpoint. This helps you verify your integration before going live.
Before going live, make sure you've completed these essential steps: