nrshoukhin/forte-php-sdk

A PHP SDK for Forte payment integration.

1.0 2020-08-23 16:45 UTC

This package is auto-updated.

Last update: 2024-06-06 08:20:54 UTC


README

Welcome to Forte PHP SDK. This repository contains Forte's PHP SDK for Forte REST API V3.

Prerequisites

Installation

To install this package run this command in you terminal from project root

composer require nrshoukhin/forte-php-sdk

For Laravel

Open your laravel project's config/app.php and add this service provider element in providers array

Shoukhin\Forte\ForteServiceProvider::class,

and add this facade element in aliases array

'Forte' => Shoukhin\Forte\Facades\Forte::class,

Run this artisan command in your terminal

php artisan vendor:publish --provider="Shoukhin\Forte\ForteServiceProvider"

after executing the command successfully, go to your project config folder then open forte.php (Location: Your_laravel_project_folder/config/forte.php) and add your forte rest api credentials.

return [
    'access_id' => 'provide_forte_access_id',

    'secret_id' => 'provide_forte_secret_id',

    'mode'  =>  'provide_mode', //live or sandbox
    
    'org_id' => 'provide_the_forte_organization_id',

    'loc_id' => 'provide_the_forte_location_id'
];

Usages

Here, providing an example to get all customer(s) of an organization in your PHP project.
Note: Include the autoload.php according to your project path structure.

<?php
include "vendor/autoload.php";
use Shoukhin\Forte\Api\Authentication;
use Shoukhin\Forte\Api\Customer;

$access_id = "provide your Forte access ID";
$secret_id = "provide your Forte secret ID";
$authentication = new Authentication( $access_id, $secret_id );

$authentication->set_config(
        array(
            "mode"   => "sandbox", //sandbox or live
            "org_id" => "provide the organization ID",
            "loc_id" => "provide the location ID"
        )
);

$forte = new Customer($authentication);
$customer = $forte->getCustomerOfOrganization();
echo "<pre>";
var_dump( $customer );
?>

For Laravel Usage

For an Example, Using a controller named ForteController to collect all customer(s) of an organization.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Shoukhin\Forte\Facades\Forte;

class ForteController extends Controller
{
    public function getAllCustomers(){
        $data = Forte::Customer()->getCustomerOfOrganization();
        echo "<pre>";
        var_dump( $data );
        return;
    }
}

SDK Documentation

Click Here to see the documentation of this SDK.