How to collect and disburse millions worth of payments securely.

Illustration showing payment collections and disbursements.

What is Disbursement?

Responsibilities and features

Data models and Flow

Important metrics to be observed

Overpayment = amountDisbursed - trueAmount
FrontedAmount = amountDisbursed — amountCollected
DeficitAmount = trueAmount - amountCollected

Data Models

Data Flow

Data-flow diagram representing connection with relevant entities.

Implementation with MongoDB

Commit

def commit(transaction):     
BalanceAccount.objects(
company=transaction.company,
transactions__ne=transaction
).modify(
inc__amount=transaction.amount,
push__transactions=transaction
)

Rollback

def rollback(transaction): 
assert transaction.canRollback
BalanceAccount.objects(
company=transaction.company,
transactions=transaction
).modify(
dec__amount=transaction.amount,
pull__transactions=transaction
)

Sample Code Snippet using Django ORM

Further reading

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store