aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-02-01 13:00:12 -0300
committerSebastian <sebasjm@gmail.com>2023-02-01 13:00:12 -0300
commitab9a5e1e8ac60bbf55104e84490e581dfad5de02 (patch)
treeac00b38838ee0ca3b600dc505957632b019bf1bb /packages
parentb45dd3ed4d5a43e3622b381e3a2acb16497e9864 (diff)
fix #7552, add next_url from the tip information when accepting tips
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-util/src/backup-types.ts5
-rw-r--r--packages/taler-util/src/taler-types.ts3
-rw-r--r--packages/taler-util/src/wallet-types.ts1
-rw-r--r--packages/taler-wallet-core/src/db.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/backup/export.ts1
-rw-r--r--packages/taler-wallet-core/src/operations/backup/import.ts1
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts9
7 files changed, 22 insertions, 2 deletions
diff --git a/packages/taler-util/src/backup-types.ts b/packages/taler-util/src/backup-types.ts
index b3c6b5515..0a355b65f 100644
--- a/packages/taler-util/src/backup-types.ts
+++ b/packages/taler-util/src/backup-types.ts
@@ -669,6 +669,11 @@ export interface BackupTip {
selected_denoms: BackupDenomSel;
/**
+ * The url to be redirected after the tip is accepted.
+ */
+ next_url: string | undefined;
+
+ /**
* UID for the denomination selection.
* Used to disambiguate when merging.
*/
diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts
index 8b680bdd9..a9303ed9c 100644
--- a/packages/taler-util/src/taler-types.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -905,6 +905,8 @@ export class TipPickupGetResponse {
exchange_url: string;
+ next_url?: string;
+
expiration: TalerProtocolTimestamp;
}
@@ -1464,6 +1466,7 @@ export const codecForTipPickupGetResponse = (): Codec<TipPickupGetResponse> =>
buildCodecForObject<TipPickupGetResponse>()
.property("tip_amount", codecForString())
.property("exchange_url", codecForString())
+ .property("next_url", codecOptional(codecForString()))
.property("expiration", codecForTimestamp)
.build("TipPickupGetResponse");
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index b7a51de9e..d57a221f3 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -379,6 +379,7 @@ export interface PrepareTipResult {
export interface AcceptTipResponse {
transactionId: string;
+ next_url?: string;
}
export const codecForPrepareTipResult = (): Codec<PrepareTipResult> =>
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 6a42cabcb..78c73fba5 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -822,6 +822,10 @@ export interface TipRecord {
createdTimestamp: TalerProtocolTimestamp;
/**
+ * The url to be redirected after the tip is accepted.
+ */
+ next_url: string | undefined;
+ /**
* Timestamp for when the wallet finished picking up the tip
* from the merchant.
*/
diff --git a/packages/taler-wallet-core/src/operations/backup/export.ts b/packages/taler-wallet-core/src/operations/backup/export.ts
index a66444485..3dd4e0e32 100644
--- a/packages/taler-wallet-core/src/operations/backup/export.ts
+++ b/packages/taler-wallet-core/src/operations/backup/export.ts
@@ -190,6 +190,7 @@ export async function exportBackup(
merchant_base_url: tip.merchantBaseUrl,
merchant_tip_id: tip.merchantTipId,
wallet_tip_id: tip.walletTipId,
+ next_url: tip.next_url,
secret_seed: tip.secretSeed,
selected_denoms: tip.denomsSel.selectedDenoms.map((x) => ({
count: x.count,
diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts
index c94eb7eb6..c1be1d4d9 100644
--- a/packages/taler-wallet-core/src/operations/backup/import.ts
+++ b/packages/taler-wallet-core/src/operations/backup/import.ts
@@ -824,6 +824,7 @@ export async function importBackup(
acceptedTimestamp: backupTip.timestamp_accepted,
createdTimestamp: backupTip.timestamp_created,
denomsSel,
+ next_url: backupTip.next_url,
exchangeBaseUrl: backupTip.exchange_base_url,
merchantBaseUrl: backupTip.exchange_base_url,
merchantTipId: backupTip.merchant_tip_id,
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index dabde9f62..2bf216102 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -130,6 +130,7 @@ export async function prepareTip(
tipAmountRaw: Amounts.stringify(amount),
tipExpiration: tipPickupStatus.expiration,
exchangeBaseUrl: tipPickupStatus.exchange_url,
+ next_url: tipPickupStatus.next_url,
merchantBaseUrl: res.merchantBaseUrl,
createdTimestamp: TalerProtocolTimestamp.now(),
merchantTipId: res.merchantTipId,
@@ -355,17 +356,21 @@ export async function acceptTip(
const tipRecord = await tx.tips.get(tipId);
if (!tipRecord) {
logger.error("tip not found");
- return false;
+ return undefined;
}
tipRecord.acceptedTimestamp = TalerProtocolTimestamp.now();
await tx.tips.put(tipRecord);
- return true;
+ return tipRecord;
});
+
if (found) {
await processTip(ws, tipId);
}
+ //FIXME: if tip is not found the behavior of the function is the same
+ // as the tip was found and finished
return {
transactionId: makeTransactionId(TransactionType.Tip, tipId),
+ next_url: found?.next_url,
};
}