vm-labs / borica
通过他们的API与BORICA进行通信的包
v1.1.0
2022-03-08 11:57 UTC
Requires
- php: ^7.2
- symfony/config: ^4.4
- symfony/dependency-injection: ^4.4
- symfony/form: ^4.4
- symfony/http-client: ^5.1
- symfony/http-kernel: ^4.4
- symfony/validator: ^4.4
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()) { // ... } } }