PHPackages                             ryuamy/trs-emas-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ryuamy/trs-emas-php

ActiveLibrary[API Development](/categories/api)

ryuamy/trs-emas-php
===================

Treasury PHP API Third Party Library

00PHP

Since Jul 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ryuamy/trs-emas-php)[ Packagist](https://packagist.org/packages/ryuamy/trs-emas-php)[ RSS](/packages/ryuamy-trs-emas-php/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Treasury API Third Party PHP Package
====================================

[](#treasury-api-third-party-php-package)

[![license](https://camo.githubusercontent.com/88cabb0aa9b8538c8e04066e31a1998755769870066fe7914fe95a2e131deb99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f727975616d792f7472732d656d61732d7068703f636f6c6f723d677265656e)](https://packagist.org/packages/ryuamy/trs-emas-php)[![release](https://camo.githubusercontent.com/fe2ef6c102e0a9ecc652eb44cf0c23dd5ad45fa0897de56d10a4d6385a70f8ca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f727975616d792f7472732d656d61732d7068703f636f6c6f723d6f72616e676526696e636c7564655f70726572656c6561736573)](https://packagist.org/packages/ryuamy/trs-emas-php)

using [Treasury](https://www.treasury.id/) API v2.2, please make sure Treasury API version you gonna use and read API [procedure below](#procedure) for flow of registration and transaction.

Instalation
-----------

[](#instalation)

Install package with composer by following command:

```
composer require ryuamy/trs-emas-php

```

Call Package
------------

[](#call-package)

Add following code on your project:

```
use Ryuamy\TrsEmas;
```

Usages
------

[](#usages)

```
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](#example) to see parameter requirement on each class.

Example
-------

[](#example)

### Authentication

[](#authentication)

#### Client Login

[](#client-login)

```
$bodyParameters = [
    'client_id' => '(Treasury client id)',
    'client_secret' => '(Treasury client secret)',
];

$Tresury = TrsEmas\Authentication::loginClient( true, $bodyParameters );
```

#### User Register

[](#user-register)

```
$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](#client-login) response
- security\_question value using [Security Question](#security-question) response
- bank\_code value using [Bank List](#bank-list) response

#### User Login

[](#user-login)

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

### Transaction

[](#transaction)

#### Gold Rate

[](#gold-rate)

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

#### Calculate Buy Amount Type Currency

[](#calculate-buy-amount-type-currency)

```
$bodyParameters = [
    'amount_type' => 'currency',
    'amount' => 400000,
    'payment_method' => 'bca',
];

$Tresury = TrsEmas\Transaction::calculateBuy( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Buy Amount Type Gold

[](#calculate-buy-amount-type-gold)

```
$bodyParameters = [
    'amount_type' => 'gold',
    'amount' => 0.582,
    'payment_method' => 'bca',
];

$Tresury = TrsEmas\Transaction::calculateBuy( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Sell Amount Type Currency

[](#calculate-sell-amount-type-currency)

```
$bodyParameters = [
    'amount_type' => 'currency',
    'amount' => 50000,
];

$Tresury = TrsEmas\Transaction::calculateSell( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Sell Amount Type Gold

[](#calculate-sell-amount-type-gold)

```
$bodyParameters = [
    'amount_type' => 'gold',
    'amount' => 0.015,
];

$Tresury = TrsEmas\Transaction::calculateSell( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Buy Amount Type Currency For Partner

[](#calculate-buy-amount-type-currency-for-partner)

```
$bodyParameters = [
    'amount_type' => 'currency',
    'amount' => 400000,
];

$Tresury = TrsEmas\Transaction::calculateBuyPartner( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Buy Amount Type Gold For Partner

[](#calculate-buy-amount-type-gold-for-partner)

```
$bodyParameters = [
    'amount_type' => 'gold',
    'amount' => 0.582,
];

$Tresury = TrsEmas\Transaction::calculateBuyPartner( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Sell Amount Type Currency For Partner

[](#calculate-sell-amount-type-currency-for-partner)

```
$bodyParameters = [
    'amount_type' => 'currency',
    'amount' => 50000,
];

$Tresury = TrsEmas\Transaction::calculateSellPartner( true, $bodyParameters, '(Bearer Token)' );
```

#### Calculate Sell Amount Type Gold For Partner

[](#calculate-sell-amount-type-gold-for-partner)

```
$bodyParameters = [
    'amount_type' => 'gold',
    'amount' => 0.015,
];

$Tresury = TrsEmas\Transaction::calculateSellPartner( true, $bodyParameters, '(Bearer Token)' );
```

#### Payment Method

[](#payment-method)

```
$Tresury = TrsEmas\Transaction::paymentMethod( true, '(Bearer Token)' );
```

#### Buy Gold

[](#buy-gold)

```
$bodyParameters = [
    'unit' => 1.8766253,
    'total' => 796169,
    'payment_channel' => 'BRIN',
    'latitude' => '-6.914744',
    'longitude' => '107.609810'
];

$Tresury = TrsEmas\Transaction::buy( true, $bodyParameters, '(Bearer Token)' );
```

#### Buy Gold For Partner

[](#buy-gold-for-partner)

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

#### Apply Voucer Buy Gold

[](#apply-voucer-buy-gold)

```
$bodyParameters = [
    'code' => 'TRSVCR1',
];

$Tresury = TrsEmas\Transaction::applyVoucher( true, $bodyParameters, '(Bearer Token)' );
```

#### Payment Notify For Partner

[](#payment-notify-for-partner)

```
$bodyParameters = [
    'invoice_number' => 'TRS42154451',
    'payment_note' => 'Payment to BRI'
];

$Tresury = TrsEmas\Transaction::paymentNotify( true, $bodyParameters, '(Bearer Token)' );
```

#### Sell Gold

[](#sell-gold)

```
$bodyParameters = [
    'total' => 31587,
    'unit' => 0.0432,
    'latitude' => '-6.914744',
    'longitude' => '107.609810'
];

$Tresury = TrsEmas\Transaction::sell( true, $bodyParameters, '(Bearer Token)' );
```

### Minting

[](#minting)

#### Minting Partner

[](#minting-partner)

```
$Tresury = TrsEmas\Minting::mintingPartner( true, '(Bearer Token)' );
```

#### Minting Fee

[](#minting-fee)

```
$bodyParameters = [
    'minting_partner' => 'x6A3lOoJXL59zDd'
];

$Tresury = TrsEmas\Minting::mintingFee( true, $bodyParameters, '(Bearer Token)' );
```

Notes:

- minting\_partner value using [Minting Partner](#minting-partner) response

#### Minting Piece

[](#minting-piece)

```
$bodyParameters = [
    'minting_partner' => 'x6A3lOoJXL59zDd'
];

$Tresury = TrsEmas\Minting::mintingPiece( true, $bodyParameters, '(Bearer Token)' );
```

Notes:

- minting\_partner value using [Minting Partner](#minting-partner) response

#### Minting Shipping

[](#minting-shipping)

```
$bodyParameters = [
    'minting_partner' => 'x6A3lOoJXL59zDd'
];

$Tresury = TrsEmas\Minting::mintingShipping( true, $bodyParameters, '(Bearer Token)' );
```

Notes:

- minting\_partner value using [Minting Partner](#minting-partner) response

#### Calculate Minting

[](#calculate-minting)

```
$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](#minting-partner) response
- minting\_fee value using [Minting Fee](#minting-fee) response
- minting\_piece value using [Minting Piece](#minting-piece) response
- minting\_shipping value using [Minting Shipping](#minting-shipping) response

#### Gold Minting

[](#gold-minting)

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

#### Gold Minting For Partner

[](#gold-minting-for-partner)

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

### User

[](#user)

#### Get Profile

[](#get-profile)

```
$Tresury = TrsEmas\User::profile( true, '(Bearer Token)' );
```

#### Update Profile

[](#update-profile)

only get Treasury update profile URL

```
$Tresury = TrsEmas\User::updateProfile( true, '(Bearer Token)' );
```

#### Update Password

[](#update-password)

```
$bodyParameters = [
    'email' => 'ryuamy.mail@gmail.com',
    'password' => '(New Password)',
    'password_confirmation' => '(New Password)',
    'pin' => '12345',
];

$Tresury = TrsEmas\User::updatePassword( true, $bodyParameters, '(Bearer Token)' );
```

### History

[](#history)

#### Buy Gold History

[](#buy-gold-history)

```
$Tresury = TrsEmas\History::buyGoldHistory( true, '(Bearer Token)' );
```

#### Sell Gold History

[](#sell-gold-history)

```
$Tresury = TrsEmas\History::sellGoldHistory( true, '(Bearer Token)' );
```

#### Gold Minting History

[](#gold-minting-history)

```
$Tresury = TrsEmas\History::goldMintingHistory( true, '(Bearer Token)' );
```

#### Buy Gold Detail History

[](#buy-gold-detail-history)

```
$bodyParameters = [
    'invoice_no' => 'TRS42154451',
];

$Tresury = TrsEmas\History::buyGoldDetailHistory( true, $bodyParameters, '(Bearer Token)' );
```

#### Sell Gold Detail History

[](#sell-gold-detail-history)

```
$bodyParameters = [
    'invoice_no' => 'TRS42154451',
];

$Tresury = TrsEmas\History::sellGoldDetailHistory( true, $bodyParameters, '(Bearer Token)' );
```

#### Gold Minting Detail History

[](#gold-minting-detail-history)

```
$bodyParameters = [
    'invoice_no' => 'TRS42154451',
];

$Tresury = TrsEmas\History::goldMintingDetailHistory( true, $bodyParameters, '(Bearer Token)' );
```

### Additional

[](#additional)

#### Check Email Availability

[](#check-email-availability)

```
$bodyParameters = [
    'email' => 'ryuamy.mail@gmail.com',
];

$Tresury = TrsEmas\Additional::checkEmailAvailability( true, $bodyParameters );
```

#### Security Question

[](#security-question)

```
$Tresury = TrsEmas\Additional::securityQuestion( true );
```

#### Bank List

[](#bank-list)

```
$Tresury = TrsEmas\Additional::bankList( true );
```

Procedure
---------

[](#procedure)

### Registration

[](#registration)

1. Get Bearer Token from Client Login API
2. Get security code list from Security Question API
3. Get bank list from Bank List API
4. Do customer registration

### Gold Transaction

[](#gold-transaction)

To create gold transaction with treasury payment method, the following procedure is:

1. Get gold rate.
2. Calculate gold transaction with currency or unit. Gold unit support can be up to 4 digits.
3. Get payment method list to take payment\_code response.
4. Do transactions with endpoints gold buy and sell gold.

To create gold transaction with partner payment method, the following procedure is:

1. Get gold rate.
2. Calculate gold transaction with currency or unit. Gold unit support can be up to 4 digits
3. Do transactions with endpoints gold buy and sell gold.
4. Hit endpoint payment notify to ensure payment has been successful.

### Minting or Cetak Emas

[](#minting-or-cetak-emas)

1. Get minting partner list.
2. Check minting fee of selected partner.
3. Check available minting piece of selected partner.
4. Calculate total minting payment.
5. Get payment method list to take payment\_code response.
6. Do transactions.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0fce8d03dbe72f0f67332bf5e0bfc7a4b9fa512dbc27e8a4573d962e64a16a2?d=identicon)[ryuamy](/maintainers/ryuamy)

---

Top Contributors

[![ryuamy](https://avatars.githubusercontent.com/u/79897981?v=4)](https://github.com/ryuamy "ryuamy (5 commits)")[![laksmisetiawati](https://avatars.githubusercontent.com/u/35263876?v=4)](https://github.com/laksmisetiawati "laksmisetiawati (4 commits)")

---

Tags

emasgold-ratepackagephpthird-partytreasury

### Embed Badge

![Health badge](/badges/ryuamy-trs-emas-php/health.svg)

```
[![Health](https://phpackages.com/badges/ryuamy-trs-emas-php/health.svg)](https://phpackages.com/packages/ryuamy-trs-emas-php)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
