feat: open payto links on the pay form, and take the checkout over D-Bus out
An app could have nostrod pay an order: it called Pay of net.catcrafts.Nostro1.Checkout on the system bus, and nostrod paid from an account the user had chosen, after a dialog of its own. On 2026-11-22 the owner decided that a link takes its place. The app registers for payto links (RFC 8905), so that an app or a website can hand one to the desktop, and shows a link as its pay form filled in. The link: - The app's desktop entry takes the scheme (Exec=nostro-app %u, MimeType=x-scheme-handler/payto), and nostro-app takes an argument that is no option as a link: it overwrites it in argv and hands it to App::Open once the app has started. - ReadPaymentLink (Nostro.App:Forms) reads payto://iban/<IBAN> with the options amount, receiver-name and message, and refuses a link rather than guess at it, in a sentence of the app's own with nothing of the link in it. Among what it refuses: an IBAN whose check digits do not hold, one of the three options given twice, instruction, a comma in the amount, and a name or a message with a code point that is Unshown, or Blank and no plain space. - A link that is read waits until the accounts are read and DefaultCheckoutAccount has answered or failed, with a line on the accounts' page. Then App::TakeLink fills in the pay form, which says in a banner that a link filled it in, and with more than one account opens it under the choice of accounts that the form's From row has. A link pays nothing: the form's button sends, and polkit's dialog confirms as for any payment (design rule 12, and 14, which is new). - Unshown and Blank are the two tables the worker's Shown() works from. They move into Nostro:Utils, where the app's reader asks them too. The move is within the library. The reader holds a link's name to those two and to no more of Shown(): a name with an & is read, and the dialog shows it with a + as it does any name. The checkout: - nostrod serves one interface under one bus name. Gone are net.catcrafts.Nostro1.Checkout with its XML and its activation file, the polkit action Checkout, the module Nostro.Checkout with --product=checkout, and the worker's record of orders. That changes the published contract after a release, 0.0.0, and design rule 10 records it as the owner's decision. - DefaultCheckoutAccount and SetDefaultCheckoutAccount keep their names and signatures. The account they keep is where a link's pay form starts: nostrod's dialog for choosing it says "have pay links start from", the app's setting reads "Pay links start from", and `nostro checkout account` prints "pay links start from". - The D-Bus policy still lets nostrod own the old name: the nostrod of 0.0.0 asks for it when it starts, and the system files can be newer than the Flatpak it runs from. install.sh removes the old name's activation file. A user's checkouts.cdb is read by nothing any more, and is left where it is. - The Arch package stops installing the checkout's two files, and its pkgrel goes up to 2. Where makepkg -si finds a package of the version already built it installs that one again, which would bring the activation file back. The guide now says that pkgrel goes up with a change to what the package installs. - Bus::Interface goes too: the worker called it in two places, to tell a call to the checkout from one to the main interface. The review's own files follow. gate0 loses the build of --product=checkout, and the three lens sections that named the checkout no longer do, and ask about a link. The README has "Pay links" in place of "Checkout for apps", and AGENTS.consumer.md says what the app reads of a link. Its line on lib/json.hpp no longer gives a release: the file is of none, and the guide names its commit. The pay form and the accounts' page change only by a banner each, shown while a link is in play, which docs/screenshots/take.sh never has: the README's pictures stand. Tests: ShouldValidateForms reads and refuses links and fills the form from one. ShouldDriveTheApp opens links against a real nostrod on the fake bus: before the accounts are known, with no account, with one and with several, with the accounts known and the system bus gone, for a second user whose first connection pays their own accounts only, one that cannot be read, one whose name has an &, and through polkit's dialog to the payment. It now counts nostrod's answers to hold that the account pay links start from is read again once a connection is removed: the check it had there passed without that. ShouldHandleMoneyAndText holds the two tables at the ends of their ranges. ShouldServeEveryUser holds that nostrod serves no checkout, that the bus's policy lets an older nostrod own the old name, and the account pay links start from. ShouldRunCommands holds the CLI's wording. The review's gate0 passes at this commit: the version check, 17 tests, the builds of the CLI, the library, nostrod, the fake system, the app and its --debug-api build, and five lint runs that report nothing. tests/coverage.sh reports lines, functions and regions at 100.00%. Looked at on 2026-11-22 on the made-up system (run fake), on a desktop (KWin at a scale of 1.85). At 420x760, at --scale 3 --size 360x760 and at 1100x720 in the light look: a link's pay form under the choice of accounts, the form after a tap beside that choice, and the accounts' page while a link waits, its line above the rows that stand in for the accounts (--bank-delay 10000). At 420x760: that line above what the page says when the accounts cannot be read (--polkit deny) and above the accounts themselves (--polkit slow, the link opened in the running app), the settings' row and page for the account pay links start from, the sheet for a link that cannot be read, and with --empty the sheet for no account.
This commit is contained in:
parent
25d991658f
commit
b43ab124a6
42 changed files with 1234 additions and 994 deletions
|
|
@ -11,7 +11,6 @@ export module Nostro:Bus;
|
|||
#ifdef NOSTRO_DBUS_ENABLED
|
||||
|
||||
import std;
|
||||
import Nostro.Checkout;
|
||||
import :Account;
|
||||
import :Bunq;
|
||||
import :Currency;
|
||||
|
|
@ -64,14 +63,12 @@ export namespace Nostro::Bus {
|
|||
inline constexpr std::string_view objectPath = "/net/catcrafts/Nostro1";
|
||||
inline constexpr std::string_view interfaceName = "net.catcrafts.Nostro1";
|
||||
|
||||
// What nostrod answers with besides the standard AccessDenied and InteractiveAuthorizationRequired. The ones an app
|
||||
// at checkout tells apart too are Nostro.Checkout's.
|
||||
inline constexpr std::string_view errorInvalidArgument = Checkout::errorInvalidArgument; // refused before anything was sent
|
||||
inline constexpr std::string_view errorBank = Checkout::errorBank; // the bank answered with an error
|
||||
inline constexpr std::string_view errorOAuthCannotPay = "net.catcrafts.Nostro1.Error.OAuthCannotPay"; // bunq refused to pay through an OAuth connector
|
||||
inline constexpr std::string_view errorCancelled = Checkout::errorCancelled; // the user did not authenticate at the prompt
|
||||
inline constexpr std::string_view errorNoCheckoutAccount = Checkout::errorNoCheckoutAccount; // a checkout, and no account chosen to pay it
|
||||
inline constexpr std::string_view errorFailed = Checkout::errorFailed; // anything else
|
||||
// What nostrod answers with besides the standard AccessDenied and InteractiveAuthorizationRequired.
|
||||
inline constexpr std::string_view errorInvalidArgument = "net.catcrafts.Nostro1.Error.InvalidArgument"; // refused before anything was sent
|
||||
inline constexpr std::string_view errorBank = "net.catcrafts.Nostro1.Error.Bank"; // the bank answered with an error
|
||||
inline constexpr std::string_view errorOAuthCannotPay = "net.catcrafts.Nostro1.Error.OAuthCannotPay"; // bunq refused to pay through an OAuth connector
|
||||
inline constexpr std::string_view errorCancelled = "net.catcrafts.Nostro1.Error.Cancelled"; // the user did not authenticate at the prompt
|
||||
inline constexpr std::string_view errorFailed = "net.catcrafts.Nostro1.Error.Failed"; // anything else
|
||||
|
||||
// The polkit actions, declared in packaging/system/net.catcrafts.Nostro1.policy.
|
||||
inline constexpr std::string_view actionView = "net.catcrafts.Nostro1.View";
|
||||
|
|
@ -80,7 +77,6 @@ export namespace Nostro::Bus {
|
|||
inline constexpr std::string_view actionUnfreezeCard = "net.catcrafts.Nostro1.UnfreezeCard";
|
||||
inline constexpr std::string_view actionBlockCard = "net.catcrafts.Nostro1.BlockCard";
|
||||
inline constexpr std::string_view actionConnectors = "net.catcrafts.Nostro1.Connectors";
|
||||
inline constexpr std::string_view actionCheckout = "net.catcrafts.Nostro1.Checkout";
|
||||
}
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
|
|
@ -121,18 +117,11 @@ namespace Nostro::Bus {
|
|||
Method{"SetDefaultCheckoutAccount", "s", "(ssssx)as", "account\0chosen\0notes\0"sv},
|
||||
};
|
||||
|
||||
// net.catcrafts.Nostro1.Checkout, which nostrod serves under a bus name of its own (Checkout::busName). Its reply
|
||||
// carries no notes: they are the user's, and the app that asks is someone else.
|
||||
inline constexpr std::array checkoutMethods = {
|
||||
Method{"Pay", Checkout::payArguments, Checkout::payReply, Checkout::payNames},
|
||||
};
|
||||
|
||||
// Throws a std::system_error naming `what` when an sd-bus call returned a negative errno; returns the result.
|
||||
std::int32_t ThrowOnSdBus(std::int32_t result, std::string_view what);
|
||||
|
||||
// The header fields and error texts sd-bus hands out as C strings, as strings: empty when there are none.
|
||||
std::string Sender(sd_bus_message* message);
|
||||
std::string Interface(sd_bus_message* message);
|
||||
std::string Member(sd_bus_message* message);
|
||||
std::string ErrorName(const sd_bus_error& error);
|
||||
std::string ErrorMessage(const sd_bus_error& error);
|
||||
|
|
@ -160,8 +149,8 @@ namespace Nostro::Bus {
|
|||
~Error();
|
||||
};
|
||||
|
||||
// A vtable of every method of `table` (methods or checkoutMethods), all of them unprivileged (polkit decides, not
|
||||
// sd-bus), each handled by `handler(member)`. It must outlive the object it is registered for.
|
||||
// A vtable of every method of `table`, all of them unprivileged (polkit decides, not sd-bus), each handled by
|
||||
// `handler(member)`. It must outlive the object it is registered for.
|
||||
std::vector<sd_bus_vtable> Vtable(std::span<const Method> table, const std::function<sd_bus_message_handler_t(std::string_view member)>& handler);
|
||||
|
||||
// Enters a container, or throws when the message holds something else there.
|
||||
|
|
|
|||
|
|
@ -154,7 +154,9 @@ namespace Nostro {
|
|||
BunqCard SetCardStatus(std::uint64_t card, std::string_view status);
|
||||
[[nodiscard]] Pending SetCardStatus(std::uint64_t card, std::string_view status, Then<BunqCard> then);
|
||||
|
||||
// The account apps' checkouts (Nostro.Checkout) pay from: none until one is chosen, or once it is gone.
|
||||
// The account a pay link's form starts from in the app: none until one is chosen, or once it is gone. It is
|
||||
// where that form starts and no more; nostrod pays nothing from it by itself. The name is from what it was
|
||||
// until 2026-11-22: the account that paid an app's order at a checkout over D-Bus, which went that day.
|
||||
std::optional<Account> DefaultCheckoutAccount();
|
||||
[[nodiscard]] Pending DefaultCheckoutAccount(Then<std::optional<Account>> then);
|
||||
// Chooses it, and returns it. An account reached through OAuth cannot pay a shop, and is refused.
|
||||
|
|
|
|||
|
|
@ -172,6 +172,41 @@ export namespace Nostro {
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Whether a code point draws nothing, or tells the reader's own text where to go: control and format characters,
|
||||
// the line and paragraph separators, what Unicode leaves out of a display by default (soft hyphens, joiners,
|
||||
// fillers, variation selectors, tags), surrogates, private use, and what is no character at all. nostrod keeps a
|
||||
// password dialog free of them, and the app refuses a link whose name or description holds one.
|
||||
constexpr bool Unshown(std::uint32_t code) noexcept {
|
||||
using Range = std::pair<std::uint32_t, std::uint32_t>;
|
||||
static constexpr std::array<Range, 31> ranges = {{
|
||||
{0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD}, {0x034F, 0x034F}, {0x0600, 0x0605}, {0x061C, 0x061C}, {0x06DD, 0x06DD}, {0x070F, 0x070F},
|
||||
{0x0890, 0x0891}, {0x08E2, 0x08E2}, {0x115F, 0x1160}, {0x17B4, 0x17B5}, {0x180B, 0x180F}, {0x200B, 0x200F}, {0x2028, 0x202E}, {0x2060, 0x206F},
|
||||
{0x3164, 0x3164}, {0xD800, 0xF8FF}, {0xFDD0, 0xFDEF}, {0xFE00, 0xFE0F}, {0xFEFF, 0xFEFF}, {0xFFA0, 0xFFA0}, {0xFFF0, 0xFFFC}, {0xFFFE, 0xFFFF},
|
||||
{0x110BD, 0x110BD}, {0x110CD, 0x110CD}, {0x13430, 0x1343F}, {0x1BCA0, 0x1BCA3}, {0x1D173, 0x1D17A}, {0xE0000, 0xE0FFF}, {0xF0000, 0xFFFFFFFF},
|
||||
}};
|
||||
for(const Range& range : ranges) {
|
||||
if(code >= range.first && code <= range.second) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Whether a code point is a space of any width, the ordinary one among them, or the Braille pattern without a dot,
|
||||
// which is one to the eye.
|
||||
constexpr bool Blank(std::uint32_t code) noexcept {
|
||||
using Range = std::pair<std::uint32_t, std::uint32_t>;
|
||||
static constexpr std::array<Range, 8> ranges = {{
|
||||
{0x0020, 0x0020}, {0x00A0, 0x00A0}, {0x1680, 0x1680}, {0x2000, 0x200A}, {0x202F, 0x202F}, {0x205F, 0x205F}, {0x2800, 0x2800}, {0x3000, 0x3000},
|
||||
}};
|
||||
for(const Range& range : ranges) {
|
||||
if(code >= range.first && code <= range.second) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Where the library's warnings go: a connector that could not be refreshed, an account it skipped, a request made
|
||||
// but not read back. A line on stderr unless the program replaces it; a daemon sends them to the client that made
|
||||
// the call instead, as on stderr they would only reach its journal.
|
||||
|
|
|
|||
|
|
@ -105,6 +105,15 @@ export namespace Nostro::App {
|
|||
// "add:<bank>:<way>" for a way's form, as in "add:bunq:key". False for a name that is none of them, and while
|
||||
// a change is under way, which the screen waits out.
|
||||
bool Navigate(std::string_view route);
|
||||
// Opens a link the program was started with, as a browser hands one on from a website's pay button: a payment
|
||||
// to make, which ReadPaymentLink reads. Its pay form opens filled in once the accounts are known, with the
|
||||
// choice of which account pays over it where there is more than one, starting from the account the user
|
||||
// chose for pay links where they chose one; until then the accounts' page says that it will. That is all a
|
||||
// link does.
|
||||
// Nothing is sent before the user presses the form's button, and the system's password dialog confirms it as
|
||||
// it does any payment: there is no say in a link. One that cannot be read is said to be so, with why. False
|
||||
// while a change is under way, which the screen waits out.
|
||||
bool Open(std::string_view link);
|
||||
// Where the user is, as a name of the same kind, with what is open over it after a '+': "account:NL…+filter".
|
||||
std::string Screen() const;
|
||||
// The connections and accounts as they are known.
|
||||
|
|
@ -127,7 +136,7 @@ export namespace Nostro::App {
|
|||
Banks, // adding a connection: the banks to choose from
|
||||
Ways, // the ways to connect to the bank that was chosen
|
||||
Connect, // the form of the way that was chosen
|
||||
Checkout,
|
||||
Checkout, // the account pay links start from: named, as its route is, after the wire's DefaultCheckoutAccount
|
||||
About
|
||||
};
|
||||
struct Route {
|
||||
|
|
@ -251,6 +260,8 @@ export namespace Nostro::App {
|
|||
// -- what the user asks for ----------------------------------------------------------------------------------
|
||||
void OpenPay(std::string account);
|
||||
void OpenRequest(std::string account);
|
||||
// The pay form for the link that waits, once what it starts from has been read.
|
||||
void TakeLink();
|
||||
void SubmitPayment();
|
||||
void SendPayment(const std::string& key, Currency currency, const PaymentOrder& order);
|
||||
void SubmitRequest();
|
||||
|
|
@ -323,6 +334,7 @@ export namespace Nostro::App {
|
|||
Loadable<std::vector<Connection>> overview;
|
||||
std::map<std::string, AccountData, std::less<>> accounts;
|
||||
Loadable<std::vector<ConnectorCards>> cards;
|
||||
// The account a link's pay form starts from, where the user chose one (nostrod's DefaultCheckoutAccount).
|
||||
Loadable<std::optional<Account>> checkout;
|
||||
|
||||
Place place = Place::Accounts;
|
||||
|
|
@ -333,6 +345,9 @@ export namespace Nostro::App {
|
|||
|
||||
PaymentForm payment;
|
||||
std::string payFrom;
|
||||
// A link that was read, whose pay form opens once the accounts are known. It is kept apart from the form until
|
||||
// then: a form that holds what a link said is shown as a link's, never found filled in later.
|
||||
std::optional<PaymentLink> waiting;
|
||||
RequestForm request;
|
||||
std::string requestInto;
|
||||
BunqKeyForm bunqKey;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import Nostro.Ui;
|
|||
// whole: each field's error is a line for under that field, and a form without errors gives an order, the values
|
||||
// nostrod is asked with. Nothing here talks to nostrod; nostrod checks everything again. The forms a payment, a
|
||||
// request and a filter are filled in on are any bank's; what a bank asks for to be connected is its own, and so is
|
||||
// the form for it, named for its bank.
|
||||
// the form for it, named for its bank. A form can also be filled in by a link, which is read here too: more strictly
|
||||
// than anything typed, since whoever wrote it is a stranger.
|
||||
|
||||
export namespace Nostro::App {
|
||||
// What a field's text was read as, or why it could not be.
|
||||
|
|
@ -33,6 +34,27 @@ export namespace Nostro::App {
|
|||
// A whole number above zero.
|
||||
Read<std::uint32_t> ReadCount(std::string_view text);
|
||||
|
||||
// A payment a link asks for, as a website's pay button hands one on to whichever program pays: who is paid, and
|
||||
// what the link says of how much and what for.
|
||||
struct PaymentLink {
|
||||
std::string iban; // in capitals and without spaces, its check digits verified
|
||||
std::string name; // the account's holder; empty when the link names nobody
|
||||
std::optional<std::int64_t> amount; // in the currency's smallest unit; none: the user says how much
|
||||
Currency currency = Currency::Euro;
|
||||
std::string description;
|
||||
};
|
||||
// Reads a link of RFC 8905, "payto://iban/NL91…?amount=EUR:12.50&receiver-name=…&message=…": the IBAN, with a
|
||||
// bank's code before it or not, and of its options the amount, the holder's name and what the payment is for.
|
||||
// An option it does not know is passed over, so that the format can grow. Everything else that is not as it
|
||||
// should be is refused: a link is a stranger's text, and what comes of it is put before the user as a payment to
|
||||
// make. So it has one IBAN that checks out, each thing said once, an amount written in one way only, and a name
|
||||
// and a description of plain text: nothing in them that would hide, turn text around or break a line, and no
|
||||
// space other than the plain one, so the name on the form is the name the bank gets. The system's password dialog
|
||||
// shows the name the way nostrod makes any name fit: cut at 64 characters, with &, < and > replaced, and after the
|
||||
// IBAN, which it shows whole. The error says what is wrong in words of the app's own, with nothing of the link in
|
||||
// them.
|
||||
Read<PaymentLink> ReadPaymentLink(std::string_view link);
|
||||
|
||||
// How often a scheduled payment runs, as the form offers it and as nostrod is told it.
|
||||
struct ScheduleUnit {
|
||||
std::string_view label;
|
||||
|
|
@ -70,6 +92,8 @@ export namespace Nostro::App {
|
|||
Ui::EditState until{Ui::FieldKind::Plain};
|
||||
// Errors show once the user has tried to go on: an empty form is not a list of mistakes.
|
||||
bool tried = false;
|
||||
// A link filled it in, not the user: the form says so for as long as it holds what the link put there.
|
||||
bool linked = false;
|
||||
|
||||
struct Errors {
|
||||
std::string to;
|
||||
|
|
@ -83,6 +107,9 @@ export namespace Nostro::App {
|
|||
};
|
||||
// Every field's error, and into `order` what the form asks for when there is none.
|
||||
Errors Check(Currency currency, std::chrono::system_clock::time_point now, PaymentOrder& order) const;
|
||||
// Puts what a link asks for in place of whatever the form held. It is a form filled in and no more: the user
|
||||
// can change every field, and nothing is sent until they press its button.
|
||||
void Fill(const PaymentLink& link);
|
||||
void Clear();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
export module Nostro.Checkout;
|
||||
import std;
|
||||
|
||||
// Checkout: how a shop app has the user's nostro pay an order, and nothing else of nostro. nostrod pays the order from
|
||||
// the account the user chose for checkouts, once the user has confirmed it at a password prompt that shows the order and
|
||||
// that account; the app never names nor sees an account, and learns only the payment's id. A module of its own, so
|
||||
// `--product=checkout` builds it without nostro's bank code, OpenSSL, Crafter.Network or Crafter.DB: it needs libsystemd
|
||||
// alone. Apps in other languages use packaging/dbus/net.catcrafts.Nostro1.Checkout.xml instead.
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
export namespace Nostro::Checkout {
|
||||
// String views of literals, so `.data()` is NUL-terminated as sd-bus wants it.
|
||||
inline constexpr std::string_view busName = "net.catcrafts.Nostro1.Checkout";
|
||||
inline constexpr std::string_view objectPath = "/net/catcrafts/Nostro1";
|
||||
inline constexpr std::string_view interfaceName = "net.catcrafts.Nostro1.Checkout";
|
||||
|
||||
// Pay(payeeIban, payeeName, amount, currency, reference, options) -> (paymentId, results): the arguments' signature,
|
||||
// the reply's, and their names, each ended by a NUL.
|
||||
inline constexpr std::string_view payArguments = "ssxssa{sv}";
|
||||
inline constexpr std::string_view payReply = "ta{sv}";
|
||||
inline constexpr std::string_view payNames = "payeeIban\0payeeName\0amount\0currency\0reference\0options\0paymentId\0results\0"sv;
|
||||
|
||||
// The errors an app tells apart, besides org.freedesktop.DBus.Error.AccessDenied (the system's policy refused),
|
||||
// ServiceUnknown (no nostro) and InteractiveAuthorizationRequired. nostrod's other interface uses the same names.
|
||||
inline constexpr std::string_view errorCancelled = "net.catcrafts.Nostro1.Error.Cancelled"; // the user did not confirm: nothing was paid
|
||||
inline constexpr std::string_view errorNoCheckoutAccount = "net.catcrafts.Nostro1.Error.NoCheckoutAccount"; // the user has no account to pay checkouts from
|
||||
inline constexpr std::string_view errorInvalidArgument = "net.catcrafts.Nostro1.Error.InvalidArgument"; // refused before anything was paid
|
||||
inline constexpr std::string_view errorBank = "net.catcrafts.Nostro1.Error.Bank"; // the bank refused
|
||||
inline constexpr std::string_view errorFailed = "net.catcrafts.Nostro1.Error.Failed"; // anything else
|
||||
|
||||
// An order to pay.
|
||||
struct Order {
|
||||
std::string payeeIban; // who is paid: an IBAN, the only kind of payee checkout pays
|
||||
std::string payeeName; // their name, as the bank and the prompt show it
|
||||
std::int64_t amount = 0; // in the currency's smallest unit: 1250 is 12.50
|
||||
std::string currency = "EUR"; // ISO 4217
|
||||
std::string reference; // the order's own number: the payment's description, and what tells orders apart
|
||||
};
|
||||
|
||||
// What became of an order.
|
||||
struct Paid {
|
||||
std::uint64_t paymentId = 0; // the bank's id of the payment
|
||||
bool repeated = false; // paid before, by an earlier call with the same order: nothing was paid now
|
||||
};
|
||||
|
||||
// An error nostrod answered with, by its D-Bus name: errorBank, org.freedesktop.DBus.Error.AccessDenied, ...
|
||||
struct Error : std::runtime_error {
|
||||
std::string name;
|
||||
Error(std::string name, const std::string& message);
|
||||
};
|
||||
|
||||
// The user did not confirm the order: nothing was paid.
|
||||
struct Cancelled : Error {
|
||||
using Error::Error;
|
||||
};
|
||||
|
||||
// The user has no account to pay checkouts from (`nostro checkout account <account>` chooses one): nothing was paid.
|
||||
struct NoCheckoutAccount : Error {
|
||||
using Error::Error;
|
||||
};
|
||||
|
||||
// Has the user's nostro pay `order`, and waits for it: for nostrod to start, for the user to read the order and
|
||||
// confirm it with their password, and for the bank, up to `timeout`; so call it off the UI thread. An order is paid
|
||||
// once: the same payee and reference again, after a timeout or a crash, answers with the first payment
|
||||
// (Paid::repeated), or waits for it while the user is still at the prompt, and the same reference with another
|
||||
// amount is refused. Throws Cancelled, NoCheckoutAccount, std::invalid_argument for text that is not UTF-8, and
|
||||
// Error for the rest; an Error named org.freedesktop.DBus.Error.ServiceUnknown means nostro is not installed.
|
||||
Paid Pay(const Order& order, std::chrono::seconds timeout = std::chrono::minutes(10));
|
||||
}
|
||||
Loading…
Reference in a new issue