Webhook Integration
Overview
PayRam provides webhook functionality to notify your backend server whenever a payment is received from your customers. This ensures real-time updates and automated processing of transactions.
Your backend server must create a webhook endpoint to receive these notifications. PayRam will send a GET request to this endpoint with payment details.
Webhook Endpoint
Merchants need to create an API endpoint in their backend to receive webhook notifications.
📌 Example Webhook URL:
Ensure that this endpoint is publicly accessible and capable of handling incoming GET requests.
Payment Data Structure
When a customer makes a payment to the PayRam server, PayRam sends the payment details in a JSON payload to your webhook.
Sample Webhook Request:
Project API-Key validation
The API-Key
will be passed in the header of the webhook API call. This API key corresponds to the project API key, which must be validated on your end before processing any customer credits or performing any operations on the received data.
Payment Statuses
The payment_state
field in the webhook payload represents the current status of the payment:
Status
Description
OPEN
Payment has not been completed.
CANCELED
The payment link has expired.
FILLED
The full requested amount has been paid.
PARTIALLY_FILLED
A partial payment has been made.
OVER_FILLED
An excess payment was received.
📌 For FILLED, PARTIALLY_FILLED, and OVER_FILLED statuses, the following fields will be populated:
filled_amount
(Supports decimals)filled_amount_in_usd
(USD equivalent of the paid amount)
Example for a FILLED payment:
Handling Webhook Requests
Your backend should:
✅ Accept incoming GET requests from PayRam.
✅ Parse the JSON payload.
✅ Validate the received payment data.
✅ Store or process the payment details as needed.
✅ Respond with HTTP 200 OK to acknowledge receipt.
Example Implementation in Node.js (Express)
Best Practices
🔹 Secure your webhook endpoint: Use API keys, IP whitelisting, or signature validation to prevent unauthorized access.
🔹 Log all webhook events: Store webhook requests in your logs for debugging and tracking purposes.
🔹 Retry handling: If your server is down, implement a retry mechanism to reprocess failed webhook events.
🔹 Confirm webhook receipt: Always respond with an HTTP 200 status code after successful processing.
Next Steps
Implement the webhook in your backend.
Test webhook handling using PayRam’s sandbox/test environment.
Monitor webhook events and logs to ensure smooth payment tracking.
Last updated