PHP code example of nash81 / bsicards-php-sdk

1. Go to this page and download the library: Download nash81/bsicards-php-sdk 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/ */

    

nash81 / bsicards-php-sdk example snippets


use BSICards\BSICardsClient;
use BSICards\APIException;

// Initialize client (credentials from .env)
$client = new BSICardsClient();

try {
    // Create a MasterCard
    $response = $client->mastercardCreateCard(
        '[email protected]',
        'John Doe',
        '1234'
    );

    echo "Card created: " . $response['message'];
} catch (APIException $e) {
    echo "Error: " . $e->getMessage();
}

use BSICards\BSICardsClient;

class CardController extends Controller
{
    public function createCard(BSICardsClient $client)
    {
        $response = $client->mastercardCreateCard(
            request('email'),
            request('name'),
            request('pin')
        );

        return response()->json($response);
    }
}

// Create a new MasterCard
$client->mastercardCreateCard($email, $name, $pin);

// Get all MasterCards
$client->mastercardGetAllCards($email);

// Get pending MasterCards
$client->mastercardGetPendingCards($email);

// Get specific card details
$client->mastercardGetCard($email, $cardId);

// Get card transactions
$client->mastercardGetTransactions($email, $cardId);

// Change card PIN
$client->mastercardChangePin($email, $cardId, $newPin);

// Freeze card
$client->mastercardFreezeCard($email, $cardId);

// Unfreeze card
$client->mastercardUnfreezeCard($email, $cardId);

// Fund card (minimum $10.00)
$client->mastercardFundCard($email, $cardId, '50.00');

// Create a new Visa card
$client->visaCreateCard(
    $email,
    $name,
    $nationalIdNumber,
    $nationalIdImageUrl,
    $userPhotoUrl,
    '1990-01-15' // DOB
);

// Get all Visa cards
$client->visaGetAllCards($email);

// Get pending Visa cards
$client->visaGetPendingCards($email);

// Get specific card
$client->visaGetCard($email, $cardId);

// Get transactions
$client->visaGetTransactions($email, $cardId);

// Freeze/Unfreeze
$client->visaFreezeCard($email, $cardId);
$client->visaUnfreezeCard($email, $cardId);

// Fund card
$client->visaFundCard($email, $cardId, '50.00');

// Create virtual card
$client->digitalCreateVirtualCard(
    $email,
    $firstName,
    $lastName,
    '1990-01-15',
    $address,
    $postalCode,
    $city,
    'GB', // Country code
    $state,
    '44', // Country phone code
    $phone
);

// Get all cards
$client->digitalGetAllCards($email);

// Get specific card
$client->digitalGetCard($email, $cardId);

// Fund card
$client->digitalFundCard($email, $cardId, $amount);

// Freeze/Unfreeze
$client->digitalFreezeCard($email, $cardId);
$client->digitalUnfreezeCard($email, $cardId);

// Check 3DS verification
$client->digitalCheck3DS($email);

// Approve 3DS transaction
$client->digitalApprove3DS($email, $cardId, $eventId);

// Terminate card
$client->digitalTerminateCard($email, $cardId);

// Create add-on card
$client->digitalCreateAddonCard($email, $cardId);

// Loyalty points
$client->digitalGetLoyaltyPoints($email, $cardId);
$client->digitalRedeemPoints($email, $cardId);

// Create a virtual Visa wallet card (minimum $5 funding deducted on creation)
$client->visaWalletCreateVirtualCard($email, $firstName, $lastName);

// Get all Visa wallet cards
$client->visaWalletGetAllCards($email);

// Get specific card details (ient->visaWalletBlockCard($email, $cardId);
$client->visaWalletUnblockCard($email, $cardId);

// Get wallet balance
$balance = $client->getWalletBalance();

// Get all deposits
$deposits = $client->getDeposits();

// Get all transactions
$transactions = $client->getTransactions();

// Get all Visa cards
$visaCards = $client->getAllVisaCards();

// Get all MasterCards
$mastercards = $client->getAllMastercards();

// Get all Digital cards
$digitalCards = $client->getAllDigitalCards();

// Swap endpoints
$currencies = $client->swapGetCurrencies();
$status = $client->swapGetStatus('transaction_id_here');
$estimate = $client->swapGetEstimate('BTC', 'USDT-TRC20', 'BTC', 'TRC20', 0.5);
$swap = $client->swapCreate('BTC', 'USDT-TRC20', 'BTC', 'TRC20', 0.5, 'THUnQJKECXP82EjijVVHpUwFMd3Y3vGBQJ');

// Wallet endpoints
$address = $client->walletCreateAddress('[email protected]', 'PAXG');
$addresses = $client->walletGetAllAddresses('[email protected]');
$specificAddress = $client->walletGetAddress('uuid_here', '[email protected]');
$balance = $client->walletGetBalance('uuid_here', '[email protected]');

use BSICards\APIException;

try {
    $response = $client->mastercardCreateCard(
        '[email protected]',
        'John Doe',
        '1234'
    );
} catch (APIException $e) {
    // Handle API error
    echo "API Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
}

$client = new BSICardsClient(
    'public_key',
    'secret_key',
    [
        'timeout' => 60,
        'connect_timeout' => 15,
    ]
);

$client->setPublicKey('new_key');
$client->setSecretKey('new_secret');

$publicKey = $client->getPublicKey();
$secretKey = $client->getSecretKey();
bash
composer 
bash
composer 
bash
php artisan vendor:publish --tag=bsicards-config