Quickstart
Create your first payment with ShadhinPay in 5 minutes
Quickstart
This guide will help you create your first payment using the ShadhinPay API.
Step 1: Get Your API Keys
- Log in to your ShadhinPay Dashboard
- Navigate to Settings → API Keys
- Copy your Client ID, Business ID, and Secret Key
Never expose your Secret Key in client-side code or public repositories.
Step 2: Create a Payment
Make a POST request to create a new payment:
curl -X POST https://api.shadhinpay.com/api/v1/payments \
-H "Content-Type: application/json" \
-H "Client-Id: your_client_id" \
-H "Business-Id: your_business_id" \
-H "Secret-Key: your_secret_key" \
-d '{
"amount": 1000,
"currency": "BDT",
"customer_phone": "8801712345678",
"customer_name": "John Doe",
"callback_url": "https://yoursite.com/webhook",
"success_url": "https://yoursite.com/success",
"cancel_url": "https://yoursite.com/cancel"
}'const response = await fetch('https://api.shadhinpay.com/api/v1/payments', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Client-Id': 'your_client_id',
'Business-Id': 'your_business_id',
'Secret-Key': 'your_secret_key',
},
body: JSON.stringify({
amount: 1000,
currency: 'BDT',
customer_phone: '8801712345678',
customer_name: 'John Doe',
callback_url: 'https://yoursite.com/webhook',
success_url: 'https://yoursite.com/success',
cancel_url: 'https://yoursite.com/cancel',
}),
});
const data = await response.json();
console.log(data.data.payment_url);import requests
response = requests.post(
'https://api.shadhinpay.com/api/v1/payments',
headers={
'Content-Type': 'application/json',
'Client-Id': 'your_client_id',
'Business-Id': 'your_business_id',
'Secret-Key': 'your_secret_key',
},
json={
'amount': 1000,
'currency': 'BDT',
'customer_phone': '8801712345678',
'customer_name': 'John Doe',
'callback_url': 'https://yoursite.com/webhook',
'success_url': 'https://yoursite.com/success',
'cancel_url': 'https://yoursite.com/cancel',
}
)
data = response.json()
print(data['data']['payment_url'])Step 3: Redirect Customer
The API returns a payment_url. Redirect your customer to this URL to complete the payment:
{
"success": true,
"message": "Payment initiated successfully",
"data": {
"payment_id": "SP_1234567890",
"payment_url": "https://pay.shadhinpay.com/checkout/SP_1234567890",
"expires_at": "2024-01-01T12:15:00Z"
}
}Step 4: Handle the Webhook
When the payment completes, we'll send a POST request to your callback_url:
{
"event": "payment.completed",
"payment_id": "SP_1234567890",
"status": "COMPLETED",
"amount": 1000,
"currency": "BDT",
"transaction_id": "TXN_ABC123",
"timestamp": "2024-01-01T12:10:00Z"
}Always verify the webhook signature before processing. See the Webhooks guide for details.