Skip to main content
Version: Next

Balance Inquiry with the SDK

Follow these steps to install the SDK, authenticate, and query your balance.

Before you start, you need an API username and password. See the Quickstart if you have not created them yet.

1. Install the SDK

pom.xml
<dependency>
<groupId>com.pahappa.systems</groupId>
<artifactId>comms-sdk</artifactId>
<version>1.0.2</version>
</dependency>
note

Most commands above install the latest release. A version is pinned only where the build tool requires one (Maven and Gradle). For the current version of every SDK, see the SDK Downloads page.

2. Authenticate

Main.java
import com.pahappa.systems.commssdk.v1.CommsSDK;

String apiUsername = "api_username";
String apiKey = "api_key";
CommsSDK sdk = CommsSDK.authenticate(apiUsername, apiKey);
Testing against the sandbox

The SDK targets the live server by default. If you are using sandbox credentials, switch environments before you authenticate:

LanguageCall
Java, Kotlin, JS / TS, DartCommsSDK.useSandBox()
Rust, PHPCommsSDK::use_sandbox()
Python, RubyCommsSDK.use_sandbox()
Gov1.CommsSDK.UseSandBox()
C#CommsSDK.UseSandBox()

Call useLiveServer / use_live_server to switch back. Sandbox credentials do not work against the live server, and vice versa.

3. Query balance

There are two ways to read your balance:

  • getBalance returns the balance as a number.
  • queryBalance returns an ApiResponse with the full result, including status and balance.

Both default to the local wallet. To query the international wallet instead, pass a WalletType — every language's tab below shows how.

Main.java
import com.pahappa.systems.commssdk.v1.models.ApiResponse;
import com.pahappa.systems.commssdk.v1.models.WalletType;

// just the balance (local wallet)
double balance = sdk.getBalance();
System.out.println("Balance: " + balance);

// full API response instead of a number
ApiResponse balanceQuery = sdk.queryBalance();
System.out.println(balanceQuery.status + " and balance: " + balanceQuery.balance);

// a specific wallet's balance
double internationalBalance = sdk.getBalance(WalletType.INTERNATIONAL);
System.out.println("International balance: " + internationalBalance);
note

For query-based methods, the returned object is of type ApiResponse. See ApiResponse.

Next steps