Giter Club home page Giter Club logo

paytech-php-client's Introduction

PayTech - PHP API Client (installable with Composer)

Coverage Status Issues PR Latest Stable Version Total Downloads Latest Unstable Version License Open Source Love png1

This is a simple SDK Client or API Client for PayTech Online Payment Gateway.

Check out PayTech SN Website.

How to use it

First of all, install the package or library via composer

  • composer require papihack/paytech-php-client

After that, setup the API config with your parameters like this :

    \PayTech\Config::setApiKey('your_api_key');
    \PayTech\Config::setApiSecret('your_api_secret');

    /*
     * you can set one of this two following parameters
     * Notice : LiveMode === Production mode
     * !!! By default LiveMode is enable (true) !!!
    */

    \PayTech\Config::setTestMode(true);
    \PayTech\Config::setLiveMode(false);

    /*
     * The PayTech\Enums\Currency class defined authorized currencies
     * You can change XOF (in the following example) by USD, CAD, GBP or MAD
     * !!! Notice that XOF is the default currency !!!
    */

    \PayTech\Config::setCurrency(\PayTech\Enums\Currency::XOF);

    /* !!! Note that if you decide to set the ipn_url, it must be in https !!! */

    \PayTech\Config::setIpnUrl('your_ipn_url');
    \PayTech\Config::setSuccessUrl('your_success_url');
    \PayTech\Config::setCanceUrl('your_cancel_url');

    /*
     * if you want the mobile success or cancel page, you can set
     * the following parameter
    */

    \PayTech\Config::setIsMobile(true);

Then you can proceed with :

    $article_price = 15000;
    $article = new \PayTech\Invoice\InvoiceItem('article_name', $article_price, 'command_name', 'ref_command');

    /* You can also add custom data or fields like this */

    \PayTech\CustomField::set('your_field_name', 'your_field_value');

    /* Make the payment request demand to the API */

    \PayTech\PayTech::send($article);

    /* Get the API Response */

    $response = [
        'success'      => \PayTech\ApiResponse::getSuccess(),
        'errors'       => \PayTech\ApiResponse::getErrors(),
        'token'        => \PayTech\ApiResponse::getToken(),
        'redirect_url' => \PayTech\ApiResponse::getRedirectUrl(),
    ];

After that, if you have a success response, you can redirect your user to the $response['redirect_url'] so that he can make the payment.
You can process the response as you wish by directly manipulating \PayTech\ApiResponse.

TODO

  • tests: cover all use cases โœ…
  • try to make a wrapper for IPN response
  • get the support team at paytech.sn to clarify certain points
  • use mock instead of hitting real endpoint

Contributing

Feel free to make a PR or posting an issue ๐Ÿ˜ƒ

Regarding the tests, I use the elegant PHP Testing Framework Pest ๐Ÿ˜Ž

Oh, one more thing, please do not forget to put a description when you make your PR ๐Ÿ™‚

Contributors

paytech-php-client's People

Contributors

papihack avatar

Watchers

 avatar

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.