PHP code example of mahbodhastam / laravel-user-wallet

1. Go to this page and download the library: Download mahbodhastam/laravel-user-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/ */

    

mahbodhastam / laravel-user-wallet example snippets


use MahbodHastam\UserWallet\UserWallet;

$wallet = UserWallet::createNewWallet(user_id: 1);

$amount = $wallet->amount;
$token = $wallet->token;

$wallet = UserWallet::getWallet('abc');

$balance = UserWallet::balance($wallet)['total'];

UserWallet::fill($wallet, 100);

UserWallet::charge($wallet, 500);

UserWallet::send(
    sender: $wallet1,
    receiver: $wallet2,
    value: 50
);

$transaction = UserWallet::makeRequest(
    value: 300,
    receiver: $wallet
);

// Keep it
$hash = $transaction->transaction_hash;

UserWallet::closeRequest(
    sender: $wallet,
    transaction_hash: $hash
);