Git Product home page Git Product logo

php-pesa's Introduction

Pesa SDK for PHP


Version 2 | Work in Progress ๐Ÿšง

Latest Version on Packagist Test documentation Hits codecov.io Total Downloads

The Pesa SDK for PHP makes it easy for developers to access OpenAPI in their PHP code, and build robust applications and software using services like Customber 2 Bussiness, Query etc.

Documentation

Take a look at the API docs here.

Getting Started

  1. Sign up for OpenAPI Portal โ€“ Before you begin, you need to sign up for an account and retrieve your credentials.

  2. Minimum requirements โ€“ To run the SDK, your system will need to meet the minimum requirements, including having PHP >= 7.1.

  3. Install the SDK โ€“ Using [Composer] is the recommended way to install the Pesa SDK for PHP. The SDK is available via [Packagist] under the openpesa/php-pesa package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:

    composer require openpesa/pesa

    Please see the Installation section of the User Guide for more detailed information about installing the SDK through Composer and other means.

  4. Using the SDK โ€“ The best way to become familiar with how to use the SDK is to read the User Guide.

Usage

Quick Examples

require 'vendor/autoload.php';

use Openpesa\SDK\Pesa;

// Intiate with credentials
$pesa = new Pesa([
            'api_key' => 'YOUR_API_KEY',
            'public_key' => 'PUBLIC_KEY',
            'client_options' => [],
        ],'sandbox');

// Setup the transaction
$data = [
    'input_Amount' => '10000',
    'input_Country' => 'TZN',
    'input_Currency' => 'TZS',
    'input_CustomerMSISDN' => '255766303775',
    'input_ServiceProviderCode' => '000000',
    'input_ThirdPartyConversationID' => 'rerekf',
    'input_TransactionReference' => rand(),
    'input_PurchasedItemsDesc' => 'Test Two Item'
];

// Execute
$result = $pesa->c2b($data);

// Print results
var_dump($result);

For more example check pesa-demo-example.

Testing

composer test

Opening Issues

If you have a feature requrest or you encounter a bug, please file an issue on our issue tracker on GitHub.

Resources

  • User Guide โ€“ For both getting started and in-depth SDK usage information
  • API Docs โ€“ For details about operations, parameters, and responses
  • Blog โ€“ Tips & tricks, articles, and announcements
  • Sample Project - A quick, sample project to help get you started
  • Issues โ€“ Report issues, submit pull requests, and get involved
  • @openpesa โ€“ Follow us on Twitter

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please review our CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

php-pesa's People

Contributors

alphaolomi avatar leyluj avatar pro-cms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-pesa's Issues

Typo

Found a typo on readme, can I submit a pr with a fix?

Re-structure the API design

From

  • Forodha class
    -contructor
    -encrypt_key
    -get_session
    -query
    -transact

To

  • Pesa class
    -contructor(options, env, client)
    -encrypt_key
    -get_session
    -c2b
    -b2c
    -b2b
    -query
    -reverse

Problem when switching to env to production

I have instantiated the pesa class with valid production credentials and switch it to production but a problem occurs, it fails to generate the session key if I return the sandbox credentials and switch back to sandbox it works fine

Package conflict

"guzzlehttp/guzzle": "^7.0", gives a package conflict error during composer install, while "^6.3" works so far. should i expect any problems due to this downgrade?

ErrorException: Undefined index: output_SessionID in file

#0 /home/u689581850/domains/gtnsite.co.tz/gtn/app/Http/Controllers/PortalSDK/Forodha.php(166): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined index...', '/home/u68958185...', 166, Array)
#1 /home/u689581850/domains/gtnsite.co.tz/gtn/app/Http/Controllers/PortalSDK/b2cController.php(331): App\Http\Controllers\PortalSDK\Forodha->transact('c2b', Array)
#2 [internal function]: App\Http\Controllers\PortalSDK\b2cController->forodhaTest()
#3 /home/u689581850/domains/gtnsite.co.tz/gtn/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)

Origin not allowed

content-type: application/json
access-control-allow-origin: *
content-length: 37
Vary: Accept-Encoding

{
"output_error": "Origin not allowed"
}
{
"status_code": 403,
"headers": "HTTP/1.1 403 Forbidden\r\ndate: Fri, 06 Nov 2020 13:39:46 GMT\r\nx-frame-options: SAMEORIGIN\r\nx-robots-tag: none\r\nx-content-type-options: nosniff\r\nx-xss-protection: 1; mode=block\r\nstrict-transport-security: max-age=16005600; includeSubDomains\r\ncontent-type: application/json\r\naccess-control-allow-origin: *\r\ncontent-length: 37\r\nVary: Accept-Encoding\r\n\r\n",
"body": "{"output_error":"Origin not allowed"}"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.