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.
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 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);
}
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:
publicvoidvalidateWebhook_test() {Configuration conf =newConfigurationForTest();GluwaApiSDKImpl wrapper =newGluwaApiSDKImpl(conf);boolean result =wrapper.validateWebhook("{Payload in Request's body}","{Signature in Request's header}");}