项目作者: omjigupta

项目描述 :
Money Transfer Api
高级语言: Java
项目地址: git://github.com/omjigupta/payment-api.git
创建时间: 2019-06-05T17:15:33Z
项目社区:https://github.com/omjigupta/payment-api

开源协议:

下载


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:

  1. 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.

  1. tar -xvzf /path/to/payment-api-1.0.tgz

3) You can either navigate to the extracted folder or execute the app from the folder you are.

  1. 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.

  1. unzip payment-api-1.0.zip

3) Navigate to the extracted folder or execute below command to run it

  1. sh bin/payment-api

Testing in console

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

  1. 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

  1. http://localhost:9000/about

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

  1. http://localhost:9000/

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

(GET) Get the Balance of Specific Account

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

balance

(GET) Checking Balance if Account does not Exist

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

wrongAccount

(POST) Transfers money between same currency accounts

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

{
“senderAccountId”:324800,
“receiverAccountId”:533000,
“amount”:10,
“currency”:”INR”
}

  1. * HTTP Response:
  2. ![transfer](https://github.com/omjigupta/payment-api/blob/master/screenshots/transfer_between_same_currency.png)
  3. ### (POST) Transfers money between cross currency accounts

http://localhost:9000/v1/transactions

  1. * HTTP Request:
  2. ```json
  3. POST /v1/transactions HTTP/1.1
  4. Accept: application/json
  5. Host: localhost:9000
  6. {
  7. "senderAccountId":124800,
  8. "receiverAccountId":533000,
  9. "amount":1,
  10. "currency":"EUR"
  11. }
  • HTTP Response:

transfer

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

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

{
“senderAccountId”:124800,
“receiverAccountId”:533000,
“amount”:1,
“currency”:”USD”
}

  1. * HTTP Response:
  2. You can see selected part of image.
  3. ![transfer](https://github.com/omjigupta/payment-api/blob/master/screenshots/transferamount_currency_is_different_from_accounts.png)
  4. ### (POST) Transfers money between cross currency accounts if Sender doesn't have enough fund

http://localhost:9000/v1/transactions

  1. * HTTP Request:
  2. ```json
  3. POST /v1/transactions HTTP/1.1
  4. Accept: application/json
  5. Host: localhost:9000
  6. {
  7. "senderAccountId":124800,
  8. "receiverAccountId":533000,
  9. "amount":15,
  10. "currency":"EUR"
  11. }
  • HTTP Response:

transfer

(POST) Transfers Negative money between cross currency accounts

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

{
“senderAccountId”:124800,
“receiverAccountId”:533000,
“amount”:-1,
“currency”:”EUR”
}

  1. * HTTP Response:
  2. ![transfer](https://github.com/omjigupta/payment-api/blob/master/screenshots/NegativeBalanceTest.png)
  3. ### (POST) Transfers Negative money between cross currency accounts

http://localhost:9000/v1/transactions

  1. * HTTP Request:
  2. ```json
  3. POST /v1/transactions HTTP/1.1
  4. Accept: application/json
  5. Host: localhost:9000
  6. {
  7. "senderAccountId":324800,
  8. "receiverAccountId":533000,
  9. "amount":10,
  10. "currency":"YEN"
  11. }
  • HTTP Response:

transfer

(POST) Transfers money when account doesn’t exist

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

{
“senderAccountId”:3200,
“receiverAccountId”:533000,
“amount”:10,
“currency”:”USD”
}
```

  • HTTP Response:

transfer