aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/android/index.ts9
-rw-r--r--src/headless/integrationtest.ts3
-rw-r--r--src/headless/taler-wallet-cli.ts4
-rw-r--r--src/operations/history.ts2
-rw-r--r--src/operations/pay.ts23
-rw-r--r--src/types/dbTypes.ts2
-rw-r--r--src/wallet.ts11
-rw-r--r--src/webex/wxBackend.ts2
8 files changed, 44 insertions, 12 deletions
diff --git a/src/android/index.ts b/src/android/index.ts
index a62299936..20d83d71a 100644
--- a/src/android/index.ts
+++ b/src/android/index.ts
@@ -154,6 +154,13 @@ class AndroidWalletMessageHandler {
this.wp.resolve(w);
return {};
}
+ case "abortProposal": {
+ const wallet = await this.wp.promise;
+ if (typeof args.proposalId !== "string") {
+ throw Error("propsalId must be a string");
+ }
+ return await wallet.refuseProposal(args.proposalId);
+ }
case "getBalances": {
const wallet = await this.wp.promise;
return await wallet.getBalances();
@@ -182,7 +189,7 @@ class AndroidWalletMessageHandler {
}
case "preparePay": {
const wallet = await this.wp.promise;
- return await wallet.preparePay(args.url);
+ return await wallet.preparePayForUri(args.url);
break;
}
case "confirmPay": {
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index 494f7c024..05aa760b0 100644
--- a/src/headless/integrationtest.ts
+++ b/src/headless/integrationtest.ts
@@ -40,7 +40,6 @@ export async function runIntegrationTest(args: {
const myWallet = await getDefaultNodeWallet({ httpLib: myHttpLib });
-
myWallet.runRetryLoop().catch((e) => {
console.error("exception during retry loop:", e);
});
@@ -75,7 +74,7 @@ export async function runIntegrationTest(args: {
throw Error("no taler://pay/ URI in payment response");
}
- const preparePayResult = await myWallet.preparePay(talerPayUri);
+ const preparePayResult = await myWallet.preparePayForUri(talerPayUri);
console.log("prepare pay result", preparePayResult);
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index 12f729be4..491f6f556 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -43,7 +43,7 @@ async function doPay(
payUrl: string,
options: { alwaysYes: boolean } = { alwaysYes: true },
) {
- const result = await wallet.preparePay(payUrl);
+ const result = await wallet.preparePayForUri(payUrl);
if (result.status === "error") {
console.error("Could not pay:", result.error);
process.exit(1);
@@ -317,7 +317,7 @@ advancedCli
.requiredArgument("url", clk.STRING)
.action(async args => {
await withWallet(args, async wallet => {
- const res = await wallet.preparePay(args.payPrepare.url);
+ const res = await wallet.preparePayForUri(args.payPrepare.url);
switch (res.status) {
case "error":
console.log("error:", res.error);
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
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index 55559ab57..71fe99b6b 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -689,7 +689,7 @@ export const enum ProposalStatus {
/**
* The user has rejected the proposal.
*/
- REJECTED = "rejected",
+ REFUSED = "refused",
/**
* Downloaded proposal was detected as a re-purchase.
*/
diff --git a/src/wallet.ts b/src/wallet.ts
index b08122b66..015a44ccc 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -36,7 +36,8 @@ import {
import {
abortFailedPayment,
- preparePay,
+ preparePayForUri,
+ refuseProposal,
confirmPay,
processDownloadProposal,
processPurchasePay,
@@ -355,8 +356,8 @@ export class Wallet {
* If the payment is possible, the signature are already generated but not
* yet send to the merchant.
*/
- async preparePay(talerPayUri: string): Promise<PreparePayResult> {
- return preparePay(this.ws, talerPayUri);
+ async preparePayForUri(talerPayUri: string): Promise<PreparePayResult> {
+ return preparePayForUri(this.ws, talerPayUri);
}
/**
@@ -681,6 +682,10 @@ export class Wallet {
}
}
+ async refuseProposal(proposalId: string): Promise<void> {
+ return refuseProposal(this.ws, proposalId);
+ }
+
async getPurchaseDetails(hc: string): Promise<PurchaseDetails> {
const purchase = await this.db.get(Stores.purchases, hc);
if (!purchase) {
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index ae12f9f91..053b82964 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -273,7 +273,7 @@ async function handleMessage(
return diagnostics;
}
case "prepare-pay":
- return needsWallet().preparePay(detail.talerPayUri);
+ return needsWallet().preparePayForUri(detail.talerPayUri);
default:
// Exhaustiveness check.
// See https://www.typescriptlang.org/docs/handbook/advanced-types.html