From c87a0d55145f140b1f104437ecdd1a1ca1040186 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 11 Dec 2017 17:46:06 +0100 Subject: show next url to go after tipping --- src/types.ts | 11 +++++++++++ src/wallet.ts | 5 +++-- src/webex/notify.ts | 2 +- src/webex/pages/tip.tsx | 2 +- src/webex/wxApi.ts | 4 ++-- src/webex/wxBackend.ts | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/types.ts b/src/types.ts index ec4929c33..69ed64446 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1943,6 +1943,11 @@ export interface TipRecord { * Identifier for the tip, chosen by the merchant. */ tipId: string; + + /** + * URL to go to once the tip has been accepted. + */ + nextUrl: string; } @@ -2007,6 +2012,9 @@ export class GetTipPlanchetsRequest { @Checkable.String exchangeUrl: string; + @Checkable.String + nextUrl: string; + static checked: (obj: any) => GetTipPlanchetsRequest; } @@ -2027,5 +2035,8 @@ export class TipToken { @Checkable.Value(AmountJson) amount: AmountJson; + @Checkable.String + next_url: string; + static checked: (obj: any) => TipToken; } diff --git a/src/wallet.ts b/src/wallet.ts index 1966db768..a597fd5bc 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -329,7 +329,7 @@ export const WALLET_PROTOCOL_VERSION = "2:0:0"; * In the future we might consider adding migration functions for * each version increment. */ -export const WALLET_DB_VERSION = 21; +export const WALLET_DB_VERSION = 22; const builtinCurrencies: CurrencyRecord[] = [ { @@ -2862,7 +2862,7 @@ export class Wallet { * Get planchets for a tip. Creates new planchets if they don't exist already * for this tip. The tip is uniquely identified by the merchant's domain and the tip id. */ - async getTipPlanchets(merchantDomain: string, tipId: string, amount: AmountJson, deadline: number, exchangeUrl: string): Promise { + async getTipPlanchets(merchantDomain: string, tipId: string, amount: AmountJson, deadline: number, exchangeUrl: string, nextUrl: string): Promise { let tipRecord = await this.q().get(Stores.tips, [tipId, merchantDomain]); if (!tipRecord) { await this.updateExchangeFromUrl(exchangeUrl); @@ -2876,6 +2876,7 @@ export class Wallet { deadline, exchangeUrl, merchantDomain, + nextUrl, planchets, tipId, }; diff --git a/src/webex/notify.ts b/src/webex/notify.ts index 1da8af1cd..05883e8bb 100644 --- a/src/webex/notify.ts +++ b/src/webex/notify.ts @@ -272,7 +272,7 @@ function talerPay(msg: any): Promise { const merchantDomain = new URI(document.location.href).origin(); let walletResp; try { - walletResp = await wxApi.getTipPlanchets(merchantDomain, tipToken.tip_id, tipToken.amount, deadlineSec, tipToken.exchange_url); + walletResp = await wxApi.getTipPlanchets(merchantDomain, tipToken.tip_id, tipToken.amount, deadlineSec, tipToken.exchange_url, tipToken.next_url); } catch (e) { wxApi.logAndDisplayError({ message: e.message, diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx index 7f3a7c1fe..678c0dfdd 100644 --- a/src/webex/pages/tip.tsx +++ b/src/webex/pages/tip.tsx @@ -121,7 +121,7 @@ class TipDisplay extends React.Component {

Tip Received!

You received a tip of {renderAmount(ts.tip.amount)} from {this.props.merchantDomain}.

{ts.tip.accepted - ?

You've accepted this tip!

+ ?

You've accepted this tip! Go back to merchant

: this.renderButtons() } {this.renderExchangeInfo(ts)} diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts index e362fc34a..61a45c024 100644 --- a/src/webex/wxApi.ts +++ b/src/webex/wxApi.ts @@ -366,8 +366,8 @@ export function getFullRefundFees(args: { refundPermissions: RefundPermission[] /** * Get or generate planchets to give the merchant that wants to tip us. */ -export function getTipPlanchets(merchantDomain: string, tipId: string, amount: AmountJson, deadline: number, exchangeUrl: string): Promise { - return callBackend("get-tip-planchets", { merchantDomain, tipId, amount, deadline, exchangeUrl }); +export function getTipPlanchets(merchantDomain: string, tipId: string, amount: AmountJson, deadline: number, exchangeUrl: string, nextUrl: string): Promise { + return callBackend("get-tip-planchets", { merchantDomain, tipId, amount, deadline, exchangeUrl, nextUrl }); } export function getTipStatus(merchantDomain: string, tipId: string): Promise { diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts index fd5df7e47..a7757c68e 100644 --- a/src/webex/wxBackend.ts +++ b/src/webex/wxBackend.ts @@ -335,7 +335,7 @@ function handleMessage(sender: MessageSender, } case "get-tip-planchets": { const req = GetTipPlanchetsRequest.checked(detail); - return needsWallet().getTipPlanchets(req.merchantDomain, req.tipId, req.amount, req.deadline, req.exchangeUrl); + return needsWallet().getTipPlanchets(req.merchantDomain, req.tipId, req.amount, req.deadline, req.exchangeUrl, req.nextUrl); } default: // Exhaustiveness check. -- cgit v1.2.3