Skip to content

yusufthedragon/treasury-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Treasury API Client for PHP

Unofficial PHP wrapper/library for access Treasury API.


Installation

Install the Package

Install treasury-php with composer by following command:

composer require yusufthedragon/treasury-php

or add it manually in your composer.json file.

Set to Production Mode

When deploying your application to production, you may want to change API Endpoint to production as well by setting setProductionMode to true.

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

Usages and Examples

Authentication

Login Client Credentials

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

Usage example:

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

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

var_dump($loginClient);

Register New User

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

Usage example:

$params = [
    'name' => 'John Doe',
    'email' => 'john@doe.com',
    '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);

Login

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

Usage example:

$params = [
    'client_id' => '115823',
    'client_secret' => 'masdh12km3bf09dbkjlm13bkcsv0asdb1249gss2',
    'grant_type' => 'password',
    'email' => 'john@doe.com',
    'password' => 'JohnDoe'
];

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

var_dump($login);

Forgot Password

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

Usage example:

$forgotPassword = \YusufTheDragon\Treasury\Auth::forgotPassword('john@doe.com');

var_dump($forgotPassword);

Transaction

Get Gold Price

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

Usage example:

$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);

Calculate Gold Amount

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

Usage example:

$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);

Get Available Payment Methods

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

Usage example:

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

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

var_dump($getPaymentMethod);

Buy Gold

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

Usage example:

$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);

Sell Gold

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

Usage example:

$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);

Use Voucher

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

Usage example:

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

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

var_dump($useVoucher);

Notify Payment

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

Usage example:

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

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

var_dump($notify);

Get Available Banks

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

Usage example:

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

var_dump($getBankList);

Minting

Get Minting Partner

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

Usage example:

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

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

var_dump($getMintingPartner);

Get Minting Fee

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

Usage example:

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

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

var_dump($getMintingFee);

Get Minting Piece

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

Usage example:

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

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

var_dump($getMintingPiece);

Get Minting Shipping

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

Usage example:

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

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

var_dump($getMintingShipping);

Calculate Gold Minting

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

Usage example:

$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);

Minting Gold

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

Usage example:

$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);

Profile

Get Profile

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

Usage example:

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

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

var_dump($getProfile);

Update Profile

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

Usage example:

$bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI';

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

var_dump($updateProfile);

Update Password

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

Usage example:

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

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

var_dump($updatePassword);

History

Get Transaction History

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

Usage example:

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

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

var_dump($getTransactionHistory);

Get Detail Transaction History

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

Usage example:

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

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

var_dump($getTransactionDetail);

License

This library is open-sourced software licensed under the GPL-3.0-only License.

Contributing

For any requests, bugs, or comments, please open an issue or submit a pull request.