PHP code example of yusufthedragon / treasury-php

1. Go to this page and download the library: Download yusufthedragon/treasury-php 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/ */

    

yusufthedragon / treasury-php example snippets


\YusufTheDragon\Treasury\Treasury::setProductionMode(true);

\YusufTheDragon\Treasury\Auth::loginClient(array $params);

$params = [
    'client_id' => '115823',
    'client_secret' => 'masdh12km3bf09dbkjlm13bkcsv0asdb1249gss2',
    'grant_type' => 'client_credentials'
];

$loginClient = \YusufTheDragon\Treasury\Auth::loginClient($params);

var_dump($loginClient);

\YusufTheDragon\Treasury\Auth::register(array $params);

$params = [
    'name' => 'John Doe',
    'email' => '[email protected]',
    'password' => 'PassWord',
    'password_confirmation' => 'PassWord',
    'gender' => 'Male',
    'birthday' => '1990-01-01',
    'referral_code' => 'TRSRFRL',
    'phone' => '089612345678',
    'security_question' => 'KQxz9YXazA14VEO',
    'security_question_answer' => 'Dr. Seuss',
    'selfie_scan' => '/9j/4AAQSkZJRgABAQAAAQAB...',
    'id_card_scan' => '/9j/4AAQSkZJRgABAQAAAQAB...',
    'owner_name' => 'John Doe',
    'account_number' => ' 772661553',
    'bank_code' => 'BCA',
    'branch' => 'Jakarta',
    'customer_concern' => true,
    'app_notification' => true,
    'email_notification' => true
];

$register = \YusufTheDragon\Treasury\Auth::register($params);

var_dump($register);

\YusufTheDragon\Treasury\Auth::login(array $params);

$params = [
    'client_id' => '115823',
    'client_secret' => 'masdh12km3bf09dbkjlm13bkcsv0asdb1249gss2',
    'grant_type' => 'password',
    'email' => '[email protected]',
    'password' => 'JohnDoe'
];

$login = \YusufTheDragon\Treasury\Auth::login($params);

var_dump($login);

\YusufTheDragon\Treasury\Auth::forgotPassword(string $email);

$forgotPassword = \YusufTheDragon\Treasury\Auth::forgotPassword('[email protected]');

var_dump($forgotPassword);

\YusufTheDragon\Treasury\Transaction::getGoldPrice(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'start_date' => '2020-01-01 00:00:00',
    'end_date' => '2020-01-02 00:00:00',
    'type' => 'daily'
];

$getGoldPrice = \YusufTheDragon\Treasury\Transaction::getGoldPrice($bearerToken, $params);

var_dump($getGoldPrice);

\YusufTheDragon\Treasury\Transaction::calculate(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'amount_type' => 'currency',
    'amount' => 20000,
    'transaction_type' => 'buy',
    'payment_type' => 'nett',
    'payment_method' => 'bca'
];

$calculate = \YusufTheDragon\Treasury\Transaction::calculate($bearerToken, $params);

var_dump($calculate);

\YusufTheDragon\Treasury\Transaction::getPaymentMethod(string $bearerToken);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

$getPaymentMethod = \YusufTheDragon\Treasury\Transaction::getPaymentMethod($bearerToken);

var_dump($getPaymentMethod);

\YusufTheDragon\Treasury\Transaction::buy(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'invoice_number' => 'TRS987654321',
    'unit' => 1.525,
    'total' => 981725,
    'payment_method' => 'treasury',
    'payment_channel' => 'BRIN',
    'latitude' => '-6.3853366',
    'longitude' => '106.8473377'
];

$buy = \YusufTheDragon\Treasury\Transaction::buy($bearerToken, $params);

var_dump($buy);

\YusufTheDragon\Treasury\Transaction::sell(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'total' => 981725,
    'unit' => 1.525,
    'latitude' => '-6.3853366',
    'longitude' => '106.8473377'
];

$sell = \YusufTheDragon\Treasury\Transaction::sell($bearerToken, $params);

var_dump($sell);

\YusufTheDragon\Treasury\Transaction::useVoucher(string $bearerToken, string $code);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$code = 'TRSwpL';

$useVoucher = \YusufTheDragon\Treasury\Transaction::useVoucher($bearerToken, $code);

var_dump($useVoucher);

