circlecreative / payvala-php-sdk
Advanced Payvala API PHP SDK
Requires
- php: ^8.1.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^11.4
README
Payvala PHP SDK
is a PHP library to send messages through the PayVala API into PayVala SoundBox Device. This library uses GuzzleHttp\Client
for HTTP communication with the Payvala API.
Features
- Easy Authentication: Supports authentication with
accessKey
,accessKeyId
, andauthCode
. - Message Sending: Send messages with flexible parameters.
- Response Handling: Get clear responses with code and messages from the API.
Installation
To install Payvala
, you can use Composer:
composer require circlecreative/payvala-php-sdk
If you are using PHP without a framework, you can include the autoload file:
require_once('path/to/circlecreative/payvala-php-sdk/src/autoload.php');
Usage
Using Payvala
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']; }
Methods
setAccessKey(string $accessKey)
Sets the accessKey
for authentication.
setAccessKeyId(string $accessKeyId)
Sets the accessKeyId
for authentication.
setAuthCode(string $authCode)
Sets the authCode
for authentication.
sendMessage(array $data): array
Sends a message via the Payvala API with the provided data.
Template Code List
Language Code List
API Response
[ 'code' => 'response_code', 'message' => 'response_message', 'requestId' => 'returned_request_id', 'nonce' => 'response_nonce', 'error' => 'error_message' // If any error occurs ]
Response Code List
License
This library is licensed under the MIT License.
Contributing
We welcome contributions from the community. If you'd like to contribute, please follow these steps:
- Fork this repository
- Create a branch for your new feature (
git checkout -b feature-new-feature
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature-new-feature
) - Open a pull request
Contact
If you have any questions or need further assistance, please open an issue on the GitHub repository or contact us via email.