Giter Club home page Giter Club logo

cws's Introduction

cws

A centralised wallet system to include in your php laravel projects

Installation

Install with composer: composer require fshangala/cws

Laravel

Laravel will automatically register the service upon installation. Run the command php artisan migrate migrations should run. If that doesnt happen for you, you can follow the steps for lumen. They work for laravel as well.

Lumen

After installation, register the service provider in your bootstrap/app.php file.

//$app->register(App\Providers\AppServiceProvider::class);
//$app->register(App\Providers\AuthServiceProvider::class);
//$app->register(App\Providers\EventServiceProvider::class);

after the lines above in your bootstrap/app.php file add the following

$app->register(Fshangala\Cws\CwsServiceProvider::class);

Then run the command php artisan migrate migrations should run. You're good to go!

Usage

Create wallet

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $user_id = 1;
    $response = createWallet($user_id);
    
    return response($response);
  }
}

Deposit request

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $user_id = 1;
    $currency = "USD";
    $debit = 200;
    $reference = "Deposit request";
    $response = depositRequest($user_id,$currency,$debit,$reference);
    
    return response($response);
  }
}

Withdraw request

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $user_id = 1;
    $currency = "USD";
    $credit = 200;
    $response = withdrawRequest($user_id,$currency,$credit);
    
    return response($response);
  }
}

transfer request

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $user_id = 1;
    $wallet_id = 2;
    $currency = "USD";
    $amount = 200;
    $reference = "Transfer funds to account 2";
    $response = transfer($user_id,$wallet_id,$currency,$amount,$reference);
    
    return response($response);
  }
}

approve transaction

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $transaction_id = 1;
    $response =  approveTransaction($transaction_id);
    
    return response($response);
  }
}

transaction history

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $user_id = 1;
    $response = transactionHistory($user_id);
    
    return response($response);
  }
}

get transaction

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $transaction_id = 1;
    $response =  getTransaction($transaction_id);
    
    return response($response);
  }
}

get total balance

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $response = totalBalance();
    
    return response($response);
  }
}

get total wallet balance

<?php

namespace App\Http\Controllers;
use Fshangala\Cws\Core\WalletCore;

class ExampleController extends Controller
{
  public function exampleMethod()
  {
    $wallet = new WalletCore();
    $user_id = 1;
    $response = totalWalletBalance($user_id);
    
    return response($response);
  }
}

cws's People

Contributors

fshangala avatar

Watchers

 avatar

cws's Issues

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.