tbanov/omnipay-epay

为 Omnipay 支付处理库提供的 ePay.bg 网关

dev-master / 1.2.x-dev 2023-05-22 13:38 UTC

This package is not auto-updated.

Last update: 2024-09-24 18:53:45 UTC


README

ePay.bg 驱动程序,用于 Omnipay PHP 支付处理库

Omnipay 是一个不依赖于框架、多网关的 PHP 5.3+ 支付处理库。本包实现了对 Omnipay 的 Epay、EasyPay、Bpay 以及更多保加利亚在线支付提供商的支持。

安装

Omnipay 通过 Composer 安装。要安装,请运行以下命令

composer require gentor/omnipay-epay

本包提供的以下网关

有关一般使用说明,请参阅主要的 Omnipay 仓库。

基本用法

购买

use Omnipay\Omnipay;

$provider = Epay; # Or Easypay
$gateway = Omnipay::create($provider);
$gateway->setMin('Epay Merchant Id');
$gateway->setSignature('Epay Signature');

$response = $gateway->purchase(
    [
        'amount' => '10.00', // BGN
        'transactionId' => 'Unique ID in your system',
        'returnUrl' => 'your.site.com/return',
        'cancelUrl' => 'your.site.com/cancel',
    ]
)->send();

if ($response->isSuccessful()) {
    // only EasyPay get IDN
    echo($response->getRedirectData());
} elseif ($response->isRedirect()) {
    // redirect to epay payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

Webhook

  • 支付状态的监听器
//Use only epay gateway
$gateway = Omnipay::create('Epay');
$gateway->setMin('Epay Merchant Id');
$gateway->setSignature('Epay Signature');

$response = $gateway->acceptNotification()->send();

if ($response->isSuccessful()) {
    $status = $response->getTransactionStatus();
    // Response is required for epay gateway to stop sending data
    echo $response->getData()['notify_text'];
} else {
    // Response is required for epay gateway to stop sending data
    echo $response->getData()['notify_text'];
}

ePay.bg 文档