PHP code example of ivo-wmg / borica

1. Go to this page and download the library: Download ivo-wmg/borica library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ivo-wmg / borica example snippets


use IvoWmg\Borica\Signature\SignatureBuilder;

SignatureBuilder::requestSource($data);          // one-off, or the initial CIT
SignatureBuilder::requestSource($data, $token);  // every subsequent MIT
SignatureBuilder::responseSource($post);         // reads the token back out

use IvoWmg\Borica\Facades\Borica;
use IvoWmg\Borica\OrderReference;
use IvoWmg\Borica\MerchantInfo;
use IvoWmg\Borica\Trtype;

$fields = Borica::registration(
    trtype: Trtype::PREAUTH,                       // or Trtype::SALE
    order: OrderReference::fromId($order->id),
    amount: '25.00',
    description: 'Order '.$order->number,
    info: new MerchantInfo(
        email: $order->email,
        cardholderName: $order->customer_name,     // transliterated for you
        billingAddress: $order->address,
    ),
);

public function callback(Request $request)
{
    $response = Borica::response($request->all());   // verifies P_SIGN, throws if it cannot

    if (! $response->isVerified()) {
        return redirect()->route('checkout')->with('error', __('Payment could not be verified.'));
    }

    ProcessBoricaCallback::dispatch($request->all());

    return redirect()->route('checkout.success');
}

use IvoWmg\Borica\ResponseCode;

ResponseCode::describe($response->rc());          // for your admin screen
ResponseCode::customerMessage($response->rc());   // for the shopper

Borica::complete($order, amount: '23.40');   // may be less than authorized, never more
Borica::reverse($order);                     // must be the full authorized amount
Borica::refund($order, amount: '10.00');     // against a completed transaction
Borica::status($order);                      // TRTYPE 90

// 1. Customer present. The callback returns MERCH_TOKEN_ID — store it encrypted.
$fields = Borica::initialTokenized(order: $ref, amount: '0.01', info: $info);

// 2. No customer. Server to server, as often as you like.
$result = Borica::charge(token: $subscription->token, order: $ref, amount: '19.99');

// 3. When they cancel.
Borica::revokeToken($subscription->token);
bash
php artisan vendor:publish --tag=borica-config
php artisan vendor:publish --tag=borica-migrations
php artisan migrate