S
ShadhinPay Docs

Payments API

Create, retrieve, and manage payments using the ShadhinPay API

Payments API

The Payments API allows you to create and manage payment transactions.

Create Payment

Creates a new payment and returns a checkout URL.

POST /payments

Request Body

FieldTypeRequiredDescription
amountnumberYesPayment amount in the smallest currency unit
currencystringYesCurrency code (e.g., "BDT")
customer_phonestringYesCustomer's phone number
customer_namestringNoCustomer's name
customer_emailstringNoCustomer's email
callback_urlstringYesURL for webhook notifications
success_urlstringNoRedirect URL after successful payment
cancel_urlstringNoRedirect URL if payment is cancelled
metadataobjectNoCustom key-value pairs

Example Request

cURL
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": 1500,
    "currency": "BDT",
    "customer_phone": "8801712345678",
    "customer_name": "John Doe",
    "customer_email": "john@example.com",
    "callback_url": "https://yoursite.com/webhook",
    "success_url": "https://yoursite.com/success",
    "cancel_url": "https://yoursite.com/cancel",
    "metadata": {
      "order_id": "ORD-12345",
      "product": "Premium Plan"
    }
  }'

Example Response

201 Created
{
  "success": true,
  "message": "Payment initiated successfully",
  "data": {
    "payment_id": "SP_1234567890",
    "status": "INITIATED",
    "amount": 1500,
    "currency": "BDT",
    "payment_url": "https://pay.shadhinpay.com/checkout/SP_1234567890",
    "expires_at": "2024-01-01T12:15:00Z",
    "created_at": "2024-01-01T12:00:00Z"
  }
}

Get Payment

Retrieves details of a specific payment.

GET /payments/{payment_id}

Path Parameters

ParameterTypeDescription
payment_idstringThe unique payment identifier

Example Request

cURL
curl -X GET https://api.shadhinpay.com/api/v1/payments/SP_1234567890 \
  -H "Client-Id: your_client_id" \
  -H "Business-Id: your_business_id" \
  -H "Secret-Key: your_secret_key"

Example Response

200 OK
{
  "success": true,
  "data": {
    "payment_id": "SP_1234567890",
    "status": "COMPLETED",
    "amount": 1500,
    "currency": "BDT",
    "customer_phone": "8801712345678",
    "customer_name": "John Doe",
    "transaction_id": "TXN_ABC123",
    "payment_method": "bkash",
    "completed_at": "2024-01-01T12:05:00Z",
    "created_at": "2024-01-01T12:00:00Z",
    "metadata": {
      "order_id": "ORD-12345",
      "product": "Premium Plan"
    }
  }
}

List Payments

Retrieves a paginated list of payments for your business.

GET /payments

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Items per page (max 100)
statusstring-Filter by status
from_datestring-Start date (ISO 8601)
to_datestring-End date (ISO 8601)

Example Request

cURL
curl -X GET "https://api.shadhinpay.com/api/v1/payments?status=COMPLETED&limit=10" \
  -H "Client-Id: your_client_id" \
  -H "Business-Id: your_business_id" \
  -H "Secret-Key: your_secret_key"

Example Response

200 OK
{
  "success": true,
  "data": {
    "payments": [
      {
        "payment_id": "SP_1234567890",
        "status": "COMPLETED",
        "amount": 1500,
        "currency": "BDT",
        "created_at": "2024-01-01T12:00:00Z"
      }
    ],
    "pagination": {
      "current_page": 1,
      "total_pages": 5,
      "total_items": 48,
      "items_per_page": 10
    }
  }
}

Refund Payment

Creates a refund for a completed payment.

POST /payments/{payment_id}/refund

Path Parameters

ParameterTypeDescription
payment_idstringThe payment to refund

Request Body

FieldTypeRequiredDescription
amountnumberNoPartial refund amount (defaults to full)
reasonstringNoReason for the refund

Example Request

cURL
curl -X POST https://api.shadhinpay.com/api/v1/payments/SP_1234567890/refund \
  -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": 500,
    "reason": "Customer requested partial refund"
  }'

Example Response

200 OK
{
  "success": true,
  "message": "Refund initiated successfully",
  "data": {
    "refund_id": "RF_9876543210",
    "payment_id": "SP_1234567890",
    "amount": 500,
    "status": "PROCESSING",
    "created_at": "2024-01-02T10:00:00Z"
  }
}

Payment Statuses

StatusDescription
INITIATEDPayment created, waiting for customer
PROCESSINGCustomer is completing payment
COMPLETEDPayment successful
FAILEDPayment failed
CANCELLEDPayment cancelled by customer
EXPIREDPayment link expired
REFUNDEDPayment was refunded

On this page