PesaPal PHP SDK
PHP SDK for implementing the PesaPal API.
Usage
Installation
include the pesapal.php file in your application
require_once('pesapal.php');
Configuration
At the top of your code, configure the Pesapal object
PesaPal::config( $env, $consumer_key, $consumer_secret, $callback_url );
Parameter Name | Parameter Description | Parameter Type | Possible/Default Value |
---|---|---|---|
$env | System Environment | string | sandbox/live |
$consumer_key | Pesapal Consumer Key | string | behdklejdkjdw |
$consumer_secret | Pesapal Consumer Secret | string | ncjdbckdcdhcjdcvjldhckadlxhska |
$callback_url | Site Callback Endpoint/Link | string | https://yoursiteurl.tld/process_ipn |
Payment Form
Create a form with the following fields:
Field Name | Field Type | Possible/Default Value |
---|---|---|
amount | number/text | 100 |
type | text | MERCHANT |
description | text | Order Description |
reference | number/text | 001 |
first_name | text | John |
last_name | text | Doe |
[email protected] | ||
phone | tel | 254700000000 |
Process Payment
Call the iframe() method where you would like to render the Pesapal iframe
PesaPal::iframe();
Process IPN Response
Update Database
Create a function to update your database with payment details - this function must return a boolean (true on success, false on failure). The function takes the response data an an argument.
Process IPN
Call the mehod on your callback url, passing the name of the callback function above as an argument
PesaPal::process_ipn( $callback );
Licencing
MIT(LICENSE)