This guide provides an overview of using the Kody PHP gRPC Client SDK and its reference documentation.
Kody provides client libraries for many popular languages to access the APIs. If your desired programming language is supported by the client libraries, we recommend that you use this option.
Available languages:
- Java: https://github.com/KodyPay/kody-clientsdk-java/
- Python: https://github.com/KodyPay/kody-clientsdk-python/
- PHP: https://github.com/KodyPay/kody-clientsdk-php/
- .Net: https://github.com/KodyPay/kody-clientsdk-dotnet/
The advantages of using the Kody Client library instead of a REST API are:
- Maintained by Kody.
- Built-in authentication and increased security.
- Built-in retries.
- Idiomatic for each language.
- Quicker development.
- Backwards compatibility with new versions.
If your coding language is not listed, please let the Kody team know and we will be able to create it for you.
- PHP 7.2 or later
- Composer
- gRPC PHP extension
Add the following to your composer.json:
{
"require": {
"kody/kody-php8-grpc-client": "v1.6.10"
},
"repositories": [
{
"type": "package",
"package": {
"name": "kody/kody-php8-grpc-client",
"version": "v1.6.3",
"dist": {
"type": "zip",
"url": "https://github.com/KodyPay/kody-clientsdk-php/releases/download/v1.6.10/kody-php8-grpc-package.zip"
}
}
}
]
}Then run:
composer installpecl install grpc
pecl install protobufAdd this line to your php.ini:
extension=grpc.so
extension=protobuf.sosudo pecl install grpc
sudo pecl install protobufAdd this line to your php.ini:
extension=grpc.so
extension=protobuf.so- Download the gRPC and Protobuf extension DLLs from:
- Place the files in your PHP
extdirectory. - Add the following line to your
php.ini:
extension=php_grpc.dll
extension=php_protobuf.dllFor more information, see the Install gRPC for PHP documentation.
The client library uses a combination of a Store ID and an API key.
These credentials will be provided to you during the integration onboarding process. You will start with test credentials and receive live credentials upon launch.
- Development and test:
https://grpc-staging.kodypay.com - Live:
https://grpc.kodypay.com
For complete API documentation, examples, and integration guides, visit: 📚 https://api-docs.kody.com
Here’s a simple example that uses the Kody PHP gRPC client:
<?php
require __DIR__ . '/../vendor/autoload.php';
use Com\Kodypay\Grpc\Pay\V1\KodyPayTerminalServiceClient;
use Com\Kodypay\Grpc\Pay\V1\TerminalsRequest;
use Grpc\ChannelCredentials;
$kody_api_hostname = 'grpc.kodypay.com';
$store_id = 'your-store-id'; // Replace with your Store ID
$api_key = 'your-api-key'; // Replace with your API key
$client = new KodyPayTerminalServiceClient($kody_api_hostname, ['credentials' => ChannelCredentials::createSsl()]);
$metadata = ['X-API-Key' => [$api_key]];
$request = new TerminalsRequest();
$request->setStoreId($store_id);
list($response, $status) = $client->Terminals($request, $metadata)->wait();
if ($status->code !== \Grpc\STATUS_OK) {
echo "Error: " . $status->details . PHP_EOL;
} else {
echo "Terminals for Store ID: $store_id" . PHP_EOL;
foreach ($response->getTerminals() as $terminal) {
echo "Terminal ID: " . $terminal->getTerminalId() . " - Online: " . ($terminal->getOnline() ? 'Yes' : 'No') . PHP_EOL;
}
}cd samples/php7
composer install
php src/index.phpEnsure:
- PHP extensions for gRPC and Protobuf are installed and enabled.
- Composer dependencies are properly installed.
- Hostname and credentials are correct.
- PHP: https://github.com/KodyPay/kody-clientsdk-php/tree/main/samples
- Java: https://github.com/KodyPay/kody-clientsdk-java/tree/main/samples
- Python: https://github.com/KodyPay/kody-clientsdk-python/tree/main/versions/3_12/samples
- .Net: https://github.com/KodyPay/kody-clientsdk-dotnet/tree/main/samples
This project is licensed under the MIT License.