DMP — Payment Request API
The DMP API allows you to send payment requests to your customers via SMS or Email. The customer receives a link they can click to pay using their preferred method.
!!! warning
The DMP API operates in live mode only (error 4001 is returned if
keys are not in live mode). Use your production keys.
Creating a Payment Request
from paydunya import DMP, PaydunyaClient
client = PaydunyaClient(
master_key="your-live-master-key",
private_key="live_private_...",
token="your-live-token",
mode="live",
)
dmp = DMP(client)
result = dmp.create(
amount=1250, # between 200 and 3,000,000
recipient_email="customer@example.com",
recipient_phone="771234567", # at least one of email/phone required
support_fees=True, # True = you pay the fees, False = customer pays
send_notification=True, # True = PayDunya sends the SMS/Email
)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount |
int/float | Yes | Amount between 200 and 3,000,000 |
recipient_email |
str | At least one | Recipient's email address |
recipient_phone |
str | At least one | Recipient's phone number |
support_fees |
bool | No (default False) |
True = you absorb fees, False = customer pays |
send_notification |
bool | No (default True) |
True = PayDunya sends the message, False = you handle it |
Response with send_notification=True
{
"success": true,
"message": "Your payment request has been sent successfully."
}
Response with send_notification=False
{
"response-code": "00",
"reference_number": "4190239470044",
"url": "https://pydu.me/k5Rrrj",
"description": "Your payment request has been created successfully"
}
When send_notification=False, PayDunya returns a short URL and a reference number.
You can include these in your own custom SMS or Email messages.
Checking Status
status = dmp.check_status("4190239470044")
print(status["status"]) # pending, completed, or failed
Response
{
"response-code": "00",
"status": "pending"
}
Status values:
- pending — payment not yet made
- completed — payment received successfully
- failed — payment attempt failed
Error Codes
| Code | Meaning |
|---|---|
00 |
Success |
4000 |
Malformed request (missing keys or recipient) |
4001 |
Integration mode must be live |
1000 |
Invalid API keys |
4004 |
Payment request not found (on status check) |