esyede/lara-dana 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

esyede/lara-dana

最新稳定版本:v1.0.0

Composer 安装命令:

composer require esyede/lara-dana

包简介

Unofficial Dana Payment API package for Laravel

README 文档

README

Unofficial Dana Payment API package for Laravel. Visit https://dashboard.dana.id/api-docs for more detailed documentations.

Requirements

  • Laravel >= 10.0

Installation

1. Install this package via composer:

composer require esyede/lara-dana

2. Publish the config file:

php artisan vendor:publish --provider="Esyede\Dana\DanaCoreServiceProvider"

Usage

Configs are stored in config/dana.php. Customize those with your own credentials.

Functions

1. Create order

$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' => [
                    'myInvoiceId' => 'T12345678ASDFG', // optional
                    'remark' => 'DEBIT', // optional
                ]
            ]
        ]
    ],
    'merchantId' => '216820000000006553000',
    'subMerchantId' => '12345678',
    'productCode' => '51051000100000000001',
];

DanaPayment::createOrder($orderData);

For more detailed documentation, visit https://dashboard.dana.id/api-docs/read/33

2. Get oAuth URL

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

For more detailed documentation, visit https://dashboard.dana.id/api-docs/read/47

3. Get Request & Refresh Token

$authToken = 'your-auth-token';
DanaPayment::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

4. Get User Profile

$accessToken = 'your_user_profile_access_token';
DanaPayment::profile($accessToken);

Fill the $accessToken with the response of DanaPayment::getToken(), ref: https://dashboard.dana.id/api-docs/read/38

5. Unbinding Access Token

DanaPayment::unbindAllAccount();

This method is used to revoke or unbind all access token registered from the merchant. ref: https://dashboard.dana.id/api-docs/read/46

6. Hnadling callback response

$status = true;
DanaPayment::handleFinishNotifyCallback($status);

This function will generate valid response for Dana API. $status is boolean.

6. Function for calculation MDR

$payAmount = 100000;
$payMethod = 'BALANCE';
DanaCalculation::calculateMDR($payAmount, $payMethod);

This function will calculate MDR fee for dana. Fill the $payMethod and $payAmount from dana callback data.

Contribution

This project is far from perfect. many of dna APIs isn't implemented yet. I would be really happy if any of you could contribute to implement it.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-15