opay-java-sdk

The parent project of dubbo

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.opayweb
ArtifactId

ArtifactId

opay-java-sdk
Last Version

Last Version

1.0.1-RELEASE
Release Date

Release Date

Type

Type

pom
Description

Description

opay-java-sdk
The parent project of dubbo
Project URL

Project URL

https://github.com/opay-services/opay-sdk-java
Source Code Management

Source Code Management

https://github.com/opay-services/opay-sdk-java.git

Download opay-java-sdk

How to add to project

<!-- https://jarcasting.com/artifacts/com.opayweb/opay-java-sdk/ -->
<dependency>
    <groupId>com.opayweb</groupId>
    <artifactId>opay-java-sdk</artifactId>
    <version>1.0.1-RELEASE</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.opayweb/opay-java-sdk/
implementation 'com.opayweb:opay-java-sdk:1.0.1-RELEASE'
// https://jarcasting.com/artifacts/com.opayweb/opay-java-sdk/
implementation ("com.opayweb:opay-java-sdk:1.0.1-RELEASE")
'com.opayweb:opay-java-sdk:pom:1.0.1-RELEASE'
<dependency org="com.opayweb" name="opay-java-sdk" rev="1.0.1-RELEASE">
  <artifact name="opay-java-sdk" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.opayweb', module='opay-java-sdk', version='1.0.1-RELEASE')
)
libraryDependencies += "com.opayweb" % "opay-java-sdk" % "1.0.1-RELEASE"
[com.opayweb/opay-java-sdk "1.0.1-RELEASE"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • java-sdk-core
  • java-sdk-samples

OPay sdk for java

Latest Stable Version

Welcome to use OPay SDK for Java. OPay SDK for Java allows you to call API without complicated programming.

This document introduces how to obtain and call OPay SDK for Java.

If you have any problem while using OPay SDK for Java, please submit an issue.

Requirements

  • To use OPay SDK for Java, you must have an OPay merchant account as well as an Merchant ID and an AccessKey Secret. Create and view your AccessKey on the Merchant Dashboard.

  • The OPay Java SDK requires JDK 1.8 or later.

Installation

If you use Apache Maven to manage Java projects, you only need to add corresponding dependencies to the pom.xml files of the projects.

<dependency>
     <groupId>com.opayweb</groupId>
     <artifactId>java-sdk-core</artifactId>
     <version>1.0.0-RELEASE</version>
 </dependency>

If maven is not downloading jar packages from a central repository, you need to add these dependencies in the pom.xml file, or a NoClassDefFoundError exception will be reported

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.16</version>
</dependency>

<dependency>
    <groupId>com.konghq</groupId>
    <artifactId>unirest-java</artifactId>
    <version>3.11.11</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.30</version>
</dependency>

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.73</version>
</dependency>

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.60</version>
    <scope>compile</scope>
</dependency>

Quick Examples

The following code example shows the three main steps to use OPay SDK for Java :

  1. Create and initialize a OPayPaymentClient instance.

  2. Create an API request and set parameters.

  3. Initiate the request and handle the response or exceptions.

package com.opay.java.sdk.samples.cashier;
import com.opay.java.sdk.samples.Config;
import com.opay.sdk.OPayPaymentClient;
import com.opay.sdk.common.DefaultProfile;
import com.opay.sdk.enums.CashierPayMethodEnum;
import com.opay.sdk.enums.CashierPayTypeEnum;
import com.opay.sdk.enums.Environment;
import com.opay.sdk.exception.OPayException;
import com.opay.sdk.model.request.CashierInitializeRequest;
import com.opay.sdk.model.response.CashierInitializeResponse;
import org.apache.http.util.Asserts;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
       
        //initialize config
        DefaultProfile profile = DefaultProfile.getProfile(Environment.SANDBOX, "<your-merchant-id>", "<your-public-key>", "<your-private-key>");
        //Create and initialize a OPayPaymentClient instance
        OPayPaymentClient client = new OPayPaymentClient(profile);
        //Create an API request and set parameters
        CashierInitializeRequest request = new CashierInitializeRequest();
        request.setReference(System.currentTimeMillis() + "");
        request.setMchShortName("Test");
        request.setProductDesc("The best wireless earphone in history");
        request.setProductName("IPhone");
        request.setUserPhone("+2348161564736");
        request.setUserRequestIp("123.4.5.6");
        request.setAmount("100");
        request.setCurrency("NGN");
        List<CashierPayTypeEnum> payTypes = new ArrayList();
        payTypes.add(CashierPayTypeEnum.BalancePayment);
        payTypes.add(CashierPayTypeEnum.OWealth);
        payTypes.add(CashierPayTypeEnum.BonusPayment);
        request.setPayTypes(payTypes);
        List<CashierPayMethodEnum> payMethods = new ArrayList();
        payMethods.add(CashierPayMethodEnum.account);
        payMethods.add(CashierPayMethodEnum.qrcode);
        payMethods.add(CashierPayMethodEnum.bankCard);
        request.setPayMethods(payMethods);
        request.setCallbackUrl("http://www.baidu.com");
        request.setReturnUrl("http://www.baidu.com");
        request.setExpireAt("10");
        System.out.println(request);
        // Initiate the request and handle the response or exceptions
        CashierInitializeResponse response = null;
        try {
            response = client.cashierInitialize(request);
        } catch (OPayException e) {
            e.printStackTrace();
        }
    }
    
        
}

Click here for more samples.

Issues

Opening an Issue, Issues not conforming to the guidelines may be closed immediately.

Changelog

Detailed changes for each release are documented in the release notes.

References

Versions

Version
1.0.1-RELEASE
1.0.0-RELEASE