Skip to content

Commit f4ab839

Browse files
committed
Fix update_checkout_session to handle all optional args correctly.
Now the method erase data from checkout object for many optional args if not provided.
1 parent 24928f7 commit f4ab839

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

.cspell/custom-words.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Visa
3838
Wayfair
3939
Worldpay
4040
Zalando
41+
absl
42+
absltest
4143
adyen
4244
agentic
4345
atok
@@ -52,6 +54,7 @@ fontawesome
5254
fpan
5355
fulfillable
5456
gpay
57+
healthz
5558
ingestions
5659
inlinehilite
5760
linenums
@@ -75,4 +78,4 @@ shopify
7578
superfences
7679
vulnz
7780
yaml
78-
yml
81+
yml

integration_test_utils.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,25 @@ def update_checkout_session(
778778
779779
"""
780780
# Default to existing values if not provided
781-
currency = currency if currency is not None else checkout_obj.currency
781+
if currency is None:
782+
currency = checkout_obj.currency
783+
784+
def to_json(obj):
785+
if obj is not None and hasattr(obj, "model_dump"):
786+
return obj.model_dump(mode="json", exclude_none=True)
787+
return obj
788+
789+
if buyer is None:
790+
buyer = to_json(getattr(checkout_obj, "buyer", None))
791+
792+
if fulfillment is None:
793+
fulfillment = to_json(getattr(checkout_obj, "fulfillment", None))
794+
795+
if discounts is None:
796+
discounts = to_json(getattr(checkout_obj, "discounts", None))
797+
798+
if platform is None:
799+
platform = to_json(getattr(checkout_obj, "platform", None))
782800

783801
# Construct Line Items
784802
if line_items is None:

0 commit comments

Comments
 (0)