> For the complete documentation index, see [llms.txt](https://docs.payon.com.kh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payon.com.kh/payons-library/how-to-use-payon-library.md).

# How to use PayOn Library

Sign is a digital signature for verifying the authenticity of digital messages or documents. Only a valid API's sign can be interact with PAYON's server.

## Initialize PAYON's Library&#x20;

{% tabs %}
{% tab title="JAVA" %}

```java
import com.payon.pg.aggregator.ecommerce.gateway.client.CheckoutURIBuilder;
import com.payon.pg.aggregator.ecommerce.gateway.client.CheckoutURIBuilder.Environment;

public class OrderController {

    public static void main(String[] args) throws IOException, InterruptedException {

	CheckoutURIBuilder checkoutURIBuilder = CheckoutURIBuilder.builder()
						.env(Environment.UAT)// UAT:for TEST,PRODUCTION: production
						.apiKey(YOUR API KEY)
						.merchantId(YOUR MERCHANT ID)
						.termId(YOUR TERMINAL ID)
						.txId(YOUR TRANSACTION ID)
						.amount(YOUR CHECK OUT AMOUNT)
						.currency(YOUR CURRENCY)
						.build();
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
	require_once('CheckoutURIBuilder.php');
	$lang        = "en";
	$merchantId  = "YOUR MERCHANT ID";
	$termId      = "YOUR TERM ID";
	$amount      = "YOUR CHECK OUT AMOUNT";
	$txId        = "YOUR TRANSACTION ID";
	$currency    = "YOUR CURRENCY";
	$apiKey        = "YOUR API KEY";
	$checkoutURIBuilder = new CheckoutURIBuilder($lang, $merchantId, $termId, $txId, $amount, $currency, $redirectUri, $apiKey);
	$env = new Environment();
	// get test url function $env::getTestUrl() and get real url function $env::getRealUrl()
	$url = $checkoutURIBuilder::toCheckoutUrlString($env::getTestUrl());
	echo "<a href='".$url."'>Click to Pay</a><br/>";
	
?>
	
```

{% endtab %}
{% endtabs %}

### Get Checkout Link

{% tabs %}
{% tab title="JAVA" %}

```
String checkoutURI = checkoutURIBuilder.toCheckoutUrlString()
```

{% endtab %}

{% tab title="PHP" %}

```php
 <?php
     $checkoutURI = $checkoutURIBuilder::toCheckoutUrlString();
 ?>
```

{% endtab %}
{% endtabs %}

### Get API's Signature

{% tabs %}
{% tab title="JAVA" %}

```java
String sign = checkoutURIBuilder.getSign()
```

{% endtab %}

{% tab title="PHP" %}

```php
 <?php
     $checkoutURI = $checkoutURIBuilder::getSign();
 ?>
```

{% endtab %}
{% endtabs %}

### Arguments

| env        | environment mode(TEST,PRODUCTION)                              |
| ---------- | -------------------------------------------------------------- |
| apiKey     | Merchant's API key, will provided after merchant registration. |
| termId     | Merchant's terminal identification                             |
| merchantId | Merchant's identification                                      |
| amount     | Total amount                                                   |
| Currency   | Currency code (KHR, USD)                                       |
