Giter Site home page Giter Site logo

otengkwame / redde-php-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wigalgh/redde-php-sdk

0.0 0.0 0.0 21 KB

A PHP SDK built around the Redde REST API that allows merchants to receive, send, check transaction status, and perform lots of payment transactions.

Home Page: https://developers.reddeonline.com/rest-api.html

License: MIT License

PHP 100.00%
redde payment-integration payment-gateway payment-platform payment-api developerkwame

redde-php-sdk's Introduction

GitHub version Maintenance made-with-php MIT license ForTheBadge built-by-developers

Redde-php-sdk

A PHP SDK built around the Redde REST API that allows merchants to receive, send, check transaction status, and perform lots of payment transactions.

Before you can have access to APIs you need to register and create an Account. Header for all request should have {"apikey": "string"}: and this API key will be sent to merchant when their app configuration is setup for them by Wigal.

For more information on documentation go to developers.reddeonline.com

Installation

To use this library you'll need to have created a Redde account.

To install this library and use in your project, we recommend using Composer.

composer require redde/php-api-sdk

You don't need to clone this repository to use this library in your own projects. Use Composer to install it from Packagist.

If you're new to Composer, here are some resources that you may find useful:

Usage

If you're using Composer, make sure the autoloader is included in your project's bootstrap file:

require_once "vendor/autoload.php";

Create an api object with your API key and App ID which will be provided to you by the Redde Team:

$api = new ReddeApi(API_KEY, APP_ID);    

Examples

Receiving money from Customer or Client

To use the API to recieve money from a customer, the receiveMoney() method will be used using a simple array of parameters, the keys match the parameters of the API.

/**
* An example of using the Redde Api to receive money
*/

require_once 'vendor/autoload.php';

//Configuration file contains apikey and appid
$config = include 'config.php';

use Redde\Exceptions\ReddeApiException;
use Redde\Exceptions\ReddeException;
use Redde\ReddeApi;

/* Replace this with your API key and App Id
 You can also insert the apikey and appid here directly 
 and ignore the config.php file
*/

$apikey = $config['apikey'];
$app_id = $config['appid'];

$api = new ReddeApi($apikey, $app_id);

/* Note that the clienttransid and clientreference is generated 
  by the developer. The nickname is your identity name eg. Wigal
*/

$params = [
    "amount" => 1, //amount to receive
    "appid" => $config['appid'], //your app id
    "clientreference" => client_reference_here, //client reference from your side
    "clienttransid" => client_transaction_id_here, //client transaction id from your side
    "description" => "Recieving payment from {$client_reference_here}", //A description for the transaction performed
    "nickname" => "nickname_here", //a name to give to who is paying 
    "paymentoption" => "MTN", //payment options are MTN|AIRTELTIGO|VODAFONE
    "vouchercode" => "", //this is optional for vodafone 
    "walletnumber" => "024XXXXXXX" //the mobile number to use
];

/**
* Call receiveMoney function and pass
* the payload as parameter. This will 
* return a response which you can save
* in any storage of your choice
*/
$api->receiveMoney($params);

Sending money to Customer or Client

To use the API to send money to a customer, the sendMoney() method will be used using a simple array of parameters, the keys match the parameters of the API.

/**
* An example of using the Redde Api to send money
*/

require_once 'vendor/autoload.php';

//Configuration file contains apikey and appid
$config = include 'config.php';

use Redde\Exceptions\ReddeApiException;
use Redde\Exceptions\ReddeException;
use Redde\ReddeApi;

/* Replace this with your API key and App Id
 You can also insert the apikey and appid here directly 
 and ignore the config.php file
*/

$apikey = $config['apikey'];
$app_id = $config['appid'];

$api = new ReddeApi($apikey, $app_id);

/* Note that the clienttransid and clientreference is generated 
  by the developer. The nickname is your identity name eg. Wigal
*/

$params = [
    "amount" => 1, //amount to receive
    "appid" => $config['appid'], //your app id
    "clientreference" => client_reference_here, //client reference from your side
    "clienttransid" => client_transaction_id_here, //client transaction id from your side
    "description" => "Sending payment from {$client_reference_here}", //A description for the transaction performed
    "nickname" => "nickname_here", //a name to give to who is paying 
    "paymentoption" => "MTN", //payment options are MTN|AIRTELTIGO|VODAFONE
    "walletnumber" => "024XXXXXXX" //the mobile number to use
];

/**
* Call receiveMoney function and pass
* the payload as parameter. This will 
* return a response which you can save
* in any storage of your choice
*/
$api->sendMoney($params);

Callbacks

Most APIs implement callbacks for easy tracking of api transactions so we've spun something simple for you to use. Check it out

/**
* A simple implementation of callback 
* on Redde Api
*/

require_once '../vendor/autoload.php';
use Redde\Exceptions\ReddeApiException;
use Redde\Exceptions\ReddeException;
use Redde\Webhooks\WebHookStatus;

$status = new WebHookStatus(); //instantiate an object

$data = $status->callback(); //get callback and set it to a variable

echo $data->reason; //output any data e.g. status|reason| etc

License

This library is released under the MIT License

redde-php-sdk's People

Contributors

otengkwame 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.