Giter Club home page Giter Club logo

remittance-simulator's Introduction

Mayannah

Build Status

Simulates a remittance transaction

Content:

  1. Installation
  2. Usage
    1. Environment Variables
    2. Admin Page
    3. API
      1. Authentication
      2. Create Remittance
      3. List Remittance
      4. Search Remittance
      5. Pay Remittance
      6. Deposit And Withdraw Virtual Money
      7. Complete or pay a Transaction
      8. Health Check

Installation

Requirements:

  • Postgresql container named mayannah-db
$ git clone <repo>
$ cd mayannah
$ docker build -t mayannah:latest .
# link to a postgresql container
$ docker run --name mayannah --link mayannah-db -d mayannah:latest
# For Customize settings
#$ docker run --name mayannah \
#             --link mayannah-db \
#             -v $PWD/prod.env:/mayannah/prod.env
#             -d mayannah:latest
# Create a superuser
$ docker exec -it mayannah python manage.py createsuperuser
# open in browser 
# http://localhost:8000

Usage

Environment Variables

Mayannah uses the file prod.env for its environment variable. Edit as needed

Name Description
DATABASE_URL Configuration for Database
SENTRY DSN of sentry

Reference:

Django Environ Sentry

Admin Page

http://localhost:8000/admin/

Admin Page is used to create Users, It can also create, edit, and view Remittance records.

API

Authentication

Basic Authentication or JWT Token is required for all API calls. All users with login credentials can access the API.

Use Admin page to create a User.

For JWT Token Generation:

$ curl -X POST -H "Content-Type: application/json" \
               -d '{"token":"<EXISTING_TOKEN>"}' \
               http://localhost:8000/api-token-refresh/

Sample Response:

{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImJqIiwiZXhwIjoxNTAxMDUyMTA3LCJlbWFpbCI6IiJ9.9hEn-Ra1YiDXgQaHOkNIvmGArLNpeapo5egwAM7jyOM"
}

All headers must now contain:

authorization: JWT <token>

Create Remittance

POST /v1/remittance

fields:

name type description
source_reference_number string required
remitter person required person details
beneficiary person required person details
payout_amount integer required
payout_currency string required

Person

name type description
first_name string required
last_name string required
address string optional
country string optional or it defaults to Philippines
contact_number string optional

Request:

{
	"source_reference_number": "remittance-quatro",
	"remitter": {
		"first_name": "remi",
		"last_name": "ter",
		"address": "Manila",
		"country": "Philippines"
	},
	"beneficiary": {
		"first_name": "beni",
		"last_name": "ficiary",
		"contact_number": "555000668899",
		"address": "",
		"country": "Philippines",
		"identification_type": "SSS",
		"identification_id": "55552222111"
	},
	"payout_amount": 500000,
	"payout_currency": "PH"
	
}

Response

{
	"source_reference_number": "remittance-quatro",
	"slug": "remittance-quatro",
	"remitter": {
		"first_name": "remi",
		"last_name": "ter",
		"contact_number": "",
		"address": "Manila",
		"country": "Philippines",
		"identification_type": "",
		"identification_id": ""
	},
	"beneficiary": {
		"first_name": "beni",
		"last_name": "ficiary",
		"contact_number": "555000668899",
		"address": "",
		"country": "Philippines",
		"identification_type": "SSS",
		"identification_id": "55552222111"
	},
	"payout_amount": 500000,
	"payout_currency": "PH",
	"status": "AVAILABLE"
}

List Remittance

List all Remittance

GET /v1/remittance

Response:

