PHP SDK for implementing the PesaPal API.
include the pesapal.php file in your application
require_once('pesapal.php');
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 |
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 |
john@yahoo.com | ||
phone | tel | 254700000000 |
Call the iframe() method where you would like to render the Pesapal iframe
PesaPal::iframe();
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.
Call the mehod on your callback url, passing the name of the callback function above as an argument
PesaPal::process_ipn( $callback );
MIT(LICENSE)