summaryrefslogtreecommitdiff
path: root/src/operations/pay.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-20 01:25:22 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-20 01:25:22 +0100
commit378d8dee5825c67f9387542661ea6b34c30adbea (patch)
tree24824f90b61cd52d94cff98a727bea25091f94a5 /src/operations/pay.ts
parentaa37ef082d0e4aaedeb219d0a3f726da146edba7 (diff)
downloadwallet-core-378d8dee5825c67f9387542661ea6b34c30adbea.tar.gz
wallet-core-378d8dee5825c67f9387542661ea6b34c30adbea.tar.bz2
wallet-core-378d8dee5825c67f9387542661ea6b34c30adbea.zip
implement refusing proposals
Diffstat (limited to 'src/operations/pay.ts')
-rw-r--r--src/operations/pay.ts23
1 files changed, 22 insertions, 1 deletions
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