Skip to content

jpay-api/java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started with J-Pay API

Introduction

Java API SDK for J-Pay payment gateway

Installation

Add the dependency to your pom.xml:

<dependency>
  <groupId>com.github.jpay-api</groupId>
  <artifactId>java-sdk</artifactId>
  <version>v1.0.0</version>
</dependency>

Supported Java version is 8+. From the SDK project root, install the library into your local Maven cache:

mvn install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
apiKey String Merchant API key for automatic MD5 request signing on Payments API calls and webhook signature verification.
environment Environment The API environment.
Default: Environment.SANDBOX
httpClientConfig Consumer<HttpClientConfiguration.Builder> Set up HTTP client configuration (timeout, retries, proxy, SSL verification, etc.).
loggingConfig Consumer<ApiLoggingConfiguration.Builder> Set up logging configuration for API calls.

The API client can be initialized as follows:

import net.jpay.apilib.Environment;
import net.jpay.apilib.JPayApiClient;
import org.slf4j.event.Level;

JPayApiClient client = new JPayApiClient.Builder()
    .apiKey("your-merchant-api-key")
    .environment(Environment.SANDBOX)
    .loggingConfig(builder -> builder
        .level(Level.INFO)
        .requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
        .responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
    .httpClientConfig(configBuilder -> configBuilder
        .timeout(30))
    .build();

Environments

The SDK can be configured to use a different environment for making API calls. Available environments are:

Fields

Name Description
SANDBOX Sandbox (Default) — https://sandbox.j-pay.net
PRODUCTION Production — https://api.j-pay.net

Request Models & Builders

Each API endpoint supports typed request models with fluent builders aligned to the OpenAPI spec. All parameters use String types as defined in the API.

import net.jpay.apilib.models.requests.CreatePayoutRequest;
import net.jpay.apilib.models.requests.builders.CreatePayoutRequestBuilder;
import net.jpay.apilib.http.response.ApiResponse;

CreatePayoutRequest request = CreatePayoutRequestBuilder.init()
    .orderType("1")
    .memberid("10010")
    .outTradeNo("PO20260101001")
    .amount("100.00")
    .currency("USD")
    .notifyurl("https://example.com/payout/notify")
    .remark("Salary payout")
    .firstname("John")
    .payeeCountry("US")
    .payeeaccount("1234567890")
    .bankcode("001")
    .bankname("Test Bank")
    .build();

ApiResponse<Object> response = client.getPayoutsApi().create(request);
Object result = response.getResult();

Response payloads are automatically deserialized from the API JSON response.

Automatic Request Signing

When apiKey is configured, PaymentsApi automatically generates the MD5 signature (pay_md5sign) before sending outbound requests. You do not need to set payMd5Sign manually unless you want to override the computed value.

Signing follows the J-Pay signature algorithm: non-empty sign fields are sorted by name, joined as key=value&..., appended with &key={apiKey}, then MD5-hashed in uppercase.

For card payment creation (POST /pay_index), the signed fields are: pay_memberid, pay_orderid, pay_applydate, pay_bankcode, pay_notifyurl, pay_callbackurl, pay_amount.

List of APIs

SDK Infrastructure

Configuration

HTTP

Utilities

About

Java API SDK for J-Pay payment gateway

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages