diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-20 01:25:22 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-20 01:25:22 +0100 |
commit | 378d8dee5825c67f9387542661ea6b34c30adbea (patch) | |
tree | 24824f90b61cd52d94cff98a727bea25091f94a5 /src/operations | |
parent | aa37ef082d0e4aaedeb219d0a3f726da146edba7 (diff) | |
download | wallet-core-378d8dee5825c67f9387542661ea6b34c30adbea.tar.xz |
implement refusing proposals
Diffstat (limited to 'src/operations')
-rw-r--r-- | src/operations/history.ts | 2 | ||||
-rw-r--r-- | src/operations/pay.ts | 23 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/operations/history.ts b/src/operations/history.ts index f02894b6b..00727918a 100644 --- a/src/operations/history.ts +++ b/src/operations/history.ts @@ -91,7 +91,7 @@ async function collectProposalHistory( case ProposalStatus.PROPOSED: // no history event needed break; - case ProposalStatus.REJECTED: + case ProposalStatus.REFUSED: { const shortInfo = getOrderShortInfo(proposal); if (!shortInfo) { diff --git a/src/operations/pay.ts b/src/operations/pay.ts index db2a24310..c7920020e 100644 --- a/src/operations/pay.ts +++ b/src/operations/pay.ts @@ -808,7 +808,7 @@ export async function submitPay( * If the payment is possible, the signature are already generated but not * yet send to the merchant. */ -export async function preparePay( +export async function preparePayForUri( ws: InternalWalletState, talerPayUri: string, ): Promise<PreparePayResult> { @@ -1018,3 +1018,24 @@ async function processPurchasePayImpl( logger.trace(`processing purchase pay ${proposalId}`); await submitPay(ws, proposalId); } + +export async function refuseProposal(ws: InternalWalletState, proposalId: string) { + const success = await ws.db.runWithWriteTransaction([Stores.proposals], async (tx) => { + const proposal = await tx.get(Stores.proposals, proposalId); + if (!proposal) { + logger.trace(`proposal ${proposalId} not found, won't refuse proposal`); + return false ; + } + if (proposal.proposalStatus !== ProposalStatus.PROPOSED) { + return false; + } + proposal.proposalStatus = ProposalStatus.REFUSED; + await tx.put(Stores.proposals, proposal); + return true; + }); + if (success) { + ws.notify({ + type: NotificationType.Wildcard, + }); + } +}
\ No newline at end of file |