Fix payment confirm response with runtime intent fields
This commit is contained in:
@@ -3272,14 +3272,18 @@ class PaymentContractCheckoutService:
|
|||||||
amount_usdc=intent.amount_usdc,
|
amount_usdc=intent.amount_usdc,
|
||||||
tx_hash=tx_hash_text,
|
tx_hash=tx_hash_text,
|
||||||
)
|
)
|
||||||
refreshed = PaymentIntentRecord(
|
refreshed_payload = {
|
||||||
**{
|
field_name: getattr(intent, field_name)
|
||||||
**intent.__dict__,
|
for field_name in PaymentIntentRecord.__dataclass_fields__
|
||||||
|
}
|
||||||
|
refreshed_payload.update(
|
||||||
|
{
|
||||||
"status": "confirmed",
|
"status": "confirmed",
|
||||||
"tx_hash": tx_hash_text,
|
"tx_hash": tx_hash_text,
|
||||||
"metadata": confirmed_metadata,
|
"metadata": confirmed_metadata,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
refreshed = PaymentIntentRecord(**refreshed_payload)
|
||||||
return {
|
return {
|
||||||
"intent": refreshed.__dict__,
|
"intent": refreshed.__dict__,
|
||||||
"transaction": tx_payload,
|
"transaction": tx_payload,
|
||||||
|
|||||||
@@ -235,6 +235,9 @@ def test_confirm_direct_transfer_uses_intent_chain_rpc(monkeypatch, tmp_path):
|
|||||||
metadata={},
|
metadata={},
|
||||||
)
|
)
|
||||||
confirmed_intent = PaymentIntentRecord(**{**intent.__dict__, "status": "confirmed"})
|
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]
|
intents = [intent, confirmed_intent]
|
||||||
get_intent_calls = []
|
get_intent_calls = []
|
||||||
requested_chains = []
|
requested_chains = []
|
||||||
@@ -653,6 +656,9 @@ def test_confirm_direct_transfer_uses_erc20_transfer_without_wallet_binding(monk
|
|||||||
metadata={},
|
metadata={},
|
||||||
)
|
)
|
||||||
confirmed_intent = PaymentIntentRecord(**{**intent.__dict__, "status": "confirmed"})
|
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]
|
intents = [intent, confirmed_intent]
|
||||||
rest_calls = []
|
rest_calls = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user