Introduction
Welcome to the AffxPay API documentation. Our API suite allows you to process payments, check statuses, query account balances, and send SMS notifications. We also support webhook events to keep you updated on payment statuses in real time.
Authentication
API Key
All API requests must include your API key in the request header to authenticate access to AffxPay’s services. Obtain your API key upon registration.
https://affxpay.com/api/FUNCTION?api=YOUR_API_KEYParameters:
- YOUR_API_KEY : API Key.
API Endpoints
1. Payment API
Initiate a new payment request.
GET https://affxpay.com/api/pay?upi={UPI}&amount={amount}&comment={comment}&api=YOUR_API_KEYParameters:
- upi : User Upi Id.
- amount : Amount you want to pay.
- comment : Remark for the payment. (24 char max)
{ "status":"processing", "message":"Payment Processing Will Get Reflected in 1 Hour", "ip":"152.59.49.161", "time":1730819789, "upi":"1234567890@upi", "amount": 10, "trx_id":"KB7OMLN5CS248WAZP6GUHTQ0", "bank_trx_id":"tr_o71WkUS2cVm1mYnHr3jxNaMiP", "closing_balance":"9989.70" }
2. Payment Status API
Retrieve the status of a specific payment.
GET https://affxpay.com/api/fetch-balance?api=YOUR_API_KEYParameters:
- transaction_id (string): Unique ID of the transaction.
{ "status":"success", "time":1730820097, "upi":"1234567890@upi", "amount":"10", "trx_id":"KB7OMLN5CS248WAZP6GUHTQ0", "bank_trx_id":"tr_o71WkUS2cVm1mYnHr3jxNaMiP" }
3. Account Balance API
Get the current balance in your AffxPay account.
GET https://affxpay.com/api/fetch-balance?api=YOUR_API_KEYSample Response:
{ "status":"success", "balance":"10000", "ip":"152.59.49.161", "time":1730820341 }
4. SMS API
Send an SMS notification to a user.
GET Adding SoonParameters:
- phone (string): Recipient's phone number.
- camp (string): Camp Name
{ "status":"success", "message":"Message Sent Successfully", "ip":"152.58.41.224", "time":1730930774, "trx_id":null, "mobile_no":"6263852598", "closing_balance":9999.70 }
Webhooks
1. Payment Requested Webhook
Triggered when a new payment request is initiated.
{ "event": "payment_requested", "transaction_id": "123456789", "amount": 100, "currency": "INR", "beneficiary_upi": "johndoe@upi", "status": "pending", "created_at": "2024-11-05T09:00:00Z" }
2. Payment Status Updated Webhook
Triggered when the status of a payment request changes.
{ "event": "payment_status_updated", "transaction_id": "123456789", "status": "completed", "updated_at": "2024-11-05T10:00:00Z" }
Api Failure Reasons
Here are some common reasons why API requests may fail. Each failure type includes an error code and a message to help you diagnose and resolve issues efficiently.
1. Invalid API Key
If the API key provided in the request is incorrect or has expired, the following error will be returned.
{ "error_code": "401", "error_message": "Invalid API Key. Please check your API credentials." }
2. IP Not Whitelisted
Your request will be denied if it originates from an IP address that has not been added to the whitelist. Ensure that all IPs used for requests are registered in your account settings.
{ "status":"failed", "message":"Ip Not WhiteListed", "ip":"152.59.49.161", "time":1730819619, "trx_id":null }
3. Missing Required Fields
All required fields must be included in the request payload. Omitting any required parameter will result in a failure response with the missing field specified.
{ "error_code": "400", "error_message": "Missing required fields: [field_name]" }
4. Insufficient Balance
If your account balance is too low to process the transaction, a failure response will indicate the issue. Please ensure you have sufficient balance before making a request.
{ "error_code": "402", "error_message": "Insufficient balance. Please recharge your account." }