Skip to content

dmitry-matveyev/merchants

Repository files navigation

Task description:

Merchants have many payment transactions of different types.

Transaction Types:

  1. Authorize transaction - has amount and used to hold customer's amount
  2. Charge transaction - has amount and used to confirm the amount is taken from the customer's account and transferred to the merchant
  • The merchant's total transactions amount has to be the sum of the approved Charge transactions
  1. Refund transaction - has amount and used to reverse a specific amount (whole amount) of the Charge Transaction and return it to the customer
  • Transitions the Charge transaction to status refunded
  • The approved Refund transactions will decrease the merchant's total transaction amount
  1. Reversal transaction - has no amount, used to invalidate the Authorize Transaction
  • Transitions the Authorize transaction to status reversed

Goal is to propose an API to create transactions.

Solution

API:

api/v1/transactions => transations#create

PARAMS:

  • :amount
  • :type # one of (authorized charged refunded)
  • :transaction_id # for charged and refunded transaction types

How to run:

  • run app: docker-compose up app
  • run tests: docker-compose run test rspec
  • run rails console: docker-compose run app rails c

About

Example app for administrating merchants payments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published