fix #7552, add next_url from the tip information when accepting tips

This commit is contained in:
Sebastian 2023-02-01 13:00:12 -03:00
parent b45dd3ed4d
commit ab9a5e1e8a
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
7 changed files with 22 additions and 2 deletions

View File

@ -668,6 +668,11 @@ export interface BackupTip {
*/ */
selected_denoms: BackupDenomSel; selected_denoms: BackupDenomSel;
/**
* The url to be redirected after the tip is accepted.
*/
next_url: string | undefined;
/** /**
* UID for the denomination selection. * UID for the denomination selection.
* Used to disambiguate when merging. * Used to disambiguate when merging.

View File

@ -905,6 +905,8 @@ export class TipPickupGetResponse {
exchange_url: string; exchange_url: string;
next_url?: string;
expiration: TalerProtocolTimestamp; expiration: TalerProtocolTimestamp;
} }
@ -1464,6 +1466,7 @@ export const codecForTipPickupGetResponse = (): Codec<TipPickupGetResponse> =>
buildCodecForObject<TipPickupGetResponse>() buildCodecForObject<TipPickupGetResponse>()
.property("tip_amount", codecForString()) .property("tip_amount", codecForString())
.property("exchange_url", codecForString()) .property("exchange_url", codecForString())
.property("next_url", codecOptional(codecForString()))
.property("expiration", codecForTimestamp) .property("expiration", codecForTimestamp)
.build("TipPickupGetResponse"); .build("TipPickupGetResponse");

View File

@ -379,6 +379,7 @@ export interface PrepareTipResult {
export interface AcceptTipResponse { export interface AcceptTipResponse {
transactionId: string; transactionId: string;
next_url?: string;
} }
export const codecForPrepareTipResult = (): Codec<PrepareTipResult> => export const codecForPrepareTipResult = (): Codec<PrepareTipResult> =>

View File

@ -821,6 +821,10 @@ export interface TipRecord {
createdTimestamp: TalerProtocolTimestamp; 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 * Timestamp for when the wallet finished picking up the tip
* from the merchant. * from the merchant.

View File

@ -190,6 +190,7 @@ export async function exportBackup(
merchant_base_url: tip.merchantBaseUrl, merchant_base_url: tip.merchantBaseUrl,
merchant_tip_id: tip.merchantTipId, merchant_tip_id: tip.merchantTipId,
wallet_tip_id: tip.walletTipId, wallet_tip_id: tip.walletTipId,
next_url: tip.next_url,
secret_seed: tip.secretSeed, secret_seed: tip.secretSeed,
selected_denoms: tip.denomsSel.selectedDenoms.map((x) => ({ selected_denoms: tip.denomsSel.selectedDenoms.map((x) => ({
count: x.count, count: x.count,

View File

@ -824,6 +824,7 @@ export async function importBackup(
acceptedTimestamp: backupTip.timestamp_accepted, acceptedTimestamp: backupTip.timestamp_accepted,
createdTimestamp: backupTip.timestamp_created, createdTimestamp: backupTip.timestamp_created,
denomsSel, denomsSel,
next_url: backupTip.next_url,
exchangeBaseUrl: backupTip.exchange_base_url, exchangeBaseUrl: backupTip.exchange_base_url,
merchantBaseUrl: backupTip.exchange_base_url, merchantBaseUrl: backupTip.exchange_base_url,
merchantTipId: backupTip.merchant_tip_id, merchantTipId: backupTip.merchant_tip_id,

View File

@ -130,6 +130,7 @@ export async function prepareTip(
tipAmountRaw: Amounts.stringify(amount), tipAmountRaw: Amounts.stringify(amount),
tipExpiration: tipPickupStatus.expiration, tipExpiration: tipPickupStatus.expiration,
exchangeBaseUrl: tipPickupStatus.exchange_url, exchangeBaseUrl: tipPickupStatus.exchange_url,
next_url: tipPickupStatus.next_url,
merchantBaseUrl: res.merchantBaseUrl, merchantBaseUrl: res.merchantBaseUrl,
createdTimestamp: TalerProtocolTimestamp.now(), createdTimestamp: TalerProtocolTimestamp.now(),
merchantTipId: res.merchantTipId, merchantTipId: res.merchantTipId,
@ -355,17 +356,21 @@ export async function acceptTip(
const tipRecord = await tx.tips.get(tipId); const tipRecord = await tx.tips.get(tipId);
if (!tipRecord) { if (!tipRecord) {
logger.error("tip not found"); logger.error("tip not found");
return false; return undefined;
} }
tipRecord.acceptedTimestamp = TalerProtocolTimestamp.now(); tipRecord.acceptedTimestamp = TalerProtocolTimestamp.now();
await tx.tips.put(tipRecord); await tx.tips.put(tipRecord);
return true; return tipRecord;
}); });
if (found) { if (found) {
await processTip(ws, tipId); 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 { return {
transactionId: makeTransactionId(TransactionType.Tip, tipId), transactionId: makeTransactionId(TransactionType.Tip, tipId),
next_url: found?.next_url,
}; };
} }