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
Code | Description |
---|---|
01 | Amount Only |
02 | Amount broadcast with Payer Name (not in use as of now) |
10 | Test Message |
Language Code List
Code | Description |
---|---|
DE | Default |
EN | English |
ID | Indonesia |
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
Code | Message |
---|---|
0001 | Delivered to Device |
0002 | Broadcasted by Device |
0003 | Delivered to Device and Broadcasted by Device |
1001 | Invalid credentials (Access Key ID/Access Key/Auth Code) |
1002 | Missing credentials (Access Key ID/Access Key/Auth Code) |
1003 | Incorrect Parameter Value |
1004 | Missing Mandatory parameter |
1005 | Incorrect combination of template and language |
1006 | Amount Invalid |
2001 | Device Does not exist / not provisioned / Device Inactive |
2002 | Device offline / delivery to device unsuccessful |
3001 | MQTT system failure |
3002 | API not available |
3003 | API overflow |
9000 | Other Error |
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.