Skip to content

payabbhi/payabbhi-java

Repository files navigation

Payabbhi Java Library

Make sure you have signed up for your Payabbhi Account and downloaded the API keys from the Portal.

Requirements

Java 1.7 or later.

Installation

Maven

Include this dependency in your Maven pom.xml:

<dependency>
  <groupId>com.payabbhi</groupId>
  <artifactId>payabbhi-java</artifactId>
  <version>1.0.2</version>
</dependency>

Gradle

Include this dependency in your Gradle build file build.gradle:

compile "com.payabbhi:payabbhi-java:1.0.2"

Manual Download

An alternative is to manually download the JAR for Payabbhi Java Library from Maven repository

Payabbhi Java library has the following dependencies which should be included separately:

Documentation

Please refer to:

Usage

A typical usage of the Payabbhi Java Library is shown below:

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.payabbhi.Payabbhi;
import com.payabbhi.exception.PayabbhiException;
import com.payabbhi.model.Order;

public class Example {

	public static void main(String[] args) {

		Payabbhi.accessId  = "<your-access-id>";
		Payabbhi.secretKey = "<your-secret-key>";

		try {
			Map<String, Object> params = new HashMap<>();
			params.put("merchant_order_id", "0211");
			params.put("amount", 10000);
			params.put("currency", "INR");

			Order order = Order.create(params);

			System.out.println(order);

		} catch (PayabbhiException e) {
			e.printStackTrace();
		}
	}

}

For more examples see the Java API documentation

Payment Signature Verification

Payabbhi Java library provides utility function for verifying the payment signature received in the payment callback.

Map<String, String> params = new HashMap()
params.put("order_id", "<order-id>");
params.put("payment_id", "<payment-id>");
params.put("payment_signature", "<payment-signature>");
Payabbhi.verifyPaymentSignature(params)

Webhook Signature Verification

Payabbhi Java library provides utility function for webhook signature verification.

import com.payabbhi.Payabbhi;

// In this call default value of replayInterval is 300 seconds
Payabbhi.verifyWebhookSignature("<payload>", "<signature>", "<secret>");

Payabbhi.verifyWebhookSignature("<payload>", "<signature>", "<secret>", <replayInterval>);

Test

Comment the following lines of code in the file build.gradle as below

// id 'signing'
// signing {
//     sign configurations.archives
// }

Run the following command to build and execute unit tests

$ gradle build

A html report will be generated in file build/reports/tests/test/index.html