PHP code example of jobmetric / voucher-usd

1. Go to this page and download the library: Download jobmetric/voucher-usd 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/ */

    

jobmetric / voucher-usd example snippets


use JobMetric\VoucherUsd\Facades\VoucherUsd;

$response = VoucherUsd::auth();

if ($response['ok']) {
    echo "Access Token: " . $response['data']['token'];
} else {
    echo "Error: " . $response['message'];
}

$response = VoucherUsd::balance();

if ($response['ok']) {
    echo "Available Balance: " . $response['data']['available'];
    echo "Actual Balance: " . $response['data']['actual'];
} else {
    echo "Error: " . $response['message'];
}

$data = [
    'amount' => 100, // Amount in USD
    'note' => 'Test voucher creation',
];

$response = VoucherUsd::createVoucher($data);

if ($response['ok']) {
    echo "Voucher Code: " . $response['data']['voucher_code'];
} else {
    echo "Error: " . $response['message'];
}

$response = VoucherUsd::getVouchers();

if ($response['ok']) {
    echo "Vouchers: " . print_r($response['data']['vouchers'], true);
    echo "Report: " . print_r($response['data']['report'], true);
} else {
    echo "Error: " . $response['message'];
}

$voucherCode = 'ABC123';

$response = VoucherUsd::showVoucher($voucherCode);

if ($response['ok']) {
    echo "Voucher Details: " . print_r($response['data'], true);
} else {
    echo "Error: " . $response['message'];
}