coingate
All checks were successful
Deploy / build-deploy (push) Successful in 3m10s

This commit is contained in:
Jorijn van der Graaf 2026-08-13 23:34:19 +02:00
commit 70668af8f5
20 changed files with 2354 additions and 1048 deletions

View file

@ -15,6 +15,10 @@ No permission is granted to copy, modify, distribute, or create derivative works
// {"type":"invoice", "id":..,"number":..} the number assignment, at paid
// {"type":"notified","id":..,"what":..} the confirmation email left
//
// New keys on the order event are additive: the fold defaults anything absent,
// so a ledger written by an older build still reads correctly under a newer
// one. That property is the reason nothing here is ever rewritten in place.
//
// Current state is a left fold over the file; later events win. Nothing is
// ever rewritten, so the log doubles as the audit trail the tax records need,
// and a crash mid-write costs at most its own line (a truncated last line is
@ -117,6 +121,10 @@ std::vector<OrderRecord> FoldLocked() {
r.totalMinor = doc->Int("total_minor");
r.vatIncluded = doc->Bool("vat_included");
r.status = std::string(doc->Str("status", "awaiting_payment"));
// Read as written, with no default applied here: the ledger
// should keep saying exactly what it recorded, and resolving an
// unexpected value to a rail is PaymentRails::For's single job.
r.payChoice = std::string(doc->Str("pay_choice"));
r.payUrl = std::string(doc->Str("pay_url"));
r.payId = std::string(doc->Str("pay_id"));
if (r.token.empty()) continue;
@ -165,14 +173,15 @@ bool CreateOrder(const OrderRecord& o) {
R"("color":"{}","quantity":{},"unit_minor":{},)"
R"("email":"{}","name":"{}","street":"{}","postal":"{}","city":"{}","country":"{}",)"
R"("goods_minor":{},"shipping_minor":{},"total_minor":{},"vat_included":{},)"
R"("status":"{}","pay_url":"{}","pay_id":"{}"}})",
R"("status":"{}","pay_choice":"{}","pay_url":"{}","pay_id":"{}"}})",
JsonEscape(o.createdAt), JsonEscape(o.token), JsonEscape(o.reference),
JsonEscape(o.product),
JsonEscape(o.color), o.quantity, o.unitMinor,
JsonEscape(o.buyer.email), JsonEscape(o.buyer.name), JsonEscape(o.buyer.street),
JsonEscape(o.buyer.postal), JsonEscape(o.buyer.city), JsonEscape(o.buyer.country),
o.goodsMinor, o.shippingMinor, o.totalMinor, o.vatIncluded,
JsonEscape(o.status), JsonEscape(o.payUrl), JsonEscape(o.payId)));
JsonEscape(o.status), JsonEscape(o.payChoice),
JsonEscape(o.payUrl), JsonEscape(o.payId)));
}
bool AppendOrderStatus(std::string_view token, std::string_view status,