This Laravel wrapper/library for DANA Payment API. Visit https://dana.id for more information about the product and see documentation at https://dashboard.dana.id/api-docs for more technical details.
- PHP 8.1 or higher
- Laravel 9.x, 10.x, 11.x, or 12.x
composer require otnansirk/laravel-dana
2. The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php
file.
'providers' => [
// ...
Otnansirk\Dana\DanaCoreServiceProvider::class,
];
php artisan vendor:publish --provider="Otnansirk\Dana\DanaCoreServiceProvider" --tag="dana-config"
All configuration are stored in config/dana.php
. Customize everything you need.
Make sure to set the following environment variables in your .env
file:
DANA_ENV=development
DANA_ACTIVE=false
DANA_API_URL=https://api-sandbox.saas.dana.id
DANA_WEB_URL=https://m.sandbox.dana.id
DANA_MARCHANT_ID=your_merchant_id
DANA_CLIENT_ID=your_client_id
DANA_CLIENT_SECRET=your_client_secret
DANA_ORDER_NOTIFY_URL=your_notify_url
DANA_PAY_RETURN_URL=your_return_url
DANA_PUB_KEY=your_public_key
DANA_PRIVATE_KEY=your_private_key
$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
$acquirementId = "20240125111212800110166050101920928";
DANAPay::queryOrder($acquirementId);
You can get transaction detail and status transaction with this method
Ref: https://dashboard.dana.id/api-docs/read/42
$terminalType = "WEB";
$redirectUrl = "https://your-app-url.com/oauth/callback";
DANAPay::generateOauthUrl($terminalType, $redirectUrl);
For more information please check the official DANA documentation.
Ref: https://dashboard.dana.id/api-docs/read/47
$authToken = "your-auth-token";
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
$accessToken = "your_user_profile_access_token";
DANAPay::profile($accessToken);
You can get value for $accessToken
from DANAPay::getToken
function
Ref: https://dashboard.dana.id/api-docs/read/38
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
$status = true;
DANAPay::responseFinishNotifyCallback($status);
This function will generate valid response for DANA API.
$status
is boolean data type.
$payAmount = 100000;
$payMethod = 'BALANCE';
DANACalculation::calculateMDR($payAmount, $payMethod);
This function will calculate MDR fee for DANA.
You will get value $payMethod
and $payAmount
from callback DANA.
composer test
This package supports multiple Laravel versions:
Laravel Version | PHP Version | Status |
---|---|---|
Laravel 9.x | PHP 8.1+ | ✅ Supported |
Laravel 10.x | PHP 8.1+ | ✅ Supported |
Laravel 11.x | PHP 8.2+ | ✅ Supported |
Laravel 12.x | PHP 8.2+ | ✅ Supported |
Please see CHANGELOG.md for a list of what has changed since the last version.
This project is far from perfect. Many DANA APIs that have not been implemented. I would be very happy if any of you could contribute to this project.
The MIT License (MIT). Please see License File for more information.