Repository navigation
fix: record cards issued during a concurrent freeze or terminate - #16
Merged
Merged
Conversation
Freezing or terminating a card while the provider call was still in flight could lose the issued card: Terminate left the token Terminated but CompleteIssuance then refused to record the PAN, and Freeze failed outright on a reservation. Domain: CompleteIssuance now only refuses a reservation that already carries a card, so a token moved out of Issuing (Frozen, Terminated) keeps that state while the card is recorded; Freeze accepts an in-flight reservation. MySQL: completion promotes Issuing -> Active in place with a CASE, preserving any operator state, and only while the issuance key is still held; the row is re-read so callers observe the stored state. Release drops any reservation that never received a card and never deletes a provisioned token. Tests cover the domain, both adapters, the token service and lifecycle freeze.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что
Закрывает гонку между выпуском карты и жизненным циклом: заморозка или завершение, попавшие в момент вызова провайдера, больше не теряют уже созданную карту.
CompleteIssuanceзаписывает PAN и из состоянийFrozen/Terminated, сохраняя состояние оператора — токен не «оживает» вActive; повторное завершение по-прежнему отвергается.Freezeразрешён на брониIssuing, поэтому заморозка во время выпуска не падает.Issuing → Activeвыполняется черезCASE, состояние оператора не перетирается; запись идёт только пока удерживаетсяissuance_key, строка перечитывается послеUPDATE.ReleaseTokenIssuanceосвобождает любую бронь без карты, но никогда не удаляет уже выданную карту.Тесты
Новые тесты на домен, оба адаптера (
memory, MySQL), сервис карт (эмитент замораживает бронь прямо внутри вызова) иlifecycle(freeze во время выпуска замораживает обе сущности).Проверка
gofmt,go build ./...,go vet ./...,golangci-lint run ./...— чисто.go test -race -count=1 ./...— зелено, включая интеграционные тестыinternal/adapter/mysqlпротив MySQL 8.0.Документация
README и CHANGELOG обновлены под новое поведение выпуска.