PHP code example of sha443 / bml-connect

1. Go to this page and download the library: Download sha443/bml-connect 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/ */

    

sha443 / bml-connect example snippets


use SHA443\BMLConnect\Client;

$client = new Client("sandbox");

use SHA443\BMLConnect\Client;

$client = new Client(); // passing 'production' is optional
//or
$client = new Client("production");

use SHA443\BMLConnect\Client;

$options = ['headers' => ['foo' => 'bar']];
$client = new Client('sandbox', $options);

use SHA443\BMLConnect\Client;

$client = new Client();

$json = [
 "provider" => "bml_epos", // Payment method enabled for your merchant account such as bcmc, alipay, card, bml_epos
 "currency" => "MVR",
 "amount" => 1000, // 10.00 MVR, transaction amount should be an integer ([in Laari](https://en.wikipedia.org/wiki/Maldivian_laari))
 "localId" => "Test_001", // your reference id
 "redirectUrl" => "https://example.com/order/123" // Optional redirect after payment completion
];

$transaction = $client->transactions->create($json);
return redirect($transaction["url"]); // Go to transaction payment page

use SHA443\BMLConnect\Client;

$client = new Client();

$json = [
 "currency" => "MVR",
 "amount" => 1000, // 10.00 MVR, transaction amount should be an integer ([in Laari](https://en.wikipedia.org/wiki/Maldivian_laari))
 "localId" => "Test_001", // your reference id
 "redirectUrl" => "https://example.com/order/987" // Optional redirect after payment completion
];

$transaction = $client->transactions->create($json);
return redirect($transaction["url"]); // Go to transaction payment page

use SHA443\BMLConnect\Client;
use SHA443\BMLConnect\Models\Transaction;
use SHA443\BMLConnect\Traits\Signature;

$client = new Client();

$json = [
 "currency" => "MVR",
 "amount" => 1000
];

$transaction = (new Transaction())->fromArray($json);
$verified = (new Signature($transaction))->verify($signature);