Skip to content

hachther/mesomb-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Welcome to java-mesomb ๐Ÿ‘‹

Version Documentation License: MIT Twitter: hachther

JAVA client for MeSomb services.

You can check the full documentation of the api here

๐Ÿ  Homepage

Installation

Gradle

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.hachther:mesomb-java:1.1.3'
}

Maven

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Step 2. Add the dependency

<dependency>
    <groupId>com.github.hachther</groupId>
    <artifactId>mesomb-java</artifactId>
    <version>Tag</version>
</dependency>

Usage

Collect money from an account

package com.hachther.mesomb.operations;

import com.hachther.mesomb.util.RandomGenerator;
import com.hachther.mesomb.exceptions.InvalidClientRequestException;
import com.hachther.mesomb.exceptions.PermissionDeniedException;
import com.hachther.mesomb.exceptions.ServerException;
import com.hachther.mesomb.exceptions.ServiceNotFoundException;
import com.hachther.mesomb.models.Application;
import com.hachther.mesomb.models.TransactionResponse;
import com.hachther.mesomb.operations.PaymentOperation;

class Test {
    public static void main(String args[]) {
        PaymentOperation payment = new PaymentOperation(this.applicationKey, this.accessKey, this.secretKey);
        try {
            TransactionResponse response = payment.makeCollect(new HashMap<String, Object>() {{
                put("amount", 100);
                put("service", "MTN");
                put("payer", "670256547");
                put("nonce", RandomGenerator.nonce());
            }});
        } catch (IOException | NoSuchAlgorithmException | InvalidKeyException | ServerException |
                 ServiceNotFoundException | PermissionDeniedException | InvalidClientRequestException e) {
            throw new RuntimeException(e);
        }
    }
}

Depose money in an account

package com.hachther.mesomb.operations;

import com.hachther.mesomb.util.RandomGenerator;
import com.hachther.mesomb.exceptions.InvalidClientRequestException;
import com.hachther.mesomb.exceptions.PermissionDeniedException;
import com.hachther.mesomb.exceptions.ServerException;
import com.hachther.mesomb.exceptions.ServiceNotFoundException;
import com.hachther.mesomb.models.Application;
import com.hachther.mesomb.models.TransactionResponse;
import com.hachther.mesomb.operations.PaymentOperation;

class Test {
    public static void main(String args[]) {
        PaymentOperation payment = new PaymentOperation(this.applicationKey, this.accessKey, this.secretKey);
        try {
            TransactionResponse response = payment.makeDeposit(new HashMap<String, Object>() {{
                put("amount", 100);
                put("service", "MTN");
                put("receiver", "670256547");
                put("nonce", RandomGenerator.nonce());
            }});
        } catch (IOException | NoSuchAlgorithmException | InvalidKeyException | ServerException |
                 ServiceNotFoundException | PermissionDeniedException | InvalidClientRequestException e) {
            throw new RuntimeException(e);
        }
    }
}

Get application status

package com.hachther.mesomb.operations;

import com.hachther.mesomb.exceptions.InvalidClientRequestException;
import com.hachther.mesomb.exceptions.PermissionDeniedException;
import com.hachther.mesomb.exceptions.ServerException;
import com.hachther.mesomb.exceptions.ServiceNotFoundException;
import com.hachther.mesomb.models.Application;
import com.hachther.mesomb.operations.PaymentOperation;

class Test {
    public static void main(String args[]) {
        PaymentOperation payment = new PaymentOperation(this.applicationKey, this.accessKey, this.secretKey);
        try {
            Application response = payment.getStatus();
        } catch (IOException | NoSuchAlgorithmException | InvalidKeyException | ServerException |
                 ServiceNotFoundException | PermissionDeniedException | InvalidClientRequestException e) {
            throw new RuntimeException(e);
        }
    }
}

Get transactions by IDs

package com.hachther.mesomb.operations;

import com.hachther.mesomb.exceptions.InvalidClientRequestException;
import com.hachther.mesomb.exceptions.PermissionDeniedException;
import com.hachther.mesomb.exceptions.ServerException;
import com.hachther.mesomb.exceptions.ServiceNotFoundException;
import com.hachther.mesomb.models.Application;
import com.hachther.mesomb.operations.PaymentOperation;

class Test {
    public static void main(String args[]) {
        PaymentOperation payment = new PaymentOperation(this.applicationKey, this.accessKey, this.secretKey);
        try {
            payment.getTransactions(new String[]{"ID1", "ID2"});
        } catch (IOException | NoSuchAlgorithmException | InvalidKeyException | ServerException |
                 ServiceNotFoundException | PermissionDeniedException | InvalidClientRequestException e) {
            throw new RuntimeException(e);
        }
    }
}

Author

๐Ÿ‘ค Hachther LLC [email protected]

Show your support

Give a โญ๏ธ if this project helped you!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages