Skip to content

paytm/paytm-pg-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paytm Java SDK

Official java bindings for the Paytm API. [Api Link]

Documentation

Documentation of Paytm's API and their usage is available at Paytm Docs

Requirements

Java 1.7 or later

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>com.paytm.pg</groupId>
    <artifactId>pg-java</artifactId>
    <version>0.0.6</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.paytm.pg:pg-java:0.0.6"

Usage

Merchant will integrate Paytm Payment Gateway from below 2 steps:

1. Initialization of initial parameters

Merchant will initialize initial parameters (environment, mid, key, clientId, website) by calling MerchantProperties.initialize() method.

Environment should be "STAGE" for Staging/Testing and "PROD" for Production. You can obtain mid, key, clientId, website from Dashboard [Link/Documents]

// imports
// import com.paytm.pg.constants.MerchantProperties;

/** Setting Initial Parameters */
MerchantProperties.initialize("environment", "mid", "key", "clientId", "website");

Setting Callback URL

Callback URL will set by using MerchantProperties.setCallbackUrl() method. This url will be used in initiateTransaction API call.

// imports
// import com.paytm.pg.constants.MerchantProperties;

/** Setting Callback URL */
MerchantProperties.setCallbackUrl(callbackUrl);

Add custom Connection Timeout for request (optional)

// imports
// import com.paytm.pg.constants.MerchantProperties;
// import com.paytm.merchant.models.Time;
// import java.util.concurrent.TimeUnit;

/** Setting timeout for connection i.e. Connection Timeout */
MerchantProperties.setConnectionTimeout(new Time(5, TimeUnit.MINUTES));

Set java logger level and log file path for sdk logs (optional)

// imports
// import com.paytm.pg.constants.LibraryConstants;
// import java.util.logging.FileHandler;
// import java.util.logging.Level;
// import java.util.logging.SimpleFormatter;

/** Set Logger Level for Paytm logs */
LibraryConstants.LOGGER.setLevel(Level.ALL);

/** setting log file path "/paytm/MyLogFile.log" */
try {
	FileHandler fh = null;
	fh = new FileHandler("/paytm/MyLogFile.log");
	fh.setFormatter(new SimpleFormatter());
	LibraryConstants.LOGGER.addHandler(fh);

	/** Removing console handler from logger */
	LibraryConstants.LOGGER.setUseParentHandlers(false);
} catch (IOException e) {
	LibraryConstants.LOGGER.log(Level.SEVERE, e.toString(), e);
}

2. Integrate SDK Payment Gateway API

After initializing the initial parameters, Merchant can call SDK methods to call Payment Gateway API's.

SDK Apis

Class Method HTTP request Description
Payment createTxnToken POST /theia/api/v1/initiateTransaction Create Transaction Token
Payment getPaymentStatus POST /merchant-status/api/v1/getPaymentStatus Get Payment Status
Refund initiateRefund POST /refund/api/v1/async/refund Initiate Refund
Refund getRefundStatus POST /refund/api/v1/refundStatus Get Refund Status

Documentation for Models

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages