承接 vant/vant-laravel 相关项目开发

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

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

vant/vant-laravel

最新稳定版本:1.0.0

Composer 安装命令:

composer require vant/vant-laravel

包简介

A Laravel package for Vant API integration

README 文档

README

Introduction

Vant Laravel API is a Laravel package for interacting with the Vant API, providing a simple interface for handling payments, transfers, and transactions within a Laravel application.

Features

  • Retrieve banks list
  • Verify transfer recipients
  • Initiate transfers
  • Create wallets
  • Fetch transaction history
  • Verify transactions
  • Handle webhooks securely

Installation

Step 1: Install via Composer

Run the following command to install the package:

composer require vant/vant-laravel

Step 2: Publish Configuration

After installation, publish the package configuration file:

php artisan vendor:publish --tag=config

This will create a config/vant.php file where you can configure API settings.

Step 3: Set Up Environment Variables

Update your .env file with your API credentials:

VANT_API_BASE_URL=https://dev.vantapp.com/api/partner/
VANT_API_KEY=your-api-key
VANT_API_SIGNATURE=your-signature

Usage

Using Dependency Injection

You can inject the VantApi service into your controllers or services:

use Vant\VantLaravel\Services\VantApi;

class BankController
{
    protected $vantApi;

    public function __construct(VantApi $vantApi)
    {
        $this->vantApi = $vantApi;
    }

    public function listBanks()
    {
        return $this->vantApi->getBanks();
    }
}

Using the Facade

Alternatively, you can use the provided Vant facade:

use Vant\VantLaravel\Facades\Vant;

$banks = Vant::getBanks();

API Methods

1. Get List of Banks

Vant::getBanks();

2. Verify Transfer Recipient

$data = [
    'account_number' => '1234567890',
    'bank_code' => '044',
];
Vant::verifyTransferRecipient($data);

3. Initiate Transfer

$data = [
    'recipient' => 'recipient_code',
    'amount' => 5000,
    'currency' => 'NGN',
];
Vant::initiateTransfer($data);

4. Create Wallet

$data = [
    'user_id' => 12345,
    'currency' => 'NGN',
];
Vant::createWallet($data);

5. Get All Transactions

Vant::allTransactions();

6. Get Transaction by Reference

Vant::getTransaction('txn_ABC123');

7. Checkout

$data = [
    'amount' => 10000,
    'currency' => 'NGN',
    'customer' => [
        'email' => 'customer@example.com',
    ],
];
Vant::checkout($data);

8. Verify Webhook Signature

if (Vant::verifyWebhook()) {
    // Process webhook
}

Exception Handling

All API requests handle exceptions gracefully and return error messages in case of failure.

Contributing

Feel free to contribute by submitting a pull request or reporting issues.

License

This package is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-03-03