ejimba/pesapal

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Laravel Pesapal Payment Gateway API Wrapper

2.0.13 2015-05-28 21:57 UTC

This package is auto-updated.

Last update: 2021-07-28 16:02:36 UTC


README

Build Status GitHub license Latest Version

Introduction

This is a Laravel pesapal package to integrate Pesapal payments in your application.

Installation

You should install this package with Composer. Add the following "require" to your composer.json file and run the composer install command to install it.

Laravel 5

Coming soon

Laravel 4.2
{
    "require": {
        "ejimba/pesapal": "2.x"
    }
}
Laravel 4.1
{
    "require": {
        "ejimba/pesapal": "1.x"
    }
}

Then, in your app/config/app.php add this line to your 'providers' array.

'Ejimba\Pesapal\PesapalServiceProvider',

Then, publish the config file by

php artisan config:publish ejimba/pesapal

Then, migrate the package table by using

php artisan migrate --package=ejimba/pesapal

Go to your pesapal account and in the ipn url enter

yoursite.com/ipn

Configuration

This is what you should see in the app/config/packages/ejimba/pesapal/config.php

return array(
    
    /*
    |--------------------------------------------------------------------------
    |   Pesapal Activation
    |--------------------------------------------------------------------------
    |
    |   This specifies whether the application is demo or live states.
    |
    |       true => we are live
    |       false => we are in demo
    |
    |   Supported: true, false
    |
    */

    'enabled' => true,

    /*
    |--------------------------------------------------------------------------
    |   Consumer Key
    |--------------------------------------------------------------------------
    |
    |   Consumer key emailed to you when you created a business account
    |   If you don't have one, sign up at https://www.pesapal.com/home/businessindex
    |
    |   Supported: String
    |
    */

    'consumer_key' => "",

    /*
    |--------------------------------------------------------------------------
    |   Consumer Secret
    |--------------------------------------------------------------------------
    |
    |   Consumer secret emailed to you when you created a business account
    |   If you don't have one, sign up at https://www.pesapal.com/home/businessindex
    |
    |   Supported: String
    |
    */

    'consumer_secret' => "",

    /*
    |--------------------------------------------------------------------------
    |   Currency
    |--------------------------------------------------------------------------
    |
    |   Default Currency
    |
    |   Supported: String e.g. KES
    |
    */

    'currency' => "KES",

    /*
    |--------------------------------------------------------------------------
    |   Controller
    |--------------------------------------------------------------------------
    |
    |   This is the controller that will be called if the status is valid,
    |   please note the method that will be called will be updateItem and 
    |   should be static that is update($key,$reference)
    |
    */

    'controller' => "",

    /*
    |--------------------------------------------------------------------------
    |   Key
    |--------------------------------------------------------------------------
    |
    |   Some random key to protect the method from being called elsewhere
    |
    */

    'key'=>"874315",

    /*
    |--------------------------------------------------------------------------
    |   redirectTo
    |--------------------------------------------------------------------------
    |
    |   Where to redirect to - the link to where your thank you page is
    |
    */

    'redirectTo'=>"/",

    /*
    |--------------------------------------------------------------------------
    |   Mail
    |--------------------------------------------------------------------------
    |
    |   Whether to email address upon complete transaction
    |
    */

    'mail' => true,

    /*
    |--------------------------------------------------------------------------
    |   Email
    |--------------------------------------------------------------------------
    |
    |   Your email address where you will be emailed on complete transaction
    |
    */

    'email'=>"",

    /*
    |--------------------------------------------------------------------------
    |   Name
    |--------------------------------------------------------------------------
    |
    |   Your name
    |
    */

    'name'=>"Site Admin",

    /*
    |--------------------------------------------------------------------------
    |   URLs
    |--------------------------------------------------------------------------
    |
    |   URLs for the application's endpoints.
    |
    |   Supported: string
    |
    */

    'url' => array(

        'ipn_demo' => 'http://demo.pesapal.com/api/querypaymentstatus',
        
        'ipn_live' => 'https://www.pesapal.com/api/querypaymentstatus',
        
        'iframe_demo' => 'http://demo.pesapal.com/API/PostPesapalDirectOrderV4',
        
        'iframe_live' => 'https://www.pesapal.com/api/PostPesapalDirectOrderV4',
    
    ),

    /*
    |--------------------------------------------------------------------------
    |   Routing
    |--------------------------------------------------------------------------
    |
    |   Configurations for routing of Pesapal
    |
    */

    'routing' => array(

        /*
        |--------------------------------------------------------------------------
        | Prefix
        |--------------------------------------------------------------------------
        |
        | Prefix for pesapal routes
        |
        |  e.g http://www.domain.com/pesapal/ipn for ipn route, use
        |
        |  'prefix' => 'pesapal'
        */

        'prefix' => '',

        /*
        |--------------------------------------------------------------------------
        | Subdomain
        |--------------------------------------------------------------------------
        |
        | Subdomain for pesapal routes
        |
        |  e.g http://pesapal.domain.com/ipn for ipn route, use
        |
        |  'subdomain' => 'pesapal'
        |
        | Default: Commented out
        |
        */

        // 'subdomain' => 'pesapal.site.com',
    ),

    
    /*
    |--------------------------------------------------------------------------
    |   Views
    |--------------------------------------------------------------------------
    |
    |   Configuration specific to the views used by pesapal.
    |
    */

    'views' => array(

        /*
        |--------------------------------------------------------------------------
        |   Successful Payment Email View
        |--------------------------------------------------------------------------
        |
        |   View used to render the email after successfull processing a payment
        | 
        |   To use your own email view, replace the view name here.
        |
        |   e.g To use app/views/emails/payment.blade.php:
        |
        |   'payment_email' => 'emails.payment'
        */

        'payment_email' => 'pesapal::emails.payment',

    ),

);

Usage

After configuration, you should be able to call

Pesapal::Iframe($dataArray)

from any view you would like the payment iframe to appear.

The array should have the following info:

$dataArray = array(
    'description' => 'Description of the item or service',
    'currency' => 'If set will override the currency config settings',
    'user' => 'Client user id if you have a system of users',
    'first_name' => 'First name of the user that is paying',
    'last_name' => 'Last name of the user that is paying',
    'email' => 'Valid email of the user that is paying',
    'phone_number' => 'Optional if email has been specified';
    'amount' => 'Amount to be charged',
    'reference' => 'Unique key to the transaction',
    'type' => 'default is MERCHANT',
    'frame_height' => 'Height of the iframe. Please provide integers as in 900 without the px'
);

License

Laravel Auto Presenter is licensed under The MIT License (MIT).