定制 12goyuriyr/symfony-mono-acquiring-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

12goyuriyr/symfony-mono-acquiring-bundle

最新稳定版本:v1.0.1

Composer 安装命令:

composer require 12goyuriyr/symfony-mono-acquiring-bundle

包简介

Symfony bundle for Monobank Acquiring API integration (invoices, payments, currency rates)

README 文档

README

CI Latest Stable Version License

Symfony bundle providing a typed HTTP client for Monobank Acquiring API.

Features

  • Create payment invoices
  • Check invoice status
  • Fetch currency exchange rates
  • Typed DTOs instead of raw arrays
  • Auto-configured via Symfony DI

Requirements

  • PHP 8.1+
  • Symfony 6.4 / 7.x / 8.x

Installation

Step 1: Install the package

composer require 12goyuriyr/symfony-mono-acquiring-bundle

Symfony Flex will automatically register the bundle in config/bundles.php. If it didn't, add it manually:

return [
    // ...
    MonobankAcquiring\MonobankAcquiringBundle::class => ['all' => true],
];

Step 2: Configure

Add your Monobank merchant token to .env:

MONO_API_TOKEN=your_token_here

Create the bundle configuration file:

# config/packages/monobank_acquiring.yaml
monobank_acquiring:
    api_token: '%env(MONO_API_TOKEN)%'
    # api_url: 'https://api.monobank.ua'  # optional, this is the default

That's it. MonoAcquiringClientInterface is now available for dependency injection.

Usage

Inject MonoAcquiringClientInterface into your service:

use MonobankAcquiring\Client\MonoAcquiringClientInterface;

class PaymentService
{
    public function __construct(
        private readonly MonoAcquiringClientInterface $monoClient,
    ) {}

    public function createPayment(): string
    {
        $invoice = $this->monoClient->createInvoice([
            'amount' => 10000,       // amount in kopiykas (100.00 UAH)
            'ccy' => 980,            // ISO 4217 currency code (UAH)
            'merchantPaymInfo' => [
                'reference' => 'Order #123',
                'destination' => 'Payment for order #123',
            ],
            'redirectUrl' => 'https://example.com/payment/callback',
            'webHookUrl' => 'https://example.com/payment/webhook',
            'validity' => 3600,
        ]);

        // Redirect user to $invoice->getPageUrl()
        return $invoice->getInvoiceId();
    }

    public function checkStatus(string $invoiceId): bool
    {
        $status = $this->monoClient->getInvoiceStatus($invoiceId);

        return $status->isSuccess();
    }
}

Available methods

createInvoice(array $payload): InvoiceResponse

Creates a payment invoice. Returns InvoiceResponse with getInvoiceId() and getPageUrl().

See Monobank API docs for payload options.

getInvoiceStatus(string $invoiceId): InvoiceStatus

Returns InvoiceStatus with:

  • getStatus() — raw status string
  • isCreated(), isProcessing(), isSuccess(), isFailure(), isExpired(), isReversed() — status checks
  • getAmount(), getFinalAmount(), getCcy() — payment amounts
  • getFee() — gateway fee
  • getPaymentInfo() — raw payment info array

getRates(): Rate[]

Returns an array of Rate objects with:

  • getCurrencyCodeA(), getCurrencyCodeB() — ISO 4217 codes
  • getDate() — Unix timestamp
  • getRateSell(), getRateBuy(), getRateCross() — exchange rates

Error handling

All API errors throw MonoApiException:

use MonobankAcquiring\Exception\MonoApiException;

try {
    $invoice = $monoClient->createInvoice($payload);
} catch (MonoApiException $e) {
    $e->getMessage();        // error description
    $e->getHttpStatusCode(); // HTTP status code
    $e->getResponseBody();   // raw response array
}

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固