Giter VIP home page Giter VIP logo

borica-api's Introduction

BORICA API

This is a simple implementation of the BORICA API for adding payments with their service.

Instalation

Pull from Composer:

composer require mirovit/borica-api

How to use

One way would be to new up a version of Mirovit\Borica\Factory, which accepts Mirovit\Borica\Request and Mirovit\Borica\Response as constructor arguments. Or just use the the Request and Response classes individually.

The Request as its name suggests is responsible for generating the URLs for request to the Borica API - possible requests are: register transaction, check status of transaction, register delayed transaction request, complete a delayed transaction request, reverse delayed transaction request and reverse a partially or the full sum from a registered transaction.

<?php

require __DIR__ . '/vendor/autoload.php';

$factory = new Factory(
    new Request('<terminal id from BORICA>', '<private key signed from BORICA>', '<private key password (optional)>', '<language (optional - BG or EN)>', '<debug (optional, whether you're testing or accepting payments)>'),
    new Response('<public certificate from BORICA>')
);

Registering of a transaction

$factory->request()
        ->amount('1') // 1 EUR
        ->orderID(1) // Unique identifier in your system
        ->description('testing the process') // Short description of the purchase (up to 125 chars)
        ->currency('EUR') // The currency of the payment
        ->register(); // Type of the request

Check status of a transaction

$factory->request()
        ->amount('1') // 1 EUR
        ->orderID(1) // Unique identifier in your system
        ->description('testing the process') // Short description of the purchase (up to 125 chars)
        ->currency('EUR') // The currency of the payment
        ->status(); // Type of the request

Reverse a transaction

$factory->request()
        ->amount('1') // 1 EUR - partial reversal (amount less than the original), full reversal the original amount
        ->orderID(1) // Unique identifier in your system
        ->reverse(); // Type of the request

Using with Laravel 5

Create a service provider as the one below and register it with the app. You can either add it to the config/app.php or register it in Providers/AppServiceProvider.php.

<?php

namespace App\Providers;

use Mirovit\Borica\Factory;
use Mirovit\Borica\Request;
use Mirovit\Borica\Response;
use Illuminate\Support\ServiceProvider;

class BoricaServiceProvider extends ServiceProvider
{

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(Request::class, function(){
            return new Request(env('BORICA_TERMINAL_ID'), 'path/to/private.key', '',  app()->getLocale());
        });

        $this->app->bind(Response::class, function(){
            return new Response('path/to/public.cer');
        });

        $this->app->bind(Factory::class, function(){
            return new Factory(app(Request::class), app(Response::class));
        }, true);
    }
}

Contributing

If you'd like to contribute, feel free to send a pull request!

borica-api's People

Contributors

buresmi7 avatar georgetudor avatar mirovit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

borica-api's Issues

Carbon 1 is deprecated

Please, either update the dependency or better remove it (replace with DateTime) as it seems completely redundant (formatting dates should be left to the client of the library)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.