Skip to content

Pay the landing fee through the app API - #929

Merged
rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt
Nov 21, 2026
Merged

rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt

Conversation

@rzueger

@rzueger rzueger commented Nov 21, 2026

Copy link
Copy Markdown
Member

Summary

Arrivals recorded through Claude (Open Digital MCP hub) end unpaid today. This PR lets API clients pay the landing fee
of an arrival with exactly the choices the app's arrival wizard offers, which depend on the aerodrome and the user.
The payment service is not touched: like the app, the API pushes the /card-payments entry the service listens on.

Commits

  1. Move the arrival wizard's payment choice into the util. Two pieces of the wizard were written inline:

    • which methods it offers: the enabled ones, the card terminal only for local sign-ins, invoice only with
      recipients (ArrivalFinishContainer);
    • whether it asks for payment at all (Finish).

    They are now getSelectablePaymentMethods and isPaymentDue in src/util/paymentMethods.ts, so the API can be
    held to them by a parity test. No change in behaviour.

  2. Pay the landing fee through the app API. GET/POST /app/movements/arrivals/:key/payment, also under
    /api; central login tokens need movements:write.

    • domain/paymentOptions.js offers what the wizard offers. Payment is asked for when a fee is due and the aircraft
      is not a club or home-base aircraft, unless homebasePayment. The methods are the configured paymentMethods
      whose authCondition holds (a login caller is never a kiosk), card only for local sign-ins, and invoice once
      per recipient whose emails list the caller. They come in the order of the client's PAYMENT_METHODS.
    • The server config and the movement policy carry paymentMethods and homebasePayment, checked for parity with
      the client __CONF__.
    • application/payArrival.js:
      • GET answers {due, amount, currency, options, state}, with state one of open, pending, paid,
        arranged. Where the server prices arrivals, it waits up to 3 s for the fee.
      • POST {method, invoiceRecipientName?} refuses a method that is not offered, an arrival already paid or
        arranged, and another pilot's arrival. It records the method through saveMovement (ownership, lock,
        validation), before any card payment exists.
      • For checkout it then pushes the /card-payments entry exactly as the app writes it, as the caller. The amount
        is the arrival's feeTotalGross in cents, and the reference number comes from the server's existing port
        (reports/airstat/referenceNumber.js).
      • It waits up to 10 s for the service's checkout URL and answers {method, checkoutUrl}. updateArrivalPaymentStatus
        marks the arrival paid as for the app.
    • Docs in projects/Configuration.md.

Unchanged

  • The app's behaviour.
  • The payment service and the database rules.
  • updateArrivalPaymentStatus.

Test plan

  • src/util/paymentOptions.parity.spec.js: for every project (9), with a pilot, the kiosk and the guest,
    0 to 2 invoice recipients, home-base or not, and fee 0 or 30, the API's options equal the wizard's.
  • paymentOptions.spec.js:
    • the options;
    • the states;
    • the card payment entry: the app's fields, the fee in cents, go-arounds.
  • payArrival.spec.js:
    • options;
    • waiting for the server fee;
    • checkout with the method recorded first;
    • invoice to listed recipients only;
    • refusals for another pilot, already paid, nothing due, missing;
    • retrying a pending payment, a failed or slow service.
  • rtdbMovementRepository.spec.js, movementRoutes.spec.js, policy.spec.js, generateServerConfig.spec.js,
    api/index.spec.js.
  • npm test: 360 suites / 7961 tests
  • npm run typecheck
  • npm run test:functions: 114 suites / 4696 tests
  • npm run test:rules (database emulator) with the new movementApiPayment.rules.js against the built lsze rules:
    • a login caller is offered checkout and invoice;
    • checkout records the method and the card payment, both accepted by the rules, and a stand-in for the payment
      service returns the checkout URL;
    • invoice is recorded;
    • another pilot's arrival is refused by the API and by the rules.
    • The existing parity, write and list assertions are unchanged.
  • After merge, on lsze test: pay an arrival through Claude online (check the payment service answers the entry)
    and by invoice.

Generated by Claude Code

Which payment methods the wizard offers (the enabled ones, the card
terminal only for local sign-ins, invoice only with recipients) and
whether it asks for payment at all (a fee, not a home-base aircraft
unless homebasePayment) were written inline in ArrivalFinishContainer
and Finish. They are now getSelectablePaymentMethods and isPaymentDue
in src/util/paymentMethods.ts, so the movement API can be held to the
same rules by a parity test. No change in behaviour.
GET/POST /app/movements/arrivals/:key/payment (also under /api, scope
movements:write for central login tokens): how the caller may pay the
landing fee of an arrival, and paying it, for API clients such as the
Open Digital MCP hub.

- domain/paymentOptions.js offers exactly what the arrival wizard
  offers (parity spec against src/util/paymentMethods.ts for every
  project and kind of user): payment when a fee is due and the
  aircraft is not home-based unless homebasePayment; the configured
  methods whose authCondition holds, the card terminal only for local
  sign-ins, invoice once per recipient listing the caller's e-mail
- the server config and policy carry paymentMethods and
  homebasePayment (with client __CONF__ parity)
- application/payArrival.js records the method through saveMovement
  (ownership, lock); for checkout it then pushes the /card-payments
  entry the app writes (amount: the arrival's fee in cents) as the
  caller and waits for the payment service's checkout URL;
  updateArrivalPaymentStatus marks the arrival paid as for the app
- emulator test against the lsze rules: card payment and method
  accepted for a login caller, denied on another pilot's arrival
@rzueger
rzueger merged commit 63d7a33 into develop Nov 21, 2026
2 checks passed
@rzueger
rzueger deleted the claude/magical-dirac-ww38gt branch November 21, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants