Skip to content

omjigupta/payment-api

Repository files navigation

Money Transfer Api

play-java-payment application v2.6 + H2 DB + Jooq (Play JPA implementation)

This is a starter application that has base setup of Play 2.6 with H2 as database. This repository will constantly updated on better changes.

Please see the documentation at https://www.playframework.com/documentation/latest/Home for more details.

Running

Running server in console

Run this using sbt. If you downloaded this project then you'll find a prepackaged version of sbt in the project directory:

sbt clean run

And then go to http://localhost:9000 to see the running web application.

Running as Standalone server

Using tar payment-api-1.0.tgz

  1. Download the payment-api-1.0.tgz file available in the root of the project. If you clone this repo you will get inside the payment-api main directory.
  2. Extract the tar file in a folder of your preference.
tar -xvzf /path/to/payment-api-1.0.tgz
  1. You can either navigate to the extracted folder or execute the app from the folder you are.
payment-api-1.0/bin/payment-api -Dplay.http.secret.key=omjigupta

Using zip payment-api-1.0.zip

  1. Download the payment-api-1.0.zip file available in the root of the project.
  2. Extract the zip file in a folder of your preference.
unzip payment-api-1.0.zip 
  1. Navigate to the extracted folder or execute below command to run it
sh bin/payment-api

Testing in console

By running below command. You can check the test results in the terminal

sbt test

TestResult

Requirements:

  1. Java JDK 1.8
  2. Scala SBT 1.2.8

Currency Support:

  1. Currently, Application is supporting only INR, USD and EUR.
  2. Currency conversion values are hardcoded for now. Conversion rates added from exchange.

Endpoints:

(GET) Ping - "About me" and application start request

http://localhost:9000/about

By Hitting above request you will be redirected to my LinkedIn profile

http://localhost:9000/

By Hitting this request you can check application is running or not

(GET) Get the Balance of Specific Account

http://localhost:9000/v1/accounts/424800/balance

balance

(GET) Checking Balance if Account does not Exist

http://localhost:9000/v1/accounts/1234/balance

wrongAccount

(POST) Transfers money between same currency accounts

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":324800,
"receiverAccountId":533000,
"amount":10,
"currency":"INR"
}
  • HTTP Response:

transfer

(POST) Transfers money between cross currency accounts

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":124800,
"receiverAccountId":533000,
"amount":1,
"currency":"EUR"
}
  • HTTP Response:

transfer

(POST) Transfers money between cross currency accounts when given amount in different currency

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":124800,
"receiverAccountId":533000,
"amount":1,
"currency":"USD"
}
  • HTTP Response: You can see selected part of image.

transfer

(POST) Transfers money between cross currency accounts if Sender doesn't have enough fund

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":124800,
"receiverAccountId":533000,
"amount":15,
"currency":"EUR"
}
  • HTTP Response:

transfer

(POST) Transfers Negative money between cross currency accounts

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":124800,
"receiverAccountId":533000,
"amount":-1,
"currency":"EUR"
}
  • HTTP Response:

transfer

(POST) Transfers Negative money between cross currency accounts

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":324800,
"receiverAccountId":533000,
"amount":10,
"currency":"YEN"
}
  • HTTP Response:

transfer

(POST) Transfers money when account doesn't exist

http://localhost:9000/v1/transactions
  • HTTP Request:
POST /v1/transactions HTTP/1.1
Accept: application/json
Host: localhost:9000

{
"senderAccountId":3200,
"receiverAccountId":533000,
"amount":10,
"currency":"USD"
}
  • HTTP Response:

transfer

About

Money Transfer Api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published