Gluwa SDK for Java

If your service is developed in Java, the features we provide are available through the SDK. The Gluwa SDK for Java is a library with powerful features that enable Java developers to easily make requests to the Gluwa APIs.

Getting started

<repositories>
    <repository>
        <id>Gluwa-java-mvn-repo</id>
        <url>https://raw.github.com/gluwa/Gluwa-Java/mvn-repo/</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.gluwa.sdk</groupId>
        <artifactId>gluwa-sdk-java</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

Our jar is here: https://github.com/gluwa/Gluwa-Java/tree/mvn-repo/com/gluwa/sdk/gluwa-sdk-java

Create and initialize a Configuration class. Then, enter the APIKey, APISecret and WebookSecret generated from the Gluwa Dashboard, and an Ethereum wallet to manage your funds.

Please note that the sandbox environment is deprecated and will be replaced with an alternative solution in the future.

public class Configuration extends Configuration {
	public ConfigurationForTest() {
		super();
		set__DEV__(true); // sandbox: true, live: false
		setApiKey("{Your API Key}");
		setApiSecret("{Your API Secret}");
		setWebhookSecret("{Your Webhook Secret}");
		setMasterEthereumAddress("{Your Ethereum Address}");
		setMasterEthereumPrivateKey("{Your Ethereum Private Key}");
	}
}

Gluwa SDK For Java works with JDK 1.8 or higher.

Method Examples

public void postTransaction_test() {
	GluwaApiSDKImpl wrapper = new GluwaApiSDKImpl(new ConfigurationForTest());
	GluwaTransaction transaction = new GluwaTransaction();

	transaction.setCurrency("{Currency}"); // Currency.KRWG, Currency.NGNG
	transaction.setAmount("{Amount}");
	transaction.setTargetAddress("{Target's Address}");
	transaction.setNote("{Note}");
	transaction.setMerchantOrderID("{Your OrderID}");

	GluwaResponse result = wrapper.postTransaction(transaction);
}

public void getPaymentQRCode_example() {
	Configuration conf = new ConfigurationForTest();
	GluwaApiSDKImpl sdkImpl = new GluwaApiSDKImpl(conf);

	GluwaTransaction transaction = new GluwaTransaction();
	transaction.setCurrency(Currency.USDCG);
	transaction.setAmount("51");
	transaction.setExpiry(1800);
}

getPaymentQRCode API returns a QR code png image as a Base64 string. You can display the image on your website as below:

<img src="data:image/png;base64,{BASE64_STRING_YOU_RECEIVED}" alt="Gluwa Payment QR Code">

Create a Payment QR Code​ With Payload

public void getPaymentQRCodeWithPayload_example() {
  Configuration conf = new ConfigurationForTest();
  GluwaApiSDKImpl sdkImpl = new GluwaApiSDKImpl(conf);

  GluwaTransaction transaction = new GluwaTransaction();
  transaction.setCurrency(Currency.USDCG);
  transaction.setAmount("51");
  transaction.setExpiry(1800);

  // `getPaymentQRCode` API returns QR code png image as a Base64 string and payload.
  GluwaResponse result = sdkImpl.getPaymentQRCodeWithPayload(transaction);
  assertNotNull(result);
}

public void getListTransactionHistory_test() {
  Configuration conf = new ConfigurationForTest();
  GluwaApiSDKImpl wrapper = new GluwaApiSDKImpl(conf);

  GluwaTransaction transaction = new GluwaTransaction();
  transaction.setCurrency("{Currency}");
  transaction.setLimit(100); // optional
  transaction.setStatus("Confirmed"); // optional
  transaction.setOffset(0); // optional

  GluwaResponse result = wrapper.getListTransactionHistory(transaction);
}

public void getListTransactionDetail_test() {
  Configuration conf = new ConfigurationForTest();
  GluwaApiSDKImpl wrapper = new GluwaApiSDKImpl(conf);

  GluwaTransaction transaction = new GluwaTransaction();
  transaction.setCurrency("{Currency}");
  transaction.setTxnHash("{Txn Hash}");

  GluwaResponse result = wrapper.getListTransactionDetail(transaction);
}

public void getAddresses_Test() {
  Configuration conf = new ConfigurationForTest();
  GluwaApiSDKImpl wrapper = new GluwaApiSDKImpl(conf);

  GluwaTransaction transaction = new GluwaTransaction();
  transaction.setCurrency("{Currency}");

  GluwaResponse result = wrapper.getAddresses(transaction);
}

When the user completes the transfer via the QR code, the Gluwa API sends a webhook to your webhook endpoint. Verify that the values ​​were actually sent from the Gluwa server.‌

Verify the requested Signature and Payload as follows:

public void validateWebhook_test() {
  Configuration conf = new ConfigurationForTest();
  GluwaApiSDKImpl wrapper = new GluwaApiSDKImpl(conf);
  boolean result = wrapper.validateWebhook(
    "{Payload in Request's body}",
    "{Signature in Request's header}");
}

Last updated