Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Pre-Transaction Workflow #450

Open
4 tasks
gitfelipegomes opened this issue Jan 7, 2025 · 1 comment
Open
4 tasks

Implement Pre-Transaction Workflow #450

gitfelipegomes opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
domain:transactions Responsible for transactions and operations feature New feature

Comments

@gitfelipegomes
Copy link
Member

Context

A pre-transaction is a mechanism for pre-processing values. It performs validation of the accounts involved in the transaction, reserves the amounts in the source accounts (on_hold), and keeps the transaction in a pending state, awaiting a subsequent call for confirmation (commit) or cancellation (cancel).

In the case of confirmation, the balances are effectively transferred to the destination accounts, and the corresponding debit and credit operations are recorded.

In the event of cancellation, the previously reserved amounts are returned to the available balance of the source accounts.

How to do it

Workflow

stateDiagram-v2
    state validate <<choice>>
    [*] --> validate: pre-transaction
    validate --> PRE_APPROVED: account validation success
    validate --> ERROR: account validation fail
    PRE_APPROVED --> APPROVED: commit
    PRE_APPROVED --> CANCELED: cancel
    APPROVED --> [*]
    CANCELED --> [*]
Loading

Step: Create Transaction

  1. Validate transaction
  2. Move the balance from the source accounts to on_hold
  3. Set transaction status to PRE_APPROVED

Action: Commit

  1. Transfer the reserved balances to the destination accounts
  2. Record the credit and debit operations
  3. Set status to APPROVED

Action: Cancel

  1. Return the reserved balances from the source accounts to the available balance
  2. Set status to CANCELED

To-do

  • Add pending:boolean field on transaction body
  • Create new column int the transaction database to store transaction JSON
  • Create transaction commit endpoint
  • Create transaction cancel endpoint
@gitfelipegomes gitfelipegomes added feature New feature domain:transactions Responsible for transactions and operations labels Jan 7, 2025
@MartinezAvellan MartinezAvellan removed their assignment Jan 13, 2025
@MartinezAvellan MartinezAvellan self-assigned this Jan 23, 2025
@fredcamaral
Copy link
Member

(syncing github issues with jira)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:transactions Responsible for transactions and operations feature New feature
Projects
None yet
Development

No branches or pull requests

3 participants