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,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();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue