Replaced mollie
All checks were successful
Deploy / build-deploy (push) Successful in 3m47s

This commit is contained in:
Jorijn van der Graaf 2026-08-20 20:15:47 +02:00
commit df91762271
29 changed files with 3079 additions and 838 deletions

View file

@ -133,30 +133,41 @@ cat > "$WORK/Caddyfile" <<EOF
EOF
# Rail selection for dev:
# * a repo-root .env (gitignored, never committed) is sourced if present —
# put MOLLIE_API_KEY=test_… there to point dev at Mollie's real test mode;
# * DEV_RAIL=fake|mollie overrides the automatic choice;
# * default with no key is the fake rail: full order lifecycle, no network.
# "Pay" an order with: touch $WORK/orders.jsonl.fake-paid
# * a repo-root .env (gitignored, never committed) is sourced if present;
# * DEV_RAIL=transfer|fake overrides the automatic choice;
# * default is TRANSFER, because that is what production serves. Dev used to
# default to the fake rail, which meant the bank rail's actual page — the
# IBAN, the beneficiary name, the reference, the whole thing a buyer reads
# — could not be looked at locally at all.
#
# A live_ key is refused outright. Dev creates throwaway orders; pointing them
# at real money collection is never what anyone meant.
# The transfer rail needs no credential, so dev can run the REAL rail rather
# than a stand-in: it only needs an account to name. If .env does not name one,
# obviously-fake values are used, and they are labelled as such on purpose —
# never make fixture data look real (a sample financials file was once mistaken
# for the actual books).
#
# Nothing here can collect real money: the transfer rail only RENDERS account
# details, and settlement comes from a credits file this machine writes.
if [ -f .env ]; then
set -a; . ./.env; set +a
fi
RAIL="${DEV_RAIL:-}"
if [ -z "$RAIL" ]; then
RAIL=fake
[ -n "${MOLLIE_API_KEY:-}" ] && RAIL=mollie
fi
if [ "$RAIL" = mollie ]; then
case "${MOLLIE_API_KEY:-}" in
test_*) echo "dev: payments via Mollie TEST mode" ;;
live_*) echo "dev: refusing to run dev against a LIVE Mollie key." >&2
echo "dev: live keys belong in /etc/catcrafts/payments.env on the server." >&2
exit 1 ;;
*) echo "dev: MOLLIE_API_KEY is not a test_ or live_ key" >&2; exit 1 ;;
esac
RAIL="${DEV_RAIL:-transfer}"
if [ "$RAIL" = transfer ]; then
# Refuse a real-looking IBAN that is not yours to be paid into by mistake?
# No — the opposite risk matters here. These values are only ever RENDERED
# in dev; nothing can be paid. What must not happen is dev quietly showing
# the PRODUCTION account while someone screenshots the page, so when .env
# supplies nothing the placeholders say plainly that they are placeholders.
: "${TRANSFER_IBAN:=NL00DEVB0000000000}"
: "${TRANSFER_BENEFICIARY:=DEV PLACEHOLDER, not a real account}"
: "${TRANSFER_BIC:=DEVBNL2A}"
export TRANSFER_IBAN TRANSFER_BENEFICIARY TRANSFER_BIC
if [ "$TRANSFER_IBAN" = NL00DEVB0000000000 ]; then
echo "dev: bank transfer rail with PLACEHOLDER account details"
echo "dev: put TRANSFER_IBAN / TRANSFER_BENEFICIARY / TRANSFER_BIC in .env to preview the real ones"
else
echo "dev: bank transfer rail, account $TRANSFER_IBAN ($TRANSFER_BENEFICIARY)"
fi
fi
# /financials has two inputs and a fresh dev run has neither: sales fold out of
@ -247,7 +258,16 @@ cat <<EOF
Edit the aggregates and just refresh — they are re-read every request:
\$EDITOR $WORK/orders.jsonl.financials.json")
Payment rail: $RAIL$([ "$RAIL" = fake ] && printf '%s' " — simulate a customer paying with:
touch $WORK/orders.jsonl.fake-paid")
touch $WORK/orders.jsonl.fake-paid")$([ "$RAIL" = transfer ] && printf '%s' " — the order page shows
the account details a buyer would transfer to. To simulate the money arriving,
append the credit the bank would have reported, using the order's own
reference (the CC-… code on the order page):
tools/dev-credit.sh $WORK/orders.jsonl CC-XXXXXX 57043
The reconciler picks it up within a minute and the order flips to paid.
Reference matching is deliberately forgiving, so try lower case, spaces, or
the RF… form to see that they all still settle the same order.")
Ctrl-C to stop.
EOF