PHP code example of pagocards / php-laravel

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

    

pagocards / php-laravel example snippets


use Pagocards\SDK\Facades\Pagocards;

// Create a Mastercard
$card = Pagocards::createMastercard([
    'email' => '[email protected]',
    'firstname' => 'John',
    'lastname' => 'Doe'
]);

// Create a Visa Card
$card = Pagocards::createVisacard([
    'email' => '[email protected]',
    'firstname' => 'John',
    'lastname' => 'Doe'
]);

// Fund a Visa Card
$result = Pagocards::fundVisacard('card_id', 100.00);

// Get card details
$card = Pagocards::getCard('card_id', 'visacard');

// List cards
$cards = Pagocards::listCards('visacard', 1, 50);

// Block/Unblock Mastercard
Pagocards::toggleCard('card_id', 'block', 'mastercard');
Pagocards::toggleCard('card_id', 'unblock', 'mastercard');

// Get wallet balance
$balance = Pagocards::getBalance();

use Pagocards\SDK\Client;

$client = new Client(
    'your_public_key',
    'your_secret_key',
    'https://pagocards.com'
);

// Use all the same methods as the facade
$card = $client->createVisacard([
    'email' => '[email protected]',
    'firstname' => 'John',
    'lastname' => 'Doe'
]);

namespace App\Services;

use Pagocards\SDK\Facades\Pagocards;

class CardService
{
    public function createUserCard($email, $firstname, $lastname)
    {
        try {
            $card = Pagocards::createVisacard([
                'email' => $email,
                'firstname' => $firstname,
                'lastname' => $lastname
            ]);

            return $card;
        } catch (\Exception $e) {
            \Log::error('Card creation failed: ' . $e->getMessage());
            throw $e;
        }
    }
}

Pagocards::createMastercard([
    'email' => '[email protected]',
    'firstname' => 'John',
    'lastname' => 'Doe'
])

Pagocards::createVisacard([
    'email' => '[email protected]',
    'firstname' => 'John',
    'lastname' => 'Doe'
])

Pagocards::getCard('card_id', 'visacard');
// or
Pagocards::getCard('card_id', 'mastercard');

Pagocards::listCards('visacard', $page = 1, $perPage = 50);

Pagocards::fundVisacard('card_id', 100.00);

Pagocards::toggleCard('card_id', 'block', 'mastercard');

Pagocards::toggleCard('card_id', 'unblock', 'mastercard');

$balance = Pagocards::getBalance();
// Returns: ['issuance_balance' => 100, 'funding_balance' => 500]

try {
    $card = Pagocards::createVisacard([
        'email' => 'invalid-email',
        'firstname' => 'John',
        'lastname' => 'Doe'
    ]);
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
}

Pagocards::setBaseUrl('https://pagocards.com');

$url = Pagocards::getBaseUrl();
bash
composer config repositories.pagocards vcs https://github.com/pagocards/php-laravel
composer 
json
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/pagocards/php-laravel"
    }
  ],
  "
bash
composer 
bash
php artisan vendor:publish --provider="Pagocards\SDK\ServiceProvider" --tag="config"
bash
git clone https://github.com/pagocards/php-laravel.git
cd php-laravel