[codex] Fix invoice pay outcome precedence - #56
Merged
Conversation
There was a problem hiding this comment.
APPROVE
Summary
이 PR은 /v1/invoices/{id}/pay 요청에서 payment_method 파라미터가 fixture-configured PaymentIntent outcome을 우선하여 덮어쓰던 문제를 올바르게 수정합니다.
Analysis
변경 영역
api.go에서 기존에 paymentMethodID를 그대로 Outcome 필드에 전달하던 로직을 명시적인 outcome/billtap_outcome 파라미터만 확인하도록 변경했습니다.
// 변경 전
outcome := paymentMethodID
// 변경 후
Outcome: p.first("outcome", "billtap_outcome"),이는 payManualInvoice의 outcome 결정 우선순위와 일치합니다:
- 명시적
opts.Outcome - PaymentIntent metadata의 configured outcome
- Customer-level default outcome
opts.PaymentMethodID(fallback)- "payment_succeeded" (default)
검증
TestInvoiceBackedOneTimePaymentFlow에 payment_method 파라미터를 전달하면서 configured outcome이 우선함을 검증하는 assertion을 추가했습니다:
if failed.Metadata["billtap_last_invoice_payment_outcome"] != "card_declined" {
t.Fatalf("failed invoice metadata = %#v, want configured outcome to win over payment_method", failed.Metadata)
}Safety 확인
- Real payment data 처리 없음: outcome 시뮬레이션만 처리
- Webhook 영향 없음
- Fixture isolation 유지
- Production boundary 관련 변경 없음
Release gate
CI에서 Release gate가 SUCCESS로 표시되어 있습니다.
Conclusion
이 변경은 billing state correctness 관점에서 올바른 수정입니다. fixture-seeded configured outcome이 arbitrary payment_method보다 우선하도록 하는 것이 Billtap의 deterministic billing simulation 의도에 부합합니다.
Blocking issue가 없으므로 APPROVE합니다.
Reviewed by Z.ai GLM via Claude Code Action
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.
Summary
Fix invoice pay handling so
payment_methodandsourceremain payment method inputs only. Explicitoutcome/billtap_outcomestill override when requested, but a configured invoice-backed PaymentIntent outcome now wins over an arbitrary submitted payment method ID.Root cause
The
/v1/invoices/{id}/payhandler copied the submitted payment method intoInvoicePaymentOptions.Outcome. That bypassed customer/default PaymentIntent outcome metadata for manual invoice-backed payments and turned declined or action-required fixture paths into successful payments.Validation
go test ./internal/api -run TestInvoiceBackedOneTimePaymentFlow -count=1 -vgo test ./internal/api ./internal/billing ./internal/storagego test ./...git diff --check