Demo code that uses Synqpay SDK. Includes examples of
- Use Synqpay API to invoke Synqpay JSON-RPC API over IPC
- Manage Synqpay Service
- Synqpay PAL (Print Abstract Layer) to use integrated printer
The Synqpay SDK is publicly available and hosted on the Maven Central repository. This ensures that developers can easily access and integrate the SDK into their applications, facilitating streamlined development processes.
Android projects:
implementation("com.synqpay:synqpay-sdk:1.3")
-
Init from your Activity/Application creation
SynqpaySDK.get().init(this);
-
Bind
Register and unregister binding listeners
@Override public void onStart() { super.onStart(); SynqpaySDK.get().setListener(this); SynqpaySDK.get().bindService(); } @Override public void onStop() { super.onStop(); SynqpaySDK.get().unbindService(); SynqpaySDK.get().setListener(null); }
-
Use the desired module
@Override public void onSynqpayConnected() { this.api = SynqpaySDK.get().getSynqpayApi(); this.manager = SynqpaySDK.get().getSynqpayManager(); this.printer = SynqpaySDK.get().getSynqpayPrinter(); this.device = SynqpaySDK.get().getSynqpayDevice(); }
public void sendRequest() { JSONObject jsonObject = new JSONObject(); try { jsonObject. put("jsonrpc","2.0"). put("id","1234"). put("method","getTerminalStatus"). put("params",null); } catch (JSONException e) {} try { api.sendRequest(jsonObject.toString(),responseCallback); } catch (RemoteException ignored) {} }