show next url to go after tipping
This commit is contained in:
parent
2f441cd1b9
commit
c87a0d5514
11
src/types.ts
11
src/types.ts
@ -1943,6 +1943,11 @@ export interface TipRecord {
|
|||||||
* Identifier for the tip, chosen by the merchant.
|
* Identifier for the tip, chosen by the merchant.
|
||||||
*/
|
*/
|
||||||
tipId: string;
|
tipId: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL to go to once the tip has been accepted.
|
||||||
|
*/
|
||||||
|
nextUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2007,6 +2012,9 @@ export class GetTipPlanchetsRequest {
|
|||||||
@Checkable.String
|
@Checkable.String
|
||||||
exchangeUrl: string;
|
exchangeUrl: string;
|
||||||
|
|
||||||
|
@Checkable.String
|
||||||
|
nextUrl: string;
|
||||||
|
|
||||||
static checked: (obj: any) => GetTipPlanchetsRequest;
|
static checked: (obj: any) => GetTipPlanchetsRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2027,5 +2035,8 @@ export class TipToken {
|
|||||||
@Checkable.Value(AmountJson)
|
@Checkable.Value(AmountJson)
|
||||||
amount: AmountJson;
|
amount: AmountJson;
|
||||||
|
|
||||||
|
@Checkable.String
|
||||||
|
next_url: string;
|
||||||
|
|
||||||
static checked: (obj: any) => TipToken;
|
static checked: (obj: any) => TipToken;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ export const WALLET_PROTOCOL_VERSION = "2:0:0";
|
|||||||
* In the future we might consider adding migration functions for
|
* In the future we might consider adding migration functions for
|
||||||
* each version increment.
|
* each version increment.
|
||||||
*/
|
*/
|
||||||
export const WALLET_DB_VERSION = 21;
|
export const WALLET_DB_VERSION = 22;
|
||||||
|
|
||||||
const builtinCurrencies: CurrencyRecord[] = [
|
const builtinCurrencies: CurrencyRecord[] = [
|
||||||
{
|
{
|
||||||
@ -2862,7 +2862,7 @@ export class Wallet {
|
|||||||
* Get planchets for a tip. Creates new planchets if they don't exist already
|
* 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.
|
* 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<TipPlanchetDetail[]> {
|
async getTipPlanchets(merchantDomain: string, tipId: string, amount: AmountJson, deadline: number, exchangeUrl: string, nextUrl: string): Promise<TipPlanchetDetail[]> {
|
||||||
let tipRecord = await this.q().get(Stores.tips, [tipId, merchantDomain]);
|
let tipRecord = await this.q().get(Stores.tips, [tipId, merchantDomain]);
|
||||||
if (!tipRecord) {
|
if (!tipRecord) {
|
||||||
await this.updateExchangeFromUrl(exchangeUrl);
|
await this.updateExchangeFromUrl(exchangeUrl);
|
||||||
@ -2876,6 +2876,7 @@ export class Wallet {
|
|||||||
deadline,
|
deadline,
|
||||||
exchangeUrl,
|
exchangeUrl,
|
||||||
merchantDomain,
|
merchantDomain,
|
||||||
|
nextUrl,
|
||||||
planchets,
|
planchets,
|
||||||
tipId,
|
tipId,
|
||||||
};
|
};
|
||||||
|
@ -272,7 +272,7 @@ function talerPay(msg: any): Promise<any> {
|
|||||||
const merchantDomain = new URI(document.location.href).origin();
|
const merchantDomain = new URI(document.location.href).origin();
|
||||||
let walletResp;
|
let walletResp;
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
wxApi.logAndDisplayError({
|
wxApi.logAndDisplayError({
|
||||||
message: e.message,
|
message: e.message,
|
||||||
|
@ -121,7 +121,7 @@ class TipDisplay extends React.Component<TipDisplayProps, TipDisplayState> {
|
|||||||
<h2>Tip Received!</h2>
|
<h2>Tip Received!</h2>
|
||||||
<p>You received a tip of <strong>{renderAmount(ts.tip.amount)}</strong> from <strong>{this.props.merchantDomain}</strong>.</p>
|
<p>You received a tip of <strong>{renderAmount(ts.tip.amount)}</strong> from <strong>{this.props.merchantDomain}</strong>.</p>
|
||||||
{ts.tip.accepted
|
{ts.tip.accepted
|
||||||
? <p>You've accepted this tip!</p>
|
? <p>You've accepted this tip! <a href={ts.tip.nextUrl}>Go back to merchant</a></p>
|
||||||
: this.renderButtons()
|
: this.renderButtons()
|
||||||
}
|
}
|
||||||
{this.renderExchangeInfo(ts)}
|
{this.renderExchangeInfo(ts)}
|
||||||
|
@ -366,8 +366,8 @@ export function getFullRefundFees(args: { refundPermissions: RefundPermission[]
|
|||||||
/**
|
/**
|
||||||
* Get or generate planchets to give the merchant that wants to tip us.
|
* 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<TipPlanchetDetail[]> {
|
export function getTipPlanchets(merchantDomain: string, tipId: string, amount: AmountJson, deadline: number, exchangeUrl: string, nextUrl: string): Promise<TipPlanchetDetail[]> {
|
||||||
return callBackend("get-tip-planchets", { merchantDomain, tipId, amount, deadline, exchangeUrl });
|
return callBackend("get-tip-planchets", { merchantDomain, tipId, amount, deadline, exchangeUrl, nextUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTipStatus(merchantDomain: string, tipId: string): Promise<TipStatus> {
|
export function getTipStatus(merchantDomain: string, tipId: string): Promise<TipStatus> {
|
||||||
|
@ -335,7 +335,7 @@ function handleMessage(sender: MessageSender,
|
|||||||
}
|
}
|
||||||
case "get-tip-planchets": {
|
case "get-tip-planchets": {
|
||||||
const req = GetTipPlanchetsRequest.checked(detail);
|
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:
|
default:
|
||||||
// Exhaustiveness check.
|
// Exhaustiveness check.
|
||||||
|
Loading…
Reference in New Issue
Block a user