承接 otnansirk/laravel-dana 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

otnansirk/laravel-dana

Composer 安装命令:

composer require otnansirk/laravel-dana

包简介

This Laravel wrapper for DANA Payment API

README 文档

README

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.

Requirements

  • PHP 8.1 or higher
  • Laravel 9.x, 10.x, 11.x, or 12.x

Installation

1. You can install the package via composer.

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,
];

3. You should publish the config/dana.php config file with this php artisan command.

php artisan vendor:publish --provider="Otnansirk\Dana\DanaCoreServiceProvider" --tag="dana-config"

Configuration

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

Usage

1. Create order | DANAPay::createOrder($orderData)

$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

2. Get Transaction by acquirementId | DANAPay::queryOrder($acquirementId)

$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

3. Get oAuth URL | DANAPay::generateOauthUrl($terminalType, $redirectUrl)

$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

4. Get Token and Refresh Token | DANAPay::getToken($authToken)

$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

5. Get User Profile | DANAPay::profile($accessToken)

$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

6. Unbinding Access Token | DANAPay::unBindAllAccount()

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

7. Function for provide callback response

$status = true;
DANAPay::responseFinishNotifyCallback($status);

This function will generate valid response for DANA API.
$status is boolean data type.

8. Function for calculation MDR

$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.

Testing

composer test

Laravel Version Compatibility

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

Changelog

Please see CHANGELOG.md for a list of what has changed since the last version.

Contributing

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.

License

The MIT License (MIT). Please see License File for more information.

otnansirk/laravel-dana 适用场景与选型建议

otnansirk/laravel-dana 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 371 次下载、GitHub Stars 达 33, 最近一次更新时间为 2022 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payment」 「payment gateway」 「otnansirk」 「laravel-DANA」 「DANA Laravel」 「dana payment gateway」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 otnansirk/laravel-dana 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 otnansirk/laravel-dana 我们能提供哪些服务?
定制开发 / 二次开发

基于 otnansirk/laravel-dana 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 371
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 33
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 33
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-01