Omise Java Library
Java
Latest commit 7a2f379 Jan 12, 2017 @chakrit chakrit v2.4.0

README.md

OMISE-JAVA

Maven Central Circle CI Gitter

This library has been updated to v2.0, check the v1 branch for the previous version.

Omise-java provides a set of Java bindings to the Omise REST API. Please contact chakrit@omise.co or support@omise.co if you have any questions regarding this library and the functionality it provides.

INSTALLATION

Android

WARNING: Android users should check out our omise-android repository instead.

This library requires Java 7 and up and is meant to be used with Java server implementations.

Gradle\Maven

Adds to your build.gradle file.

dependencies {
    compile 'co.omise:omise-java:2.0.8'
}

Shadow JAR

If you have dependency conflicts with omise-java jar you can try using the shadowed JAR version which has the JAR dependencies relocated to the co.omise.dependencies package.

You can obtain a shadowed jar by manually cloing the project and running the shadowJar task:

$ git clone git://github.com/omise/omise-java
$ cd omise-java
$ gradle shadowJar
:compileJava
:processResources
:classes
:shadowJar

BUILD SUCCESSFUL

$ ls builds/libs
omise-java-2.0.7-all.jar

USAGE

Obtain a set of API keys from the Omise Dashboard and creates a Client object:

Client client = new Client("pkey_test_123", "skey_test_123");

Access the API by calling methods on the provided Resource classes, for example to get current balance:

long money = client.balance().get().getTotal();

Creating a charge from a token:

Client client = new Client("pkey_test_123");

try {
    Charge charge = client.charges().create(new Charge.Create()
            .amount(100000) // THB 1,000.00
            .currency("THB")
            .card("tokn_test_123"));
    System.out.println("created charge: " + charge.getId());

} catch (IOException e) {
    e.printStackTrace();
}

LICENSE

MIT license