omise-java
omise-java copied to clipboard
Omise Java Library
Omise-Java
omise-java provides a set of Java bindings to the Opn Payments REST API. Please contact
[email protected] if you have any questions regarding this
library and the functionality it provides.
Security Warning
Please do NOT use Omise Java library versions less than 3.1.1, as they are outdated and have security vulnerabilities.
Installation
You can use your preferred method of managing dependencies in order to install the omise-java library. Below you will find some popular examples:
Android
WARNING: Android users should check out our omise-android repository instead.
This library requires Java 8 and higher and is meant to be used with Java server implementations.
Gradle
Add the following line to your build.gradle file:
dependencies {
compile 'co.omise:omise-java:4.+'
}
Kotlin
Add the following dependency to your build.gradle.kts file:
dependencies {
implementation("co.omise:omise-java:4.+")
}
Maven
Add the following dependency to your pom.xml file:
<dependency>
<groupId>co.omise</groupId>
<artifactId>omise-java</artifactId>
<version>4.0.0</version>
</dependency>
Shadow JAR
If you have dependency conflicts with the omise-java jar, you can try using the
shadowed JAR version that has the JAR dependencies relocated to the
co.omise.dependencies package.
You can obtain a shadowed jar by manually cloning 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-4.0.0-all.jar
Migration guide
- v4
- v3
Usage
Obtain a set of API keys from the Opn Payments Dashboard and create a Client object:
Client client = new Client.Builder()
.publicKey("pkey_test_123")
.secretKey("skey_test_123")
.build();
Access the API by creating a Request and sending it through the Client, for example to get
current Balance:
Request<Balance> request = new Balance.GetRequestBuilder().build();
Balance balance = client.sendRequest(request);
long total = balance.getTotal();
Creating a charge from a token:
Client client = new Client.Builder()
.publicKey("pkey_test_123")
.build();
Request<Charge> request =
new Charge.CreateRequestBuilder()
.amount(100000) // 1,000 THB
.currency("thb")
.card("card_test_4xtsoy2nbfs7ujngyyq")
.build();
Charge charge = client.sendRequest(request);
System.out.println("created charge: " + charge.getId());
License
MIT license On February 23, 2023, we started redirecting users from search.maven.org to central.sonatype.com. Launched in September of 2022, central.sonatype.com provides the main functionality of search.maven.org with enhanced search results, including security vulnerability and software quality information.