[
	{
		"source_reference_number": "remittance-uno",
		"slug": "remittance-uno",
		"remitter": {
			"first_name": "remi",
			"last_name": "ter",
			"contact_number": "",
			"address": "Manila",
			"country": "Philippines",
			"identification_type": "",
			"identification_id": ""
		},
		"beneficiary": {
			"first_name": "beni",
			"last_name": "ficiary",
			"contact_number": "555000668899",
			"address": "",
			"country": "Philippines",
			"identification_type": "SSS",
			"identification_id": "55552222111"
		},
		"payout_amount": 50000,
		"payout_currency": "PH",
		"status": "PAID"
	},
	{
		"source_reference_number": "remittance-dos",
		"slug": "remittance-dos",
		"remitter": {
			"first_name": "remi",
			"last_name": "ter",
			"contact_number": "",
			"address": "Manila",
			"country": "Philippines",
			"identification_type": "",
			"identification_id": ""
		},
		"beneficiary": {
			"first_name": "beni",
			"last_name": "ficiary",
			"contact_number": "555000668899",
			"address": "",
			"country": "Philippines",
			"identification_type": "SSS",
			"identification_id": "55552222111"
		},
		"payout_amount": 500000,
		"payout_currency": "PH",
		"status": "AVAILABLE"
	},
	{
		"source_reference_number": "remittance-tres",
		"slug": "remittance-tres",
		"remitter": {
			"first_name": "remi",
			"last_name": "ter",
			"contact_number": "",
			"address": "Manila",
			"country": "Philippines",
			"identification_type": "",
			"identification_id": ""
		},
		"beneficiary": {
			"first_name": "beni",
			"last_name": "ficiary",
			"contact_number": "555000668899",
			"address": "",
			"country": "Philippines",
			"identification_type": "SSS",
			"identification_id": "55552222111"
		},
		"payout_amount": 1000,
		"payout_currency": "PH",
		"status": "AVAILABLE"
	}
]

SEARCH Specific Remittance

Returns a result of specific Remittance

POST /v1/remittance/

Parameter

Name Type Description
remittance_slug string slug of remittance transaction. Can be seen during create remittance.

Response:

{
	"source_reference_number": "remittance-dos",
	"slug": "remittance-dos",
	"remitter": {
		"first_name": "remi",
		"last_name": "ter",
		"contact_number": "",
		"address": "Manila",
		"country": "Philippines",
		"identification_type": "",
		"identification_id": ""
	},
	"beneficiary": {
		"first_name": "beni",
		"last_name": "ficiary",
		"contact_number": "555000668899",
		"address": "",
		"country": "Philippines",
		"identification_type": "SSS",
		"identification_id": "55552222111"
	},
	"payout_amount": 500000,
	"payout_currency": "PH",
	"status": "AVAILABLE"
}

Pay Remittance

Updates the status of remittance record to PAID. Only available transactions can be PAID.

POST /v1/remittance/pay

Inputs:

Name Type Description
source_reference_number string required

Request:

{
	"source_reference_number": "remittance-quatro"
}

Response:

{
	"message": "Successfully Tagged as Paid"
}

Curl:

curl --request POST \
  --url http://localhost:8000/v1/remittance/pay/ \
  --header 'authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImJqIiwiZXhwIjoxNTAxMDUyMTA3LCJlbWFpbCI6IiJ9.9hEn-Ra1YiDXgQaHOkNIvmGArLNpeapo5egwAM7jyOM' \
  --header 'content-type: application/json' \
  --data '{"source_reference_number": "remittance-quatro"}'

Deposit And Withdraw Virtual Money

Deposit or Withdraw money to a users account

POST /v1/transaction/

Inputs:

Name Type Description
account string Name of user account
branch string Branch Name
amount integer Amount more than 1
type string DEPOSIT or WITHDRAW

Sample Request:

curl --request POST \
  --url http://localhost:8002/v1/transaction/complete \
  --header 'authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImJqIiwiZXhwIjoxNTAxMDUyMTA3LCJlbWFpbCI6IiJ9.9hEn-Ra1YiDXgQaHOkNIvmGArLNpeapo5egwAM7jyOM' \
  --header 'content-type: application/json' \
  --data '{"account": "bj",
	   "branch": "ayannah",
	   "amount": 200,
	   "type": "DEPOSIT"}'

Response

{
	"reference_id": "a133925d-6276-4cb7-9364-0dd70939a966",
	"account": "bj",
	"branch": "ayannah",
	"amount": 200,
	"type": "DEPOSIT"
}

Complete or pay a Transaction

Inputs

Name Type Description
Source Reference Number string Source Reference Number of transaction
curl --request POST \
  --url http://localhost:8002/v1/transaction/complete/ \
  --header 'authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImJqIiwiZXhwIjoxNTAxMDUyMTA3LCJlbWFpbCI6IiJ9.9hEn-Ra1YiDXgQaHOkNIvmGArLNpeapo5egwAM7jyOM' \
  --header 'content-type: application/json' \
  --data '{"reference_id": "a133925d-6276-4cb7-9364-0dd70939a966"}'

Response:

{
	"status": "Already Paid"
}

Health Check

GET /health/<staging or production

remittance-simulator's People

Contributors

merlinsbeard avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.