vm-labs/borica

Package that enables the communication with BORICA via their API

Installs: 3 150

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 7

Forks: 1

Open Issues: 0

Type:symfony-bundle

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

This package is not auto-updated.

Last update: 2024-09-18 23:41:42 UTC


README

This is implementation of the BORICA API for adding payments with their service. EMV 3DS protocol.

Content

Installation

Install using composer:

composer require vm-labs/borica

Enable the Bundle

# config/bundles.php

<?php

return [
    ...

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

Configuration

# 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://localhost'
            extended_mac: false # default true
        config_2: # optional
            terminal_id: # terminal id
            ...

Usage

Currently possible requests are - payment, cancellation and status of transaction.

The communication and transmission of parameters is done through HTML forms and HTTP post to the e-Commerce CGI server of BORICA. So with the current implementation you can check if the data is valid or take the form for a specific transaction.

Payment request

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(),
        ]);
    }
}

Response

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();
        // ...
    }
}

Status

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()) {
            // ...
        }
    }
}

Credit cards

Amount dependant

Response codes

ISO_8583

APGW response codes