> For the complete documentation index, see [llms.txt](https://laravel-dana.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://laravel-dana.gitbook.io/docs/product-guides/how-to-use.md).

# How to use

<details>

<summary>Create Order</summary>

```php
<?php
...
use Otnansirk\Dana\Facades\DANAPay;
...

$orderData = [
    [
    "order" => [
        "orderTitle" => "Dummy product",
        "orderAmount" => [
            "currency" => "IDR",
            "value" => "100"
        ],
        "merchantTransId" => "201505080001",
        "merchantTransType" => "dummy transaction type",
        "orderMemo" => "Memo",
        "goods" => [
            [
                "merchantGoodsId" => "24525635625623",
                "description" => "dummy description",
                "category" => "dummy category",
                "price" => [
                    "currency" => "IDR",
                    "value" => "100"
                ],
                "unit" => "Kg",
                "quantity" => "3.2",
                "merchantShippingId" => "564314314574327545",
                "snapshotUrl" => "[http://snap.url.com]",
                "extendInfo" => [
                    "key" => "value",
                ]
            ]
        ]
    ],
    "merchantId" => "216820000000006553000",
    "subMerchantId" => "12345678",
    "productCode" => "51051000100000000001"
];

DANAPay::createOrder($orderData);
```

About all possible payloads for `$orderData` please check the official DANA documentation.\
Ref: <https://dashboard.dana.id/api-docs/read/33>

</details>

<details>

<summary>Query Order</summary>

Get transaction detail and status.

```php
<?php
$acquirementId = "20240125111212800110166050101920928"; 
DANAPay::queryOrder($acquirementId);
```

For more information please check the official DANA documentation.\
Ref : <https://dashboard.dana.id/api-docs/read/42>\
Ref Status Enum : <https://dashboard.dana.id/api-docs/read/31#StatusDetailEnum>

</details>

<details>

<summary><strong>Get oAuth URL</strong></summary>

Generate an oAuth URL for the specified terminal type and redirect URL.

```php
<?php
...
use Otnansirk\Dana\Facades\DANAPay;
...

$terminalType = "WEB";
$redirectUrl  = "https://your-app-url.com/oauth/callback"
$oAuthUrl = DANAPay::generateOauthUrl($terminalType, $redirectUrl);

```

For more information please check the official DANA documentation.\
Ref: <https://dashboard.dana.id/api-docs/read/47>

</details>

<details>

<summary>Get Token &#x26; Refresh Token</summary>

```php
<?php
...
use Otnansirk\Dana\Facades\DANAPay;
...

$authToken = "your-auth-token";
$accessToken = DANAPay::getToken($authToken);
```

You can get value of ***`$authToken`*** from oAuth callback process.\
From this function you will receive `token` and `refresh_token`.\
Ref: <https://dashboard.dana.id/api-docs/read/32>

</details>

<details>

<summary>Get Profile</summary>

```php
<?php
...
use Otnansirk\Dana\Facades\DANAPay;
...

$accessToken = "your_user_profile_access_token";
$profile = DANAPay::profile($accessToken);
```

You can get value for `$accessToken` from [DANAPay::getToken](#get-token-and-refresh-token) function\
Ref: <https://dashboard.dana.id/api-docs/read/38>

</details>

<details>

<summary>Unbinding Access Token</summary>

```php
<?php
...
use Otnansirk\Dana\Facades\DANAPay;
...

DANAPay::unBindAllAccount();
```

This function used for revoke or unbind all access token registered from the merchant.\
Ref: <https://dashboard.dana.id/api-docs/read/46>

</details>

<details>

<summary>MDR Calculation</summary>

```php
<?php
...
use Otnansirk\Dana\Facades\DANAPay;
...

$payAmount = 100000;
$payMethod = 'BALANCE';
$mdr = DANACalculation::calculateMDR($payAmount, $payMethod);
```

This function will calculate MDR fee for DANA.&#x20;

You will get value *$payMethod* and *$payAmount* from callback DANA notification.

</details>
