PHP code example of toneflix-code / laravel-pay-pocket

1. Go to this page and download the library: Download toneflix-code/laravel-pay-pocket 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/ */

    

toneflix-code / laravel-pay-pocket example snippets



use ToneflixCode\LaravelPayPocket\Interfaces\WalletOperations;
use ToneflixCode\LaravelPayPocket\Traits\ManagesWallet;

class User extends Authenticatable implements WalletOperations
{
    use ManagesWallet;
}

namespace App\Enums;

enum WalletEnums: string
{
    case WALLET_MAIN = 'wallet_main';
    case WALLET_ESCROW = 'wallet_escrow';
}


deposit(type: string, amount: float|int, notes: string null)

$user = auth()->user();
$user->deposit('wallet_main', 123.45);

$user = auth()->user();
$user->deposit('wallet_escrow', 67.89);

use ToneflixCode\LaravelPayPocket\Facades\LaravelPayPocket;

$user = auth()->user();
LaravelPayPocket::deposit($user, 'wallet_main', 123.45);


$user = auth()->user();
$user->deposit('wallet_main', 67.89, 'You sold pizza.');

pay(amount: int, allowedWallets: array [], notes: string null)

$user = auth()->user();
$user->pay(12.34);

use ToneflixCode\LaravelPayPocket\Facades\LaravelPayPocket;

$user = auth()->user();
LaravelPayPocket::pay($user, 12.34);

$user = auth()->user();
$user->pay(12.34, ['wallet_main']);

$user = auth()->user();
$user->pay(12.34, [], 'You ordered pizza.');

$user->walletBalance // Total combined balance available across all wallets

// Or using provided facade

LaravelPayPocket::checkBalance($user);

$user->getWalletBalanceByType('wallet_main') // Balance available in wallet_main
$user->getWalletBalanceByType('wallet_escrow') // Balance available in wallet_escrow

// Or using provided facade

LaravelPayPocket::walletBalanceByType($user, 'wallet_main');
bash
php artisan vendor:publish --tag="pay-pocket-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="pay-pocket-wallets"
php artisan vendor:publish --tag="config"