Repository navigation
v0.3.0
Added
- A won dispute is reported. The new
pay.KindDisputeWonis emitted for
charge.dispute.closedwith statuswonand for
charge.dispute.funds_reinstated, with the dispute's id asReversalRef.
Subscribe the endpoint to both events; Stripe may send both for one win. pay.MemEventbuilds a refund. The optionspay.WithReversalRefand
pay.WithEmailset the refund's own reference and the payer's email, so a
test drives a purchase, its credit and its refund through the handler.
Before, a refund built withMemEventhad noReversalRef, and the
documented handler refused it.paytest.WithPaidDeliverygives the conformance suite a signed, paid
delivery. With it, the suite checks that your adapter turns it into
pay.KindPaidwith its reference, and refuses the same body with one byte
changed withpay.ErrBadSignature.
Changed
-
Built with Go 1.27.4, which fixes GO-2026-6859.
-
pgledger.Migrateadds a migration. Version 2 adds the column
reversestoledger_entriesand a unique index on it, so the database
allows one reversal per entry. RunMigratebefore the new release
serves traffic, as at every start. A reversal written before the
migration does not record its entry, so an entry reversed then can be
reversed once more. -
A reference used again for a different write is refused with the new
ledger.ErrRefConflict. A replay of the same write, with the same holder,
kind, amount and group, still writes nothing and returnsnil. Before,
any write whose reference was already recorded returnedniland wrote
nothing, so a credit or a hold could vanish behind another write's
reference. A reversal whoseRefequals itsOfis refused the same way.
A reference that is blank or starts or ends with a space is refused with
ledger.ErrBadRef. -
An entry is reversed at most once. A second reversal of the same
entry under another reference, such as a dispute after a refund, writes
nothing and returnsEffect{Applied: false}. A transfer, a hold or a
release cannot be reversed:ledger.ErrNotReversible. -
A settled group stays closed. A hold on a group that is already
settled is refused withledger.ErrSettled, a settlement that names
another holder than the hold's withledger.ErrWrongHolder, and a
Debitthat carries a group withledger.ErrDebitGroup. Before, each of
them was accepted and left credit held that nothing could release, or
released it onto the wrong holder. -
ledger.MemStore.Withinholds the store for the whole unit. Other writers
wait until it ends, and see none of its entries if it fails. A unit must
write through theOpsit is given: a call on the store itself from inside
it waits forever. -
ledger.CheckReversalandledger.CheckReplayare exported, so a store
you write refuses the same reversals and treats the same writes as
replays as the two stores here. -
A checkout or a charge for zero or a negative amount is refused with
the newpay.ErrNotPositive, by the Stripe adapter before it calls Stripe,
and bypay.MemProvider.MemProvideralso refuses a currencymoneydoes
not know, withmoney.ErrCurrency. Before, Stripe refused such a charge
with its own error, and the fake accepted it. -
The conformance suite is stricter.
paytest.RunProviderContractfails
an adapter that accepts a delivery with no signature, so the factory you
pass must configure a webhook secret: apay.MemProviderwithout a
Secretno longer passes. It also fails an adapter that accepts a
checkout or a charge for zero or a negative amount. -
pay.WebhookHandlerstill answers 400 for every delivery the adapter
refuses, but the answer saysbad signatureonly when the signature
failed, andunusable deliveryfor a delivery that verified and cannot be
used, such as a paid session in another currency. Theatfield of the
log line tells the two apart. Withpay.WithLogger, a delivery answered
200 without reaching your handler, because no processor or no handler is
configured, is now logged as a warning. -
pgledgeris built on pgx v5.12.0, up from v5.10.0. -
The Stripe adapter is built on stripe-go v87.1.0, up from v85.2.0. Its calls
to Stripe now carry API version2026-10-28.endiveinstead of
2026-05-27.dahlia; no parameter it sends and no field it reads changed
between the two. Webhook deliveries are still read at the version the
endpoint is registered on. A 409 or 5xx answer from Stripe is now retried
under the same idempotency key, so a retried create returns the original
checkout, customer or charge.
Fixed
- A replayed hold or transfer that carries a reference returns
nil,
in both stores, also after the first attempt spent the funds. Before, it
returnedledger.ErrInsufficient, and a caller could stop work that was
paid for. - Reversing a transfer no longer creates money. It reversed only the
sending side, so the receiver kept what the sender got back. pgledger.Migratefrom several processes against a database that has
never had the ledger now succeeds. It created its version table before
taking its lock, and all but one process failed.ledger.MemStore.Withinno longer discards other writers' entries when a
unit fails, and aTransferor aSettleinMemStorethat fails
partway writes nothing.- In Postgres,
ReversereportsApplied: trueto exactly one of several
concurrent callers. Each of them was told it applied. - A balance that does not fit an
int64is an error that wraps
money.ErrRange, in both stores.MemStorewrapped it around to a
negative number, and Postgres failed with a database error. NegativeHoldersin Postgres matches the namespace as written. It read it
as aLIKEpattern, so_and%matched other namespaces.money.Spread.Creditedno longer overflows. Above about $18 billion of
gross at a 5% cut, the cut wrapped around to a negative number and the
credit came out larger than the gross. A negativeBpsorFixedMicro
now counts as zero, where it credited more than was paid.money.FromUSDis exact for an amount that is a whole number of micros:
FromUSD(0.000123)was 124 micros and is now 123. About one such value in
a hundred came out one micro high. It also refuses 2^63 micros, which it
let through and converted to a different number on each architecture.
Security
- The Stripe adapter refuses a signature dated more than 5 minutes in the
future, withpay.ErrBadSignature. The Stripe SDK refuses only old
ones, so a delivery signed with a timestamp far ahead verified until that
time. - The Stripe adapter refuses an amount in a delivery that does not fit an
int64of micro-USD, with an error that wrapsmoney.ErrRange. Before,
the conversion wrapped around without an error, and a large amount became
a negative one. - Printing a
stripe.Configwith%v,%+vor%#vno longer prints its
API key or its webhook secret: each prints as[redacted]when set. - A webhook signing secret made only of whitespace now refuses every
delivery withpay.ErrBadSignature. Before, it was used as the signing
key, so a delivery signed with the same blank key verified. - Built and tested with Go 1.27.3, which fixes GO-2026-6611,
GO-2026-6612, GO-2026-6613, GO-2026-6617 and GO-2026-6809, a flaw in the
standard library's certificate verification that this code can reach. A
program that imports this module builds with its own Go, so build it
with 1.27.3 or later.