πPHP SDK
The Moneroo PHP SDK is a comprehensive library that enables PHP developers to interact with the Moneroo Payment Orchestration service.
Requirements
PHP 7.4 and later.
Installation
You can install the package via composer:
Payment
The Moneroo\Payment
class provides methods for initialise, verifying, retrieving, and marking payments as processed. You can use it like so:
Initialise Payment
To create a payment, you need to pass an array of payment data to the create
method. The array must contain the following keys:
Here are the required fields in a table format:
If not provided, the customer can be prompted to enter these details during the payment process based on the selected payment method.
There Should be an array of key-value pairs. Only string values are allowed.
If not provided, all available payment methods will be allowed. Array should contain only supported payment methods.
Example Usage
The create
method returns an object containing the payment details, including the transaction ID, Checkout URL where yous should redirect the customer to complete the payment. You can use this transaction ID to verify the payment later on.
Verify Payment
You can verify a payment by its transaction ID. This is useful when you want to check the status of a payment before processing an order on your end.
Retrieve Payment
To get details of a payment, use the get
method with the transaction ID.
Mark Payment as Processed
This is currently an experimental feature, please use with caution and report any issues you encounter.
This method is useful when you want to mark a payment as processed after you've received a successful callback from the Moneroo API, and you've processed the order on your end. This will also allow you to prevent duplicate orders or store transactions IDs in your database for future reference.
To mark a payment as processed, use the makeAsProcessed
method with the transaction ID.
Example usage:
Payout
The Moneroo\Payout
class provides methods for initialise, verifying, and retrieving payouts.
Initialise Payout
To initialise a payout, you need to pass an array of data that meets the specified validation rules. The array must contain the following keys:
Here are the required fields in a table format:
Should be a Moneroo supported payout methods
This feature is currently in the experimental phase and is not available to all users/applications. It allows you to request confirmation from a customer before proceeding with payment. Moneroo will send an e-mail to the customer containing a confirmation code. The customer is then directed to a confirmation page where they can check the payment amount and account details. If the information is correct, the customer can enter the confirmation code to approve or reject the payment request. This function is a valuable tool for avoiding incorrect information or fraudulent transactions. If the user does not respond within 15 minutes, the payment request will be automatically cancelled.
In addition to the above information, you need to add payout methods required fields for account details. For example, if the payment method is mtn_bj
, you should provide msisdn
fields in recipient
object.
This is different from user information, it accounts where money will be paid. For more information, please check the required fields for each payout method.
The create
method returns an object containing the payout details, including the transaction ID, and the payout status. You can use this transaction ID to verify the payout later on.
Verify Payout
You can verify a payout by its transaction ID.
Retrieve Payout
To get details of a payout, use the get
method with the transaction ID.
Exception Handling
The SDK comes with a number of custom exceptions to help you manage potential errors that may occur when using the Moneroo API. These exceptions are as follows:
InvalidPayloadException: This exception is thrown when the payload sent to the API does not meet the expected criteria.
ForbiddenException: This exception is thrown when an action is attempted that the authenticated user does not have the necessary permissions for.
InvalidResourceException: This exception is thrown when a request is made to a non-existent or invalid resource.
ServerErrorException: This exception is thrown when there is an error on the server's side.
NotAcceptableException: This exception is thrown when the client request's content characteristics are not acceptable according to the Accept headers sent in the request.
ServiceUnavailableException: This exception is thrown when the service is currently unavailable, perhaps due to maintenance or load issues on the server.
UnauthorizedException: This exception is thrown when the request lacks valid authentication credentials for the target resource.
For each exception, you can access the error message by calling $exception->getMessage()
, and the error code (if available) by calling $exception->getCode()
.
Support
If you have any questions or need help, feel free to contact us.
We are always happy to help you with any questions you may have.
Security Vulnerabilities
If you discover a security vulnerability within Moneroo PHP SDK, please send an e-mail to Moneroo Security via security@moneroo.io.
All security vulnerabilities will be promptly addressed.
License
The Moneroo PHP SDK is open-sourced software licensed under the MIT license.
Last updated