PHP code example of circlecreative / payvala-php-sdk

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

    

circlecreative / payvala-php-sdk example snippets




use App\Services\Payvala;

// Create an instance of Payvala
$service = new Payvala();

// Set credentials for authentication
$service->setAccessKey('your_access_key');
$service->setAccessKeyId('your_access_key_id');
$service->setAuthCode('your_auth_code');

// Send a message
$response = $service->sendMessage([
    'requestId' => 'unique_request_id',
    'deviceSn' => 'device_serial_number',
    'amount' => '100.00',
    'template' => 'message_template',
    'language' => 'en',
    'payer' => 'payer_info',
    'txnId' => 'txn_id',
    'channel' => 'channel_info',
    'timestamp' => time(),
    'transactingBank' => 'bank_name'
]);

// Handle the response
if (isset($response['error'])) {
    echo "Error: " . $response['error'];
} else {
    echo "Code: " . $response['code'];
    echo "Message: " . $response['message'];
    echo "Request ID: " . $response['requestId'];
    echo "Nonce: " . $response['nonce'];
}

[
    'code' => 'response_code',
    'message' => 'response_message',
    'requestId' => 'returned_request_id',
    'nonce' => 'response_nonce',
    'error' => 'error_message' // If any error occurs
]
bash
composer