From 15e0cb09b86686241fdeb4767bd8f66c354d7261 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Mon, 15 Jun 2026 14:56:37 +0800 Subject: [PATCH] Fix payment confirm response with runtime intent fields --- src/payments/contract_checkout.py | 10 +++++++--- tests/test_direct_payment.py | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/payments/contract_checkout.py b/src/payments/contract_checkout.py index a03a9a89..4f8d09c9 100644 --- a/src/payments/contract_checkout.py +++ b/src/payments/contract_checkout.py @@ -3272,14 +3272,18 @@ class PaymentContractCheckoutService: amount_usdc=intent.amount_usdc, tx_hash=tx_hash_text, ) - refreshed = PaymentIntentRecord( - **{ - **intent.__dict__, + refreshed_payload = { + field_name: getattr(intent, field_name) + for field_name in PaymentIntentRecord.__dataclass_fields__ + } + refreshed_payload.update( + { "status": "confirmed", "tx_hash": tx_hash_text, "metadata": confirmed_metadata, } ) + refreshed = PaymentIntentRecord(**refreshed_payload) return { "intent": refreshed.__dict__, "transaction": tx_payload, diff --git a/tests/test_direct_payment.py b/tests/test_direct_payment.py index 9f3c1ed8..2df3f55f 100644 --- a/tests/test_direct_payment.py +++ b/tests/test_direct_payment.py @@ -235,6 +235,9 @@ def test_confirm_direct_transfer_uses_intent_chain_rpc(monkeypatch, tmp_path): metadata={}, ) confirmed_intent = PaymentIntentRecord(**{**intent.__dict__, "status": "confirmed"}) + # get_intent attaches user_id at runtime; the confirmation response must ignore + # non-dataclass attributes when rebuilding the returned intent payload. + setattr(intent, "user_id", "user-1") intents = [intent, confirmed_intent] get_intent_calls = [] requested_chains = [] @@ -653,6 +656,9 @@ def test_confirm_direct_transfer_uses_erc20_transfer_without_wallet_binding(monk metadata={}, ) confirmed_intent = PaymentIntentRecord(**{**intent.__dict__, "status": "confirmed"}) + # Production get_intent attaches user_id at runtime; the confirmation + # response must ignore non-dataclass attributes when rebuilding the intent. + setattr(intent, "user_id", "user-1") intents = [intent, confirmed_intent] rest_calls = []