Skip to content

API

The client shape is the same across C++, Java, and C#. Differences are called out inline.

Info

Every string the client sends or receives is a JSON-RPC 2.0 payload: a request (passed to sendRequest), a response or error (delivered to that call's ResponseCallback), or a notification (delivered to NotificationCallback). The client itself doesn't interpret these — see the API reference for the actual method/param definitions.

Enums

1
2
3
enum class TransportType { TCP, SSL, UART };
enum class LogLevel { Debug, Info, Warning, Error };
enum class ConnectionStatus { Connected, Disconnected, ConnectError, AuthorizationError };
1
2
3
enum TransportType { TCP, SSL, UART }
enum LogLevel { DEBUG, INFO, WARNING, ERROR }
enum ConnectionStatus { CONNECTED, DISCONNECTED, CONNECT_ERROR, AUTHORIZATION_ERROR }
1
2
3
enum TransportType { TCP, SSL, UART }
enum LogLevel { Debug, Info, Warning, Error }
enum ConnectionStatus { Connected, Disconnected, ConnectError, AuthorizationError }

Callbacks

1
2
3
4
using ResponseCallback = std::function<void(const std::string& response)>;
using NotificationCallback = std::function<void(const std::string& notification)>;
using ConnectionStateCallback = std::function<void(ConnectionStatus)>;
using LogCallback = std::function<void(LogLevel, const std::string& message)>;
1
2
3
4
interface ResponseCallback { void onResponse(String response); }
interface NotificationCallback { void onNotification(String notification); }
interface ConnectionStateCallback { void onConnectionState(ConnectionStatus status); }
interface LogCallback { void onLog(LogLevel logLevel, String message); }
1
2
3
4
delegate void ResponseCallback(string response);
delegate void NotificationCallback(string notification);
delegate void ConnectionStateCallback(ConnectionStatus status);
delegate void LogCallback(LogLevel level, string message);

Builder

Constructed with a TransportType; every setter returns the builder for chaining.

1
2
3
4
5
6
7
8
9
SynqpayClient::Builder builder(TransportType type);

builder.set_endpoint(const std::string& endpoint);
builder.set_api_key(const std::string& api_key);
builder.set_root_ca_path(const std::string& root_ca_path);       // SSL only
builder.set_connection_state_callback(ConnectionStateCallback);
builder.set_notification_handler(NotificationCallback);

std::unique_ptr<SynqpayClient> build();
1
2
3
4
5
6
7
8
9
SynqpayClient.Builder builder = SynqpayClient.create(TransportType type);

builder.setEndpoint(String endpoint);
builder.setApiKey(String apiKey);
builder.setRootCAPath(String rootCAPath);       // SSL only
builder.setConnectionStateCallback(ConnectionStateCallback);
builder.setNotificationCallback(NotificationCallback);

SynqpayClient build();
1
2
3
4
5
6
7
8
9
var builder = new SynqpayClient.Builder(TransportType type);

builder.SetEndpoint(string endpoint);
builder.SetApiKey(string apiKey);
builder.SetRootCAPath(string rootCAPath);       // SSL only
builder.SetConnectionStateCallback(ConnectionStateCallback);
builder.SetNotificationCallback(NotificationCallback);

SynqpayClient Build();

Client

static void set_log_callback(LogCallback callback);

void start();
void stop();
bool is_running() const;

void connect();
void disconnect();
bool is_connected() const;

int send_request(const std::string& json, ResponseCallback callback);
std::string get_error_message(int error) const;
// released via std::unique_ptr — no explicit destroy
static void setLogCallback(LogCallback callback);

void start();
void stop();
boolean isRunning();

void connect();
void disconnect();
boolean isConnected();

int sendRequest(String json, ResponseCallback callback);
String getErrorMessage(int error);
void destroy();
static void SetLogCallback(LogCallback callback);

void Start();
void Stop();
bool IsRunning { get; }

void Connect();
void Disconnect();
bool IsConnected { get; }

int SendRequest(string json, ResponseCallback callback);
string GetErrorMessage(int error);
void Destroy();

Info

Java and C# hold a native handle and must call destroy() / Destroy() when done with a client. C++ clients are returned as std::unique_ptr<SynqpayClient> and are released automatically.

Method Reference

Method Description
setLogCallback Static. Registers a global callback for the SDK's internal log messages. Not tied to a single client instance — see Logging.
start / stop Starts or stops the client's internal engine. Safe to call repeatedly.
isRunning Returns whether the client engine is currently running.
connect / disconnect Opens or closes the transport connection. Safe to call repeatedly. Fires ConnectionStateCallback on state changes.
isConnected Returns whether the transport is currently connected.
sendRequest Sends a JSON-RPC request string; callback receives the matching JSON-RPC response (or error) once it arrives. Returns an SDK-level error code (0 = sent successfully) — see Errors.
getErrorMessage Returns a human-readable description for an SDK-level error code returned by sendRequest.
destroy (Java / C#) Releases the native client. Required once you're done with a client — see Lifecycle.

For the lifecycle rules, threading contract, and error handling in more depth, see Key Concepts. For the JSON-RPC methods themselves (pair, authenticate, startTransaction, cancel, ...) and their parameters, see the API reference.