This guide provides a detailed exploration of API Requests , complete with request/response examples, parameters and their descriptions, response codes, and robust error handling mechanisms. Let’s dive into the essence of FrillPay’s API integration.
API Endpoints: A Detailed Description
Initiating a Payment Transaction
Initiates a payment transaction, marking the beginning of a seamless payment experience.
Parameters:
- apiKey (string): Your unique API Key (How to get it?)
- reqestedId (string): You will receive response with this ID
- fName (string): Your customer’s first name
- lName (string): Your customer’s last name
- email (string): The email address of the customer initiating the payment
- amount (number): The amount to be charged from your customer
- currency (string): Enter supported currency (USD)
- accountno (string): The unique identifier of your customer
These parameters form the backbone of your API requests, guiding FrillPay’s payment gateway to process transactions securely and efficiently.
Request Example:
// Preparing data to send to the Payment Gateway (FrillPay)
$data = array(
'apiKey' => encryptData($apiKey, $token),
'reqestedId' => encryptData($reqestedId, $token),
'fName' => encryptData("John", $token),
'lName' => encryptData("Doe", $token),
'email' => encryptData("[email protected]", $token),
'amount' => encryptData(100.00, $token),
'accountno' => encryptData($accountno, $token),
'currency' => encryptData($currency, $token),
);
Response Example:
// Function to decrypt data using AES decryption
function decryptData($data, "YOUR-TOKEN-KEY-HERE") {
// Decrypt logic here
}
// Getting response back from the payment gateway
if(isset($_GET['status']) && isset($_GET['message'])) {
echo $status = decryptData($_GET['status'],"YOUR-TOKEN-KEY-HERE");
echo $message = decryptData($_GET['message'],"YOUR-TOKEN-KEY-HERE");
echo $reqestedId = decryptData($_GET['reqestedId'],"YOUR-TOKEN-KEY-HERE");
echo $trId = decryptData($_GET['transaction_id'],"YOUR-TOKEN-KEY-HERE");
echo $amount = decryptData($_GET['amount'],"YOUR-TOKEN-KEY-HERE");
echo $receivableAmount = decryptData($_GET['receivableAmount'],"YOUR-TOKEN-KEY-HERE");
} else {
echo "No response";
}
Response Codes:
- 200 OK: The request was successful, and the payment was processed.
- 400 Bad Request: The request parameters were invalid or incomplete.
- 401 Unauthorized: The authentication credentials provided were invalid or missing.
- 403 Forbidden: The server understood the request, but the server refuses to authorize it.
- 404 Not Found: The requested resource could not be found on the server.
- 500 Internal Server Error: An error occurred on the server-side.
Handling Errors: Best Practices
If an error occurs during the API request, FrillPay will return an appropriate error response along with an error code and a descriptive message. It’s recommended to handle errors gracefully and provide meaningful feedback to users.
Stay tuned as our API integration series unfolds, bringing you deeper insights into integration guides, testing in the sandbox environment, security measures, and error handling best practices. FrillPay’s API is not just a gateway; it’s a seamless passage to a world of secure and swift online transactions.