PHP code example of santosdave / pesawise-wrapper

1. Go to this page and download the library: Download santosdave/pesawise-wrapper 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/ */

    

santosdave / pesawise-wrapper example snippets


use Santosdave\PesawiseWrapper\Facades\Pesawise;

// Or inject in your constructor
use Santosdave\PesawiseWrapper\Pesawise;

public function __construct(Pesawise $pesawise)
{
    $this->pesawise = $pesawise;
}

use Santosdave\PesawiseWrapper\Pesawise;

class PaymentService
{
    protected $pesawise;

    public function __construct(Pesawise $pesawise)
    {
        $this->pesawise = $pesawise;
    }

    public function processPayment(array $paymentData)
    {
        return $this->pesawise->createDirectPayment($paymentData);
    }
}

$banks = Pesawise::getAllSupportedBanks();

$recipient = Pesawise::validateBankRecipient([
    'bankId' => 1,
    'bankAccountNumber' => '1234567890'
]);

$bulkPayment = Pesawise::createBulkPayment([
    'balanceId' => 1001002,
    'currency' => 'KES',
    'bulkPayments' => [
        [
            'amount' => 1000,
            'transferType' => 'BANK',
            'phoneNumber' => '254712345678',
            'reference' => 'REF123',
            'recipient' => 'John Doe',
            'bankId' => 1,
            'accountNumber' => '1234567890'
        ]
    ]
]);

$order = Pesawise::createPaymentOrder([
    'amount' => 1000,
    'customerName' => 'John Doe',
    'currency' => 'KES',
    'externalId' => 'ORDER123',
    'description' => 'Product purchase',
    'balanceId' => 1001002,
    'callbackUrl' => 'https://example.com/callback'
]);

$payment = Pesawise::completePayment([
    'paymentId' => 'payment_id_here',
    'otp' => '123456'
]);

$payment = Pesawise::createDirectPayment([
    'balanceId' => 1001002,
    'currency' => 'KES',
    'amount' => 1000,
    'transferType' => 'BANK',
    'reference' => 'REF123',
    'recipient' => 'John Doe',
    'bankId' => 1,
    'accountNumber' => '1234567890'
]);

use Santosdave\PesawiseWrapper\Exceptions\PesawiseException;

try {
    $payment = Pesawise::createDirectPayment([...]);
} catch (PesawiseException $e) {
    $errorMessage = $e->getMessage();
    $errorCode = $e->getCode();
    $errorResponse = $e->getErrorResponse();
    // Handle the error
}
bash
php artisan vendor:publish --provider="Santosdave\PesawiseWrapper\PesawiseProvider"