\YusufTheDragon\Treasury\Transaction::notify(string $bearerToken, string $invoiceNumber, string $paymentNote);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$invoiceNumber = 'PNT0001',
$paymentNote = 'BCA'

$notify = \YusufTheDragon\Treasury\Transaction::notify($bearerToken, $invoiceNumber, $paymentNote);

var_dump($notify);

\YusufTheDragon\Treasury\Transaction::getBankList();

$getBankList = \YusufTheDragon\Treasury\Transaction::getBankList();

var_dump($getBankList);

\YusufTheDragon\Treasury\Minting::getMintingPartner(string $bearerToken);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

$getMintingPartner = \YusufTheDragon\Treasury\Minting::getMintingPartner($bearerToken);

var_dump($getMintingPartner);

\YusufTheDragon\Treasury\Minting::getMintingFee(string $bearerToken, string $mintingPartner);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$mintingPartner = 'x6A3lOoJXL59zDd';

$getMintingFee = \YusufTheDragon\Treasury\Minting::getMintingFee($bearerToken, $mintingPartner);

var_dump($getMintingFee);

\YusufTheDragon\Treasury\Minting::getMintingPiece(string $bearerToken, string $mintingPartner);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$mintingPartner = 'x6A3lOoJXL59zDd';

$getMintingPiece = \YusufTheDragon\Treasury\Minting::getMintingPiece($bearerToken, $mintingPartner);

var_dump($getMintingPiece);

\YusufTheDragon\Treasury\Minting::getMintingShipping(string $bearerToken, string $mintingPartner);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$mintingPartner = 'x6A3lOoJXL59zDd';

$getMintingShipping = \YusufTheDragon\Treasury\Minting::getMintingShipping($bearerToken, $mintingPartner);

var_dump($getMintingShipping);

\YusufTheDragon\Treasury\Minting::calculate(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'minting_partner' => 'x6A3lOoJXL59zDd',
    'minting_fee' => '6ynW4Kp6dX8zNgq',
    'minting_piece' => 'KQxz9YXazA14VEO',
    'minting_shipping' => 'zQdmLYAkGAgoN2D'
];

$calculate = \YusufTheDragon\Treasury\Minting::calculate($bearerToken, $params);

var_dump($calculate);

\YusufTheDragon\Treasury\Minting::minting(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'minting_partner' => 'x6A3lOoJXL59zDd',
    'minting_fee' => 'JGYPjrXW7XDw2mE',
    'minting_piece' => 'KQxz9YXazA14VEO',
    'minting_shipping' => 'zQdmLYAkGAgoN2D',
    'shipping_address' => 'Custom Address',
    'payment_method' => 'partner',
    'payment_channel' => 'BRIN',
    'latitude' => '-6.3853366',
    'longitude' => '106.8473377'
];

$minting = \YusufTheDragon\Treasury\Minting::minting($bearerToken, $params);

var_dump($minting);

\YusufTheDragon\Treasury\Profile::getProfile(string $bearerToken);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

$getProfile = \YusufTheDragon\Treasury\Profile::getProfile($bearerToken);

var_dump($getProfile);

\YusufTheDragon\Treasury\Profile::updateProfile(string $bearerToken);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

$updateProfile = \YusufTheDragon\Treasury\Profile::updateProfile($bearerToken);

var_dump($updateProfile);

\YusufTheDragon\Treasury\Profile::updatePassword(string $bearerToken, array $params);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$params = [
    'email' => '[email protected]',
    'password' => 'PassWord',
    'password_confirmation' => 'PassWord',
    'pin' => '123456'
];

$updatePassword = \YusufTheDragon\Treasury\Profile::updatePassword($bearerToken);

var_dump($updatePassword);

\YusufTheDragon\Treasury\History::getTransactionHistory(string $bearerToken, string $type);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$type = 'buy';

$getTransactionHistory = \YusufTheDragon\Treasury\History::getTransactionHistory($bearerToken, $type);

var_dump($getTransactionHistory);

\YusufTheDragon\Treasury\History::getTransactionDetail(string $bearerToken, string $type, string $invoiceNo);

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';
$type = 'buy';
$invoiceNo = 'TRS64065803';

$getTransactionDetail = \YusufTheDragon\Treasury\History::getTransactionDetail($bearerToken, $type, $invoiceNo);

var_dump($getTransactionDetail);
bash
composer