This library has been updated to v2.7.2, check the v1 branch for the previous version.
Omise-java provides a set of Java bindings to the Omise REST API. Please contact support@omise.co if you have any questions regarding this library and the functionality it provides.
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.
Adds to your build.gradle
file.
dependencies {
compile 'co.omise:omise-java:2.7.2'
}
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.7.2-all.jar
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();
}