Giter Site home page Giter Site logo

wallet's Introduction

Wallet

A general wallet for users that they can charge. Site admin can utilize that wallet balance using set of available APIs. PayPal is the method available to load the wallet. Minimum amount is set is 10 and default current is USD. You may can edit these details in ossn_com.php file. The wallet only supports the amounts that are not in floating points.

define('WALLET_CURRENCY_CODE', 'USD'); //your 3 digits currency code from PayPal
define('WALLET_MINIMUM_LOAD', 10);  //Minimum amount integer only (no floating)

API END POINTS

Debit

CURL https://www.yourwebsite.com/api/v1.0/wallet/debit

Credit

CURL https://www.yourwebsite.com/api/v1.0/wallet/credit

Responces and parameter required

Parameter Type Description Required
api_key_token string Your API token Yes
guid integer User GUID Yes
amount integer Amount to debit must not be in points Yes
description integer Description Yes
 {
    "merchant": "Open Source Social Network",
    "url": "https:\/\/yourwebsite.com\/",
    "time_token": 1637513403,
    "payload": {
        "status": "success",
        "amount": "50",
        "guid": "1"
    },
    "code": "100",
    "message": "Request successfully executed"
}

Access using PHP

<?php
....
....
try {
    $user_guid = ossn_loggedin_user()->guid;
    $wallet = new Wallet\Wallet($user_guid);
    $amount = 20;
    $description = 'Some description';
    var_dump($wallet->credit($amount, $description)); //credit amount
} catch (Wallet\NoUserException $e) {
    echo $e->getMessage();
}  catch (Wallet\CreditException $e) {
    echo $e->getMessage();
}

//debit

try {
    $user_guid = ossn_loggedin_user()->guid;
    $wallet = new Wallet\Wallet($user_guid);
    $amount = 20;
    $description = 'Some description';
    var_dump($wallet->debit($amount, $description)); //debit amount
} catch (Wallet\NoUserException $e) {
    echo $e->getMessage();
}  catch (Wallet\DebitException $e) {
    echo $e->getMessage();
}

//getting balance
$user_guid = ossn_loggedin_user()->guid;
$wallet = new Wallet\Wallet($user_guid);
echo $wallet->getBalance();

//changing balance
$user_guid = ossn_loggedin_user()->guid;
$wallet = new Wallet\Wallet($user_guid);
echo $wallet->setBalance(<new amount>);

wallet's People

Contributors

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