Validate Payment with IPN API Documentation
Instant Payment Notification (IPN) allows your server to listen for real-time payment events. When a payment is made or canceled, the system sends an HTTP POST request to your configured `ipn_url` with the payment details.
It is critical to validate the transaction notification to maintain security and ensure proper handling of payment statuses.
Key Points to Remember
- IPN Payload: The system sends a JSON payload with payment details when an event occurs.
- Security: Validate the IPN request, including headers and payload, to ensure authenticity.
- IPN Methods: Notifications are sent using the HTTP method you specify (
GET
,POST
,PUT
,DELETE
,PATCH
,OPTIONS
, andHEAD
). Default:POST
). - Status Management: Handle payment statuses (
PENDING
,FAILED
,COMPLETED
,CANCELED
) appropriately.
Example Payloads
1. Bank Payments
When a bank payment is initiated, the system sends the following payload to the ipn_url
:
status
: AlwaysPENDING
until confirmed manually or by subsequent updates.payment_method
: AlwaysBANK
until confirmed manually or by subsequent updates.
2. Mobile Banking Payments
For mobile banking payments (e.g., BKASH, ROCKET, NAGAD, UPAY, CELLFIN, TAP, OK_WALLET, IPAY), the payload is as follows:
payment_method
: AlwaysMOBILE_BANKING
until confirmed manually or by subsequent updates.mfs_payment_method
: Identifies the mobile financial service (BKASH
,ROCKET
,NAGAD
,UPAY
,CELLFIN
,TAP
,OK_WALLET
,IPAY
).mfs_payment_account_type
: Specifies the account type (PERSONAL
,AGENT
orMERCHANT
).status
: Can bePENDING
,FAILED
, orCOMPLETED
.
3. Canceled Payments
If the user cancels a payment, the payload is sent for both bank and mobile banking transactions:
- Status: Always
CANCELED
.
Validating the IPN
Security Steps
- Validate Headers: Confirm the
eazzpay-client-secret
to authenticate the source of the notification. - Check Payload Fields: Ensure all required fields are present and valid.
- Handle Status:
PENDING
: Store the payment details for further confirmation.COMPLETED
: Update your system to mark the payment as successful.CANCELED
: Handle the cancellation process.
Example Requests
Notes
- Always validate the
eazzpay-client-secret
header to ensure the notification's authenticity. - Log incoming notifications for debugging and record-keeping.
- Test the integration in a sandbox environment before going live.