Pesapal package for Laravel
Introduction
This is a Laravel 5.* pesapal package.
I provided this package as to help since pesapal do not have a package for Laravel.
Pesapal do not have a way to test this so I guess you will have to send money
payments to test. Please do ping me whenever you need something., (*1)
<, (*2)
h3> For Laravel 4.2, (*3)
Installation
add, (*4)
"ericmuigai/pesapal": "3.0.x-dev"
to your composer.json and then, (*5)
composer update
this will install the package
Once the package is installed add, (*6)
'Ericmuigai\Pesapal\PesapalServiceProvider',
to the providers.
after this publish the config file by, (*7)
php artisan config:publish ericmuigai/pesapal
then migrate the package table by using, (*8)
php artisan vendor:publish
Go to your pesapal account and in the ipn url enter, (*9)
yoursite.com/listenipn
or or the url to your public path/listenipnbr/
You should now find the config.php in the, (*10)
config/pesapal.php
Configuration
This is what you should see in the config.php, (*11)
/**
* this settings are needed in order to work with pesapal
* enabled(bool) -if true sets the pesapal to live instead of demo website that was not functioning at the time of writing this package
* consumer_key the consumer key gotten from the pesapal website
* consumer_secret- The consumer secret gotten from the pesapal website.
* controller - This is the controller that will be called if the status is valid. A method updateItem($key, $pesapal_merchant_reference) will be called.
* please note the method that will be called will be updateItem and should be static that is update($key,$reference)
* Key- the key to protect the method from being called elsewhere
* redirectTo - the link to where your thankyou page is
* email - Your email address where you will be emailed on complete transaction
* name - your name
* currency - the currency that will be used on payment
*
*/
return array(
'enabled' => true,
'consumer_key' => "",
'consumer_secret'=>"",
'controller'=>"YourController",
'key'=>"12345",
'redirectTo'=>"/",
'email'=>"your@email.com",
'mail'=>true,
'name'=>"Admin",
'currency'=>"KES",
);
You are now set once the right info is entered., (*12)
How to use
Now you should be able to call the, (*13)
Pesapal::Iframe($array)
from any view you would like the iframe to appear.
The array should have this info in the, (*14)
$array
/**
* generates the iframe from the given details
* @param array $values this array should contain the fields required by pesapal
* description - description of the item or service
* currency - if set will override the config settings you have of currency
* user -which should be your client user id if you have a system of users
* first_name- the first name of the user that is paying
* last_name - the last name of the user that is paying
* email - this should be a valid email or pesapal will throw an error
* phone_number -which is optional if you have the email
* amount - the total amount to be posted to pesapal
* reference Please Make sure this is a unique key to the transaction. An example is the id of the item or something
* type - default is MERCHANT
* frame_height- this is the height of the iframe please provide integers as in 900 without the px
*
*/'
Author
Eric Muigai- http://www.hot254.co.ke, (*15)
License
Licensed under MIT, (*16)