Giter Site home page Giter Site logo

mohammed0115 / laravel-sudani Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alkhatibdev/laravel-sudani

1.0 0.0 0.0 32 KB

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.

Home Page: https://github.com/alkhatibdev/laravel-sudani

License: MIT License

PHP 100.00%

laravel-sudani's Introduction

Social Card of Laravel Sudani Package

Sudani SPay API integration with Laravel

Latest Version MIT Licensed

Introduction

Laravel Sudani is Sudani SPay API integration with Laravel, made to simplify the 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' => true,

];

Don't forget to set all these variable 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 initiate payment request successfully sent, a SMS with OTP code will be send 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)

// cacheToken($response['token'])

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 cache the token and use it for furthor requests of whole day, you request token like this:

$token = Sudani::token()

And you can cache it and use for next requests 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 package config file

'enable_logging' => true,

Other Packages

License

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

laravel-sudani's People

Contributors

alkhatibdev avatar

Stargazers

Mohammed kamal Mohammed 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.