Redirect to bank page on reserve creation success

Fixes #4084.
This commit is contained in:
Florian Dold 2016-01-24 03:30:54 +01:00
parent b8627813be
commit 53654b3622
7 changed files with 18 additions and 62 deletions

View File

@ -102,8 +102,6 @@ export interface ConfirmReserveRequest {
export interface ConfirmReserveResponse {
backlink: string;
backlink?: string;
success: boolean;
status: number;
text: string;
}

View File

@ -456,11 +456,16 @@ export class Wallet {
return this.http.postForm(req.post_url, form)
.then((hresp) => {
// TODO: look at response status code and handle errors appropriately
let json = JSON.parse(hresp.responseText);
if (!json) {
return {
success: false
};
}
let resp: ConfirmReserveResponse = {
status: hresp.status,
text: hresp.responseText,
success: undefined,
backlink: undefined
backlink: json.redirect_url,
};
let reserveRecord = {
reserve_pub: reservePub.toCrock(),
@ -488,9 +493,7 @@ export class Wallet {
};
resp.success = true;
// We can't show the page directly, so
// we show some generic page from the wallet.
resp.backlink = null;
return Query(this.db)
.put("reserves", reserveRecord)
.put("history", historyEntry)

View File

@ -55,12 +55,10 @@ System.register(["./wallet", "./db", "./http"], function(exports_1) {
};
wallet.confirmReserve(req)
.then(function (resp) {
if (resp.success) {
resp.backlink = chrome.extension.getURL("pages/reserve-success.html");
}
sendResponse(resp);
})
.catch(function (e) {
sendResponse({ success: false });
console.error("exception during 'confirm-reserve'");
console.error(e.stack);
});

View File

@ -72,13 +72,10 @@ function makeHandlers(wallet) {
};
wallet.confirmReserve(req)
.then((resp) => {
if (resp.success) {
resp.backlink = chrome.extension.getURL(
"pages/reserve-success.html");
}
sendResponse(resp);
})
.catch((e) => {
sendResponse({success: false});
console.error("exception during 'confirm-reserve'");
console.error(e.stack);
});

View File

@ -28,14 +28,10 @@ var ConfirmCreateReserve;
}
showAmount.textContent = s;
}
function clone(obj) {
// This is faster than it looks ...
return JSON.parse(JSON.stringify(obj));
}
document.addEventListener("DOMContentLoaded", function (e) {
updateAmount();
document.getElementById("confirm").addEventListener("click", function (e) {
var d = clone(query);
var d = Object.assign({}, query);
d.mint = document.getElementById('mint-url').value;
chrome.runtime.sendMessage({ type: 'confirm-reserve', detail: d }, function (resp) {
if (resp.success === true) {
@ -43,7 +39,7 @@ var ConfirmCreateReserve;
}
else {
document.body.innerHTML =
"\n Oops, something went wrong.\n The bank responded with HTTP status code " + resp.status + ".\n Here is some more info:\n <pre>" + resp.text + "</pre>\n </div>";
"Oops, something went wrong. It looks like the bank could not\n transfer funds to the mint. Please go back to your bank's website\n to check what happened.";
}
});
});

View File

@ -32,16 +32,12 @@ namespace ConfirmCreateReserve {
showAmount.textContent = s;
}
function clone(obj) {
// This is faster than it looks ...
return JSON.parse(JSON.stringify(obj));
}
document.addEventListener("DOMContentLoaded", (e) => {
updateAmount();
document.getElementById("confirm").addEventListener("click", (e) => {
let d = clone(query);
let d = Object.assign({}, query);
d.mint = (document.getElementById('mint-url') as HTMLInputElement).value;
chrome.runtime.sendMessage({type:'confirm-reserve', detail: d},
(resp) => {
@ -49,12 +45,9 @@ namespace ConfirmCreateReserve {
document.location.href = resp.backlink;
} else {
document.body.innerHTML =
`
Oops, something went wrong.
The bank responded with HTTP status code ${resp.status}.
Here is some more info:
<pre>${resp.text}</pre>
</div>`;
`Oops, something went wrong. It looks like the bank could not
transfer funds to the mint. Please go back to your bank's website
to check what happened.`;
}
});

View File

@ -1,29 +0,0 @@
<!doctype html>
<html>
<head>
<title>Taler Wallet: Withdraw operation initiated</title>
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
</head>
<body>
<header>
<div id="logo"></div>
<h1>Withdraw operation initiated</h1>
</header>
<aside class="sidebar" id="left">
</aside>
<section id="main">
<article>
<h1>Success!</h1>
<p>We have started the process of withdrawing electronic coins. This process may take a bit, but will happen in the background. So you can now continue to browse.</p>
<p>You can click on the Taler logo in your navigation bar to check on the progress of the withdrawal operation and your current balance.</p>
</article>
</section>
</body>
</html>