From 24e4efc80e91df2ef66aa5f4df5d2b05ec7bf42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Thu, 6 Mar 2025 09:53:48 +0100 Subject: [PATCH] server/checkout: add customer_external_id to Checkout schema --- server/polar/checkout/schemas.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/server/polar/checkout/schemas.py b/server/polar/checkout/schemas.py index bd65e0ecd1..8b4aa08adb 100644 --- a/server/polar/checkout/schemas.py +++ b/server/polar/checkout/schemas.py @@ -105,6 +105,12 @@ ), ] +_external_customer_id_description = ( + "ID of the customer in your system. " + "If a matching customer exists on Polar, the resulting order " + "will be linked to this customer. " + "Otherwise, a new customer will be created with this external ID set." +) _allow_discount_codes_description = ( "Whether to allow the customer to apply discount codes. " "If you apply a discount through `discount_id`, it'll still be applied, " @@ -142,13 +148,7 @@ class CheckoutCreateBase(CustomFieldDataInputMixin, MetadataInputMixin, Schema): ), ) customer_external_id: str | None = Field( - default=None, - description=( - "ID of the customer in your system. " - "If a matching customer exists on Polar, the resulting order " - "will be linked to this customer. " - "Otherwise, a new customer will be created with this external ID set." - ), + default=None, description=_external_customer_id_description ) customer_name: Annotated[CustomerName | None, EmptyStrToNoneValidator] = None customer_email: CustomerEmail | None = None @@ -462,6 +462,9 @@ def get_discount_discriminator_value(v: Any) -> str: class Checkout(MetadataOutputMixin, CheckoutBase): """Checkout session data retrieved using an access token.""" + customer_external_id: str | None = Field( + description=_external_customer_id_description + ) products: list[CheckoutProduct] = Field( description="List of products available to select." )