aboutsummaryrefslogtreecommitdiff
path: root/src/headless/taler-wallet-cli.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/headless/taler-wallet-cli.ts')
-rw-r--r--src/headless/taler-wallet-cli.ts57
1 files changed, 50 insertions, 7 deletions
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index 4a1f5d91e..65b2a0297 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -103,15 +103,14 @@ program
console.log("created new order with order ID", orderResp.orderId);
const checkPayResp = await merchantBackend.checkPayment(orderResp.orderId);
const qrcode = qrcodeGenerator(0, "M");
- const contractUrl = checkPayResp.contract_url;
- if (typeof contractUrl !== "string") {
- console.error("fata: no contract url received from backend");
+ const talerPayUri = checkPayResp.taler_pay_uri;
+ if (!talerPayUri) {
+ console.error("fatal: no taler pay URI received from backend");
process.exit(1);
return;
}
- const url = "talerpay:" + querystring.escape(contractUrl);
- console.log("contract url:", url);
- qrcode.addData(url);
+ console.log("taler pay URI:", talerPayUri);
+ qrcode.addData(talerPayUri);
qrcode.make();
console.log(qrcode.createASCII());
console.log("waiting for payment ...");
@@ -128,6 +127,45 @@ program
});
program
+ .command("withdraw-url <withdraw-url>")
+ .action(async (withdrawUrl, cmdObj) => {
+ applyVerbose(program.verbose);
+ console.log("withdrawing", withdrawUrl);
+ const wallet = await getDefaultNodeWallet({
+ persistentStoragePath: walletDbPath,
+ });
+
+ const withdrawInfo = await wallet.downloadWithdrawInfo(withdrawUrl);
+
+ console.log("withdraw info", withdrawInfo);
+
+ const selectedExchange = withdrawInfo.suggestedExchange;
+ if (!selectedExchange) {
+ console.error("no suggested exchange!");
+ process.exit(1);
+ return;
+ }
+
+ const {
+ reservePub,
+ confirmTransferUrl,
+ } = await wallet.createReserveFromWithdrawUrl(
+ withdrawUrl,
+ selectedExchange,
+ );
+
+ if (confirmTransferUrl) {
+ console.log("please confirm the transfer at", confirmTransferUrl);
+ }
+
+ await wallet.processReserve(reservePub);
+
+ console.log("finished withdrawing");
+
+ wallet.stop();
+ });
+
+program
.command("pay-url <pay-url>")
.option("-y, --yes", "automatically answer yes to prompts")
.action(async (payUrl, cmdObj) => {
@@ -153,6 +191,11 @@ program
process.exit(0);
return;
}
+ if (result.status === "session-replayed") {
+ console.log("already paid! (replayed in different session)");
+ process.exit(0);
+ return;
+ }
if (result.status === "payment-possible") {
console.log("paying ...");
} else {
@@ -179,7 +222,7 @@ program
if (pay) {
const payRes = await wallet.confirmPay(result.proposalId!, undefined);
- console.log("paid!");
+ console.log("paid!");
} else {
console.log("not paying");
}