using Treasury API v2.2, please make sure Treasury API version you gonna use and read API procedure below for flow of registration and transaction.
Install package with composer by following command:
composer require ryuamy/trs-emas-php
Add following code on your project:
use Ryuamy\TrsEmas;
TrsEmas\Class::function( $productionFlag, $bodyParameters, $token );
Parameters detail:
- $productionFlag: if set to true, package will hit Treasury production API, false to hit Treasury staging API. Mandatory on all class.
- $bodyParameters: request body parameter. Optional on some Class.
- $token: bearer token from client login (for User Register) or user login (for the rest of API). Optional on some class.
Look at example to see parameter requirement on each class.
$bodyParameters = [
'client_id' => '(Treasury client id)',
'client_secret' => '(Treasury client secret)',
];
$Tresury = TrsEmas\Authentication::loginClient( true, $bodyParameters );
$bodyParameters = [
'name' => 'Ryu Amy',
'email' => 'ryuamy.mail@gmail.com',
'password' => '(My Password)',
'password_confirmation' => '(My Password)',
'gender' => 'female',
'birthday' => '1991-01-01',
'referral_code' => '',
'phone' => '081312345678',
'security_question' => 'KQxz9YXazA14VEO',
'security_question_answer' => 'Sebastian Michaelis',
'selfie_scan' => '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQ...',
'id_card_scan' => '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQ...',
'owner_name' => 'Ryu Amy',
'account_number' => '123456',
'bank_code' => 'string',
'branch' => 'Jakarta',
'customer_concern' => false
];
$Tresury = TrsEmas\Authentication::register( true, $bodyParameters, '(Bearer Token)' );
Notes:
- Bearer Token get from Client Login response
- security_question value using Security Question response
- bank_code value using Bank List response
$bodyParameters = [
'client_id' => '(Treasury client id)',
'client_secret' => '(Treasury client secret)',
'email' => 'ryuamy.mail@gmail.com',
'password' => '(My Password)',
];
$Tresury = TrsEmas\Authentication::login( true, $bodyParameters );
$bodyParameters = [
'start_date' => '2021-03-03 09:00:00',
'end_date' => '2021-03-03 10:00:00'
];
$Tresury = TrsEmas\Transaction::goldRate( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'currency',
'amount' => 400000,
'payment_method' => 'bca',
];
$Tresury = TrsEmas\Transaction::calculateBuy( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'gold',
'amount' => 0.582,
'payment_method' => 'bca',
];
$Tresury = TrsEmas\Transaction::calculateBuy( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'currency',
'amount' => 50000,
];
$Tresury = TrsEmas\Transaction::calculateSell( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'gold',
'amount' => 0.015,
];
$Tresury = TrsEmas\Transaction::calculateSell( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'currency',
'amount' => 400000,
];
$Tresury = TrsEmas\Transaction::calculateBuyPartner( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'gold',
'amount' => 0.582,
];
$Tresury = TrsEmas\Transaction::calculateBuyPartner( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'currency',
'amount' => 50000,
];
$Tresury = TrsEmas\Transaction::calculateSellPartner( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'amount_type' => 'gold',
'amount' => 0.015,
];
$Tresury = TrsEmas\Transaction::calculateSellPartner( true, $bodyParameters, '(Bearer Token)' );
$Tresury = TrsEmas\Transaction::paymentMethod( true, '(Bearer Token)' );
$bodyParameters = [
'unit' => 1.8766253,
'total' => 796169,
'payment_channel' => 'BRIN',
'latitude' => '-6.914744',
'longitude' => '107.609810'
];
$Tresury = TrsEmas\Transaction::buy( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'invoice_number' => 'TRS42154451',
'unit' => 1.8766253,
'total' => 796169,
'payment_channel' => 'BRIN',
'latitude' => '-6.914744',
'longitude' => '107.609810'
];
$Tresury = TrsEmas\Transaction::buyPartner( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'code' => 'TRSVCR1',
];
$Tresury = TrsEmas\Transaction::applyVoucher( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'invoice_number' => 'TRS42154451',
'payment_note' => 'Payment to BRI'
];
$Tresury = TrsEmas\Transaction::paymentNotify( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'total' => 31587,
'unit' => 0.0432,
'latitude' => '-6.914744',
'longitude' => '107.609810'
];
$Tresury = TrsEmas\Transaction::sell( true, $bodyParameters, '(Bearer Token)' );
$Tresury = TrsEmas\Minting::mintingPartner( true, '(Bearer Token)' );
$bodyParameters = [
'minting_partner' => 'x6A3lOoJXL59zDd'
];
$Tresury = TrsEmas\Minting::mintingFee( true, $bodyParameters, '(Bearer Token)' );
Notes:
- minting_partner value using Minting Partner response
$bodyParameters = [
'minting_partner' => 'x6A3lOoJXL59zDd'
];
$Tresury = TrsEmas\Minting::mintingPiece( true, $bodyParameters, '(Bearer Token)' );
Notes:
- minting_partner value using Minting Partner response
$bodyParameters = [
'minting_partner' => 'x6A3lOoJXL59zDd'
];
$Tresury = TrsEmas\Minting::mintingShipping( true, $bodyParameters, '(Bearer Token)' );
Notes:
- minting_partner value using Minting Partner response
$bodyParameters = [
'minting_partner' => 'x6A3lOoJXL59zDd',
'minting_fee' => 'JGYPjrXW7XDw2mE',
'minting_piece' => 'KQxz9YXazA14VEO',
'minting_shipping' => '7Jb1VXLrzpm69xv'
];
$Tresury = TrsEmas\Minting::calculateMinting( true, $bodyParameters, '(Bearer Token)' );
Notes:
- minting_partner value using Minting Partner response
- minting_fee value using Minting Fee response
- minting_piece value using Minting Piece response
- minting_shipping value using Minting Shipping response
$bodyParameters = [
'minting_partner' => 'x6A3lOoJXL59zDd',
'minting_fee' => 'JGYPjrXW7XDw2mE',
'minting_piece' => 'KQxz9YXazA14VEO',
'minting_shipping' => '7Jb1VXLrzpm69xv',
'shipping_address' => 'Jalan Prapanca, Jakarta Selatan',
'payment_channel' => 'BRIN',
'latitude' => '-6.914744',
'longitude' => '107.609810',
];
$Tresury = TrsEmas\Minting::goldMinting( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'minting_partner' => 'x6A3lOoJXL59zDd',
'minting_fee' => 'JGYPjrXW7XDw2mE',
'minting_piece' => 'KQxz9YXazA14VEO',
'minting_shipping' => '7Jb1VXLrzpm69xv',
'shipping_address' => 'Jalan Prapanca, Jakarta Selatan',
'payment_channel' => 'BRIN',
'latitude' => '-6.914744',
'longitude' => '107.609810',
];
$Tresury = TrsEmas\Minting::goldMintingPartner( true, $bodyParameters, '(Bearer Token)' );
$Tresury = TrsEmas\User::profile( true, '(Bearer Token)' );
only get Treasury update profile URL
$Tresury = TrsEmas\User::updateProfile( true, '(Bearer Token)' );
$bodyParameters = [
'email' => 'ryuamy.mail@gmail.com',
'password' => '(New Password)',
'password_confirmation' => '(New Password)',
'pin' => '12345',
];
$Tresury = TrsEmas\User::updatePassword( true, $bodyParameters, '(Bearer Token)' );
$Tresury = TrsEmas\History::buyGoldHistory( true, '(Bearer Token)' );
$Tresury = TrsEmas\History::sellGoldHistory( true, '(Bearer Token)' );
$Tresury = TrsEmas\History::goldMintingHistory( true, '(Bearer Token)' );
$bodyParameters = [
'invoice_no' => 'TRS42154451',
];
$Tresury = TrsEmas\History::buyGoldDetailHistory( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'invoice_no' => 'TRS42154451',
];
$Tresury = TrsEmas\History::sellGoldDetailHistory( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'invoice_no' => 'TRS42154451',
];
$Tresury = TrsEmas\History::goldMintingDetailHistory( true, $bodyParameters, '(Bearer Token)' );
$bodyParameters = [
'email' => 'ryuamy.mail@gmail.com',
];
$Tresury = TrsEmas\Additional::checkEmailAvailability( true, $bodyParameters );
$Tresury = TrsEmas\Additional::securityQuestion( true );
$Tresury = TrsEmas\Additional::bankList( true );
- Get Bearer Token from Client Login API
- Get security code list from Security Question API
- Get bank list from Bank List API
- Do customer registration
To create gold transaction with treasury payment method, the following procedure is:
- Get gold rate.
- Calculate gold transaction with currency or unit. Gold unit support can be up to 4 digits.
- Get payment method list to take payment_code response.
- Do transactions with endpoints gold buy and sell gold.
To create gold transaction with partner payment method, the following procedure is:
- Get gold rate.
- Calculate gold transaction with currency or unit. Gold unit support can be up to 4 digits
- Do transactions with endpoints gold buy and sell gold.
- Hit endpoint payment notify to ensure payment has been successful.
- Get minting partner list.
- Check minting fee of selected partner.
- Check available minting piece of selected partner.
- Calculate total minting payment.
- Get payment method list to take payment_code response.
- Do transactions.