Hi All,
Just wanted to get the communities feedback on a functionality such as 'transfer funds'.
The functional requirement is to transfer funds from one account A to another B where we can consider the account as resources.
The accounts can be within a local db or on a remote db.
How do you design and implement above requirement?
This is my thoughts on design and implementation:
API
I would have an API like
POST /api/transfer?fromaccount=133&toaccount=423&amount=1000
or
POST /api/transferMessage?fromaccount=133&toaccount=423&amount=1000 //to make it more clear that its a message to transfer
and implement transfer funds as a message, i.e
I would send out a message and return an id of the message for correlation
like
DEBIT ACCT 133 1000
CRDIT ACCT 423 1000
So the actual debit and credit will be implemented in a transnational context to ensure integrity of the transfer.
Then after transaction completes, I will post a message to the messaging system with message id and transaction status.
So the implementation of transfer funds will be Message resource rather than the account.
Any thoughts, suggestions on similar kind of API design.
Let me know if you need clarification of the above.
-JSM