vmalits/bpay-sdk

Modern PHP SDK for BPay.md payment gateway

Maintainers

Package info

github.com/vmalits/bpay-sdk

pkg:composer/vmalits/bpay-sdk

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-01-06 15:47 UTC

This package is not auto-updated.

Last update: 2026-04-01 15:41:53 UTC


README

Requirements

  • PHP 8.2+
  • json extension
  • guzzlehttp/guzzle ^7.8 (installed automatically via Composer)

Installation

Via Composer:

composer require vmalits/bpay-sdk

Quick start

use Malits\BPay\BpayClient;
use Malits\BPay\Builder\InvoiceBuilder;
use Malits\BPay\Enums\Currency;
use Malits\BPay\Enums\Language;
use Malits\BPay\Enums\PaymentMethod;

$client = new BpayClient('merchant_id', 'secret_key');

$invoice = InvoiceBuilder::create()
    ->uuid('your-uuid')
    ->merchantId('merchant_id')
    ->amount(100.0)
    ->orderId('order123')
    ->description('Order payment')
    ->successUrl('https://your-site/success')
    ->failUrl('https://your-site/fail')
    ->callbackUrl('https://your-site/callback')
    ->currency(Currency::MDL)
    ->language(Language::EN)
    ->paymentMethod(PaymentMethod::BPAY)
    ->addParam('customer_name', 'John')
    ->addParam('phone_number', '123456789')
    ->build();

$response = $client->createInvoice($invoice);
// $response->url — payment link

Payment check

$result = $client->checkPayment('uuid-payment');
if ($result->isPaid) {
    // Payment successful
}

Callback handling

$callbackDto = $client->handleCallback($_POST);

$uuid = $callbackDto->uuid->value;
$amount = $callbackDto->amount->value;
$currencyCode = $callbackDto->currency->code;

Exceptions

  • BPayException — base exception
  • ApiException — API error
  • NetworkException — network error
  • InvalidSignatureException — invalid signature
  • ValidationException — validation error

Enum / Value Objects

  • Currency enum — MDL, RUB, USD, RON, EUR
  • Language enum — RU, RO, EN
  • PaymentMethod enum — BPAY, CARD_OMD, CARD_EUR, CARD_USD, WEBMONEY_WMZ, WEBMONEY_WMR
  • Amount VO — safe representation of amount
  • Uuid VO — payment identifier
  • Currency VO — numeric currency code
  • Params VO — extra callback parameters

Tests

composer test

Examples

See EXAMPLES.md for detailed usage examples of all SDK features.

License

MIT