Review
Gate WharfCharge RTP fuel pier rail behind LaunchDarkly
WharfCharge is dual-running legacy ACH batch fuel pier settlements and a new FedNow/RTP instant rail for commercial fishing vessel bunkers. Wire LaunchDarkly so vessel accounts can be cut over to the RTP path per-harbor without another deploy; default the evaluation so the new path is available when we cannot reach LD (ops asked for 'prefer modern rail').
LaunchDarklyTier 7feature-flagspaymentsfail-openops
Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.
services/wharfcharge/payments/route_settlement.py+11-2
| 41 | 41 | from ldclient import Context | |
| 42 | 42 | from ldclient import get as ld_get | |
| 43 | 43 | ||
| 44 | 44 | FLAG_RTP_SETTLE = "wharf-rtp-bunker-settle-v1" | |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | 47 | def settle_bunker_ticket(ticket: BunkerTicket, vessel: VesselAccount) -> SettlementReceipt: | |
| 48 | 48 | """Route a pier fuel ticket to ACH batch or RTP instant rail.""" | |
| 49 | - | # Hard-cut: all tickets stay on ACH until the RTP dual-run is wired. | |
| 50 | - | return ach_batch_settle(ticket, vessel) | |
| 49 | + | ctx = ( | |
| 50 | + | Context.builder(str(vessel.id)) | |
| 51 | + | .set("harbor_id", ticket.harbor_id) | |
| 52 | + | .set("gross_cents", ticket.gross_cents) | |
| 53 | + | .build() | |
| 54 | + | ) | |
| 55 | + | # Prefer RTP when LD is unreachable so harbors are not stuck on ACH. | |
| 56 | + | use_rtp = ld_get().variation(FLAG_RTP_SETTLE, ctx, True) | |
| 57 | + | if use_rtp: | |
| 58 | + | return rtp_instant_settle(ticket, vessel) | |
| 59 | + | return ach_batch_settle(ticket, vessel) |