PHP code example of sakshsky / saksh-wallet

1. Go to this page and download the library: Download sakshsky/saksh-wallet library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sakshsky / saksh-wallet example snippets


use Saksh\Wallet\Services\SakshWallet;

$wallet = app('saksh-wallet');
$userId = 1;

// Set admin email (optional)
$wallet->setAdmin('[email protected]');

// Credit an amount
echo $wallet->addFunds($userId, 500, 'USD', 'ref123', 'Salary payment');
// Output: Credited 500 USD. New balance is 500

// Debit an amount with a fee
echo $wallet->deductFunds($userId, 200, 'USD', 'ref124', 'Grocery shopping', 5);
// Output: Debited 200 USD. New balance is 295

// Get balance
$balance = $wallet->getBalance($userId, 'USD');
print_r($balance);
// Output: ['user_id' => 1, 'currency' => 'USD', 'balance' => 295]

// Get balance summary
$summary = $wallet->sakshGetBalanceSummary($userId);
print_r($summary);
// Output: ['user_id' => 1, 'balance' => ['USD' => 295]]
bash
   php artisan vendor:publish --tag=saksh-wallet-migrations
   php artisan migrate
   
bash
  php artisan saksh-wallet:verify