vm-labs/borica

通过他们的API与BORICA进行通信的包

维护者

详细信息

github.com/vm-labs/Borica

源代码

问题

安装数: 3,150

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 7

分支: 1

开放问题: 0

类型:symfony-bundle

v1.1.0 2022-03-08 11:57 UTC

This package is not auto-updated.

Last update: 2024-10-02 23:49:10 UTC


README

这是BORICA API的实现,用于添加支付服务。EMV 3DS协议。

内容

安装

使用Composer安装

composer require vm-labs/borica

启用Bundle

# config/bundles.php

<?php

return [
    ...

    Borica\BoricaBundle::class => ['all' => true],
];

配置

# config/packages/borica.yaml

borica_api:
    test_url: # default https://3dsgate-dev.borica.bg/cgi-bin/cgi_link 
    prod_url: # default https://3dsgate.borica.bg/cgi-bin/cgi_link

    profiles:
        config_1:
            terminal_id: # terminal id
            private_key: # path to private key
            private_key_password: # private key password
            public_key: # path to public key
            merchant: 1600000001
            merchant_name: 'Payment'
            merchant_url: 'https://'
            extended_mac: false # default true
        config_2: # optional
            terminal_id: # terminal id
            ...

使用方法

当前可能请求的是 - 付款、取消和交易状态。

通信和参数传输是通过HTML表单和HTTP POST到BORICA的电子商务CGI服务器完成的。因此,根据当前的实现,您可以检查数据是否有效或获取特定交易的表单。

支付请求

use Borica\Entity\Request as BoricaRequest;
use Borica\Manager\RequestManager;

class PaymentController extends AbstractController
{
    public function __invoke(RequestManager $requestManager)
    {
        $request = new BoricaRequest();
        $request->setAmount(29);
        $request->setDescription('Payment details.');

        # You can check that the data is valid or pick up the list of errors before submitting the form.
        if (!$paymentRequest->isValidData()) {
            $errorList = $paymentRequest->getErrorList();
            // ...
        }

        $paymentRequest = $requestManager->payment($request, 'config_1'); // the second argument is required if you have more than one configuration

        return $this->render('payment-details.html.twig', [
            'form' => $paymentRequest->getForm()->createView(),
        ]);
    }
}

响应

use Borica\Manager\ResponseManager;

class PaymentResponseController extends AbstractController
{
    public function __invoke(ResponseManager $responseManager)
    {
        $boricaResponse = $this->responseManager->response();

        # Verification of the signature in response from APGW
        if (!$boricaResponse->isValid()) {
            // ...
        }

        # Check if the borica response is completed successfully.
        if (!$boricaResponse->isSuccessful()) {
            $responseCode = $boricaResponse->getResponseCode();
            // ...
        }

        $response = $boricaResponse->getData();
        $orderId = $response->getOrderId();
        // ...
    }
}

状态

use Borica\Entity\Request as BoricaRequest;
use Borica\Manager\RequestManager;

class StatusRequestController extends AbstractController
{
    public function __invoke(RequestManager $requestManager)
    {
        $request = new BoricaRequest();
        $request->setOrder($order);

        $statusRequest = $requestManager->status($request);

        if (!$paymentRequest->isValidData()) {
            $errorList = $paymentRequest()->getErrorList();
            // ...
        }

        $boricaResponse = $statusRequest->request();

        if ($boricaResponse->isValid()) {
            // ...
        }

        if ($boricaResponse->isSuccessful()) {
            // ...
        }
    }
}

信用卡

金额相关

响应代码

ISO_8583

APGW响应代码