FreemoPay PHP is a simple and intuitive service class to easily integrate the FreemoPay payment system into your PHP applications.
- Make Payments: Process transactions directly through FreemoPay.
- Check Payment Status: Verify the status of a specific payment.
- PHP 7.4 or higher.
- FreemoPay credentials (username, password, and API URL).
- Laravel (completely optional, just that i love it 😆😁).
- Copy the file
app/services/FreemoPayService.phpinto your project. - Adjust the namespace according to your project's structure.
Before using the service, initialize it with your FreemoPay credentials:
$freemoPayService = new FreemoPayService();
$freemoPayService->init(
env('FREEMOPAY_USER'), // Your FreemoPay username
env('FREEMOPAY_PASSWORD'), // Your FreemoPay password
env('FREEMOPAY_URL') // The API base URL
);To process a payment using the FreemoPay service, follow this example:
$freemoPayService = new FreemoPayService();
$freemoPayService->init(
env('FREEMOPAY_USER'), // Your FreemoPay username
env('FREEMOPAY_PASSWORD'), // Your FreemoPay password
env('FREEMOPAY_URL') // The API base URL
);
$response = $freemoPayService->pay(
"phone_number", // Payer's phone number
"external_id", // Unique identifier for your transaction
amount // Amount to pay in the supported currency
);To check the status of a payment, use the following method:
$freemoPayService = new FreemoPayService();
$freemoPayService->init(
env('FREEMOPAY_USER'), // Your FreemoPay username
env('FREEMOPAY_PASSWORD'), // Your FreemoPay password
env('FREEMOPAY_URL') // The API base URL
);
$response = $freemoPayService->checkPaymentStatus("payment_reference");If something goes wrong, the FreemoPayService will throw exceptions. Example:
try {
$freemoPayService->pay("phone_number", "external_id", amount);
} catch (\Exception $e) {
echo "Error: " . $e->getMessage();
}Feel free to contribute by cloning this repository and submitting pull requests. Suggestions and issues are welcome!