This is a library aiming to help you to integrate the PaySuite operations to your application.
To make the most of this library, make sure to have the following prerequisites ready:
- Acquire the necessary credentials by registering on the PaySuite portal
-
Add jitpack to your root
build.gradle
file, underrepositories
:repositories { // ... other repositories here ... maven { url 'https://jitpack.io' } }
-
Add the dependency:
dependencies { implementation 'com.github.hypertech-lda:paysuite-java-sdk:1.0.0' }
-
Add jitpack to your
pom.xml
file, underrepositories
:<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
-
Add the dependency:
<dependency> <groupId>com.github.hypertech-lda</groupId> <artifactId>paysuite-java-sdk</artifactId> <version>1.0.0</version> </dependency>
git clone https://github.com/hypertech-lda/paysuite-java-sdk
Using this SDK is very simple and fast, let us see some examples:
import mz.co.hypertech.paysuitejavasdk.Client;
import mz.co.hypertech.paysuitejavasdk.PaySuiteRequest;
Client client = new Client(apiKey);
PaySuiteRequest request = new PaySuiteRequest.Builder()
.tx_ref("REF001")
.currency("MZN")
.is_test("1")
.purpose("Invoice Payment")
.amount(100.0)
.callback_url("http://domain.com/callback_url")
.redirect_url("http://domain.com/invoice.php")
.build();
// Synchronous Call
try{
PaySuiteResponse response = client.initiatePaymentSync(request);
// Handle success scenario
}catch(Exception e){
// Handle failure scenario
}
// Asynchronous Call
client.initiatePaymentAsync(request,new ResponseListener(){
@Override
public void onSuccess(PaySuiteResponse response){
// Handle success scenario
}
@Override
public void onError(PaySuiteResponse errorResponse){
// Handle failure scenario
}
});