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.
Please do NOT use Omise Java library versions less than 3.1.1, as they are outdated and have security vulnerabilities.
As of version v5.0.0
, joda-time
has been deprecated in favor of java-time so you might see a different format for the string output of date parameters and some functions might not be available anymore. For more reference view this PR(#173)
Although you can use omise-java with other Java versions, we have validated the following versions in our CI pipeline to ensure compatibility and stability.
Represents the Java version you must install on your local system to run the precompiled Java byte code inside your project. i.e., install the SDK from Maven for your project and run it on your custom project.
Represents the Java version required to compile the SDK after you clone the SDK's repo or fork it.
Library Version | Support | Supported Omise API Version | JRE Supported | Java Version (Compilation) | Compilation Tested | Notes |
---|---|---|---|---|---|---|
1.x | End of Life (EOL) | 2014-07-27 | >= 5 | >= 7 | N/A | Initial release with basic features. No longer maintained. |
2.x | End of Life (EOL) | 2017-11-02 | >= 6 | >= 8 | N/A | Ground-up rewrite onto Java7 to be more robust and maintainable. No longer maintained. |
3.x | End of Life (EOL) | 2019-05-29 | >= 8 | >= 8 | Java 8 | Used latest API version (2019-05-29 ). No longer maintained. |
4.x | Maintenance Mode | 2019-05-29 | >= 8 | >= 8 | Java 8 | v4 migration. Check guide |
5.x | Active | 2019-05-29 | >= 8 | >= 11 | Java 21 | Update gradle to 8.7 and JDK to 21 and replace deprecated joda time. |
*Maintenance mode includes only bug fixes and security updates.
You can use your preferred method of managing dependencies in order to install the omise-java library. Below you will find some popular examples:
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.
Add the following line to your build.gradle
file:
dependencies {
compile 'co.omise:omise-java:4.+'
}
Add the following dependency to your build.gradle.kts
file:
dependencies {
implementation("co.omise:omise-java:4.+")
}
Add the following dependency to your pom.xml
file:
<dependency>
<groupId>co.omise</groupId>
<artifactId>omise-java</artifactId>
<version>4.0.0</version>
</dependency>
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
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());
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.