eGov Payment Gateway Integration

The module acts as a liaison between eGov apps and external payment gateways. It facilitates payments, reconciliation of payments, and lookup of transactions 'status'.

Payment Flow

  • Create

    • Transaction to be initiated with a call to the transaction/_create API, various validations are carried out to ensure the sanctity of the request.

    • The response includes a generated transaction id and a redirect URL to the payment gateway itself.

  • Redirect

    • Once the transaction completed by the user post redirection, the Payment gateway will send the status of the transaction.

    • If this is an HTTP POST call, we have to provide /transaction/v1/_redirect as the redirect URL.

    • This endpoint will redirect to the appropriate URL that will handle the transaction update

  • Update

    • Once the transaction is completed by following the redirect URL, transaction/_update endpoint is to be called with the query params returned by the gateway.

    • Various validations are carried out to verify the authenticity of the request and the status is updated accordingly.

    • If the transaction is successful, a receipt is generated for the same.

  • Search

    • Transactions can be queried based on several search parameters as detailed in the swagger YAML Check out Resources section.

Reconciliation

  • Reconciliation is carried out by two jobs scheduled via a Quartz clustered scheduler.

  • Early Reconciliation job is set to run every 15 minutes [configurable via app properties] and is aimed at reconciling transactions that were created 15 - 30 minutes ago and are in PENDING state.

  • Daily Reconciliation job is set to run once per day and is aimed at reconciling all transactions that are in PENDING state, except for ones that were created 30 minutes ago.

Project Structure

Packages

  • config - All configuration related to the App, including main quartz scheduler configs

  • service - Consists of main service classes for app functioning.

  • service/gateways/{gatewayName} - Third-party payment gateways, each sub-package to encapsulate the entire code needed for the gateway.

  • service/jobs/* - Contains jobs and respective configs for the jobs which are to be scheduled on the Quartz scheduler

  • web/controllers - Controllers for the app.

Extension

  • Additional gateways can be added by implementing the Gateway interface.

Resources

Gateways Supported

  • AXIS

  • PAYTM

  • PHONEPE

  • CCAVENUE

Build & Run

mvn clean install java -jar target/egov-pg-service-0.0.1-SNAPSHOT.jar

Dependencies

  • Postgres database to store transaction data and enable quartz clustered scheduling.

  • Collection Service to validate request and to create receipts.

  • ID Gen Module to generate unique transaction ID's.

  • Persister module for persistence.

  • Merchant specific properties, such as merchant id and secret needs to be configured.

Configurations

CCAVENUE

  • active: The payment gateway activation status.

  • redirect working key: working key provided by ccavenue for the generation of redirection URL.

  • status working key: working key provided by ccavenue to check the status of a transaction.

  • merchant id: merchant id provided by ccavenue.

  • redirect access code: access code provided by ccavenue for the generation of redirection URL.

  • status access code: access code provided by ccavenue to check the status of a transaction.

  • currency: Currency type INR for Indian Rupee

  • redirect url: URL to which payment gateway will send the status of the transaction if it is successful

  • cancel url: URL to which payment gateway will send the status of the transaction if it is unsuccessful

  • language: Display Language on the payment gateway page.

  • gateway url: Base gateway URL to form redirect URL.

  • gateway status url: Base gateway URL to form URL to get status of the transaction

  • original return url key: Key name used in the redirection URL to store the original URL.

Data Sent to For Every Transaction

  • amount: Amount of transactions.

  • cancel_url: URL to which payment gateway will send the status of the transaction if it is unsuccessful

  • currency: Currency type INR for Indian Rupee

  • language: Display Language on the payment gateway page.

  • merchant_id: merchant id provided by ccavenue.

  • order_id: Unique id generated by this service to identify the transaction

  • redirect_url: URL to which payment gateway will send the status of the transaction if it is successful

  • sub_account_id: Key to identify the bank account to deposit the funds.