-
Notifications
You must be signed in to change notification settings - Fork 92
Description
Resolves #1331
Problem
In theory, we can Pay a request before persisting it in the Request Network protocol.
In other words, we create a Request in memory without persisting it. Then, we prompt the end user to send payment against that request. Finally, we persist the request - so that it may serve as a receipt for the payment.
However, the existing SDK functions assume that the request is persisted immediately after being created.
Motivation
This shortens the critical path for a user making a payment. This is especially desirable for payment apps - in which a payer wants to buy something. The workflow is driven by the payer instead of the payee, so why make them wait for the request to be persisted before allowing them to send a payment?
Design
https://miro.com/app/board/uXjVKaiSdUM=/?share_link_id=173430896054
Proposed Solution
Create a new class in the transaction-manager package named something like InMemoryTransactionManager, which implements the TransactionTypes.ITransactionManager interface and is identical to the existing TransactionManager EXCEPT that the persistTransaction() function returns the Promise<TransactionTypes.IReturnPersistTransaction> without persisting the Request.
Usage: Inject the "InMemoryTransactionManager" when constructing the RequestNetwork instance. Requires adding an optional transactionManager argument to the RequestNetwork constructor. If the transactionManager argument is not provided, it should fall back to the current behavior - constructing a new TransactionManager using the dataAccess and decryptionProvider.
const requestnetwork = new RequestNetwork({ transactionManager: new InMemoryTransactionManager(dataAccess, decryptionProvider) });This will also require updates to the HttpRequestNetwork class which extends the RequestNetwork class. This is because HttpRequestNetwork is exported from the request-client.js package as RequestNetwork.
Related
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
