Skip to content

Sudani SPay API integration with Laravel, was made to simplify the process and API calls and let developers focus on other integration parts and logic.

License

Notifications You must be signed in to change notification settings

alkhatibdev/laravel-sudani

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Card of Laravel Sudani Package

Sudani SPay API integration with Laravel

Latest Version Packagist Downloads (custom server) MIT Licensed

Introduction

Laravel Sudani is Sudani SPay API integration with Laravel, made to simplify the process and API calls and let developers focus on other integration parts and logic. See also Laravel Zain.

Installation

Requirements

  • PHP >= 7.4.x
  • Laravel >= 7.x

install via composer

composer require alkhatibdev/laravel-sudani

Publish Configs

php artisan vendor:publish --tag=laravel-sudani-config

A laravel-sudani.php config file will be published on your configs directory, with the following content:

<?php

return [

    'base_url' => env('SUDANI_SERVER_BASE_API_URL'),

    'provider_key' => env('SUDANI_PROVIDER_KEY'),

    'service_code' => env('SUDANI_SERVICE_CODE'),

    'username' => env('SUDANI_USERNAME'),

    'password' => env('SUDANI_PASSWORD'),

    'enable_logging' => false,

];

Don't forget to set all these variables on your .env file

SUDANI_SERVER_BASE_API_URL=http://196.1.241.110/SPayAPI/Service/
SUDANI_PROVIDER_KEY=xxxxxxxx
SUDANI_SERVICE_CODE=xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
SUDANI_USERNAME=xxxxxx
SUDANI_PASSWORD=xxxxxx

Usage

Initial Payment/Subscription

use AlkhatibDev\LaravelSudani\Facades\Sudani;

// Initiate payment request
$response = Sudani::initiate($phone)

When the initiate payment request is successfully sent, an SMS with an OTP code will be sent to the $phone number, and $response will contain a requestId and you should save it to the next step verify.

Verify Payment/Subscription

$response = Sudani::verify($otp, $requestId)

Check Subscription

$response = Sudani::checkSubscription($phone)

Unsubscribe

$response = Sudani::unsubscribe($phone)

Login and Cache SPay token

Out of the box, the package will encrypt the password and login automatically and get the token and use it for each action initiate, verify ..etc per request. If you want to cache the token and use it for further requests, you can request a token like this:

$token = Sudani::token()

And you can cache it and use it for each request for the next 24 hours, for example:

// $token = getCachedToken()

$response = Sudani::withToken($token)->initiate($phone)
$response = Sudani::withToken($token)->verify($phone)
...

Logging

You can enable logging from the package config file

'enable_logging' => true,

Other Packages

License

Laravel Sudani is open-sourced software licensed under the MIT license.

About

Sudani SPay API integration with Laravel, was made to simplify the process and API calls and let developers focus on other integration parts and logic.

Topics

Resources

License

Stars

Watchers

Forks

Languages