jobmetric / voucher-usd
This package handles payment via the USD voucher website.
Fund package maintenance!
majidmohammadian
Requires
- php: >=8.0.1
- ext-json: *
- jobmetric/laravel-package-core: ^1.17
- laravel/framework: >=9.19
This package is auto-updated.
Last update: 2024-11-28 14:31:52 UTC
README
Voucher USD
A Laravel package for managing voucher USD
, including authentication, balance checking, voucher creation, and retrieval.
Install via composer
Run the following command to pull in the latest version:
composer require jobmetric/voucher-usd
Documentation
Add the required environment variables in your .env file:
VOUCHER_USD_CLIENT_ID=your_client_id VOUCHER_USD_CLIENT_SECRET=your_client_secret VOUCHER_USD_AUTH_URL=https://example.com VOUCHER_USD_BASE_URL=https://example.com
Usage
Authentication
To authenticate and retrieve an access token:
use JobMetric\VoucherUsd\Facades\VoucherUsd; $response = VoucherUsd::auth(); if ($response['ok']) { echo "Access Token: " . $response['data']['token']; } else { echo "Error: " . $response['message']; }
Check Balance
To check the account balance:
$response = VoucherUsd::balance(); if ($response['ok']) { echo "Available Balance: " . $response['data']['available']; echo "Actual Balance: " . $response['data']['actual']; } else { echo "Error: " . $response['message']; }
Create a Voucher
To create a new voucher:
$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']; }
Retrieve All Vouchers
To retrieve a list of all vouchers:
$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']; }
Retrieve a Single Voucher
To retrieve details of a specific voucher by its code:
$voucherCode = 'ABC123'; $response = VoucherUsd::showVoucher($voucherCode); if ($response['ok']) { echo "Voucher Details: " . print_r($response['data'], true); } else { echo "Error: " . $response['message']; }
Events
This package contains several events for which you can write a listener as follows
Contributing
Thank you for considering contributing to the Laravel Ban Ip! The contribution guide can be found in the CONTRIBUTING.md.
License
The MIT License (MIT). Please see License File for more information.