Skip to content

Commit

Permalink
server/checkout: remove payment_processor from CheckoutCreate
Browse files Browse the repository at this point in the history
Fix #4748
  • Loading branch information
frankie567 committed Jan 2, 2025
1 parent 01f097f commit a6be7ba
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
3 changes: 0 additions & 3 deletions server/polar/checkout/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ class CheckoutCreateBase(CustomFieldDataInputMixin, MetadataInputMixin, Schema):
to the resulting order and/or subscription.
"""

payment_processor: Literal[PaymentProcessor.stripe] = Field(
description="Payment processor to use. Currently only Stripe is supported."
)
discount_id: UUID4 | None = Field(
default=None, description="ID of the discount to apply to the checkout."
)
Expand Down
2 changes: 0 additions & 2 deletions server/tests/checkout/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from polar.auth.scope import Scope
from polar.checkout.schemas import CheckoutProductCreate
from polar.checkout.service import checkout as checkout_service
from polar.enums import PaymentProcessor
from polar.integrations.stripe.service import StripeService
from polar.kit.tax import calculate_tax
from polar.kit.utils import utc_now
Expand Down Expand Up @@ -103,7 +102,6 @@ async def test_blocked_organization(
checkout = await checkout_service.create(
session,
CheckoutProductCreate(
payment_processor=PaymentProcessor.stripe,
product_id=product.id,
),
auth_subject,
Expand Down
33 changes: 1 addition & 32 deletions server/tests/checkout/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ async def test_not_existing_price(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=uuid.uuid4(),
),
auth_subject,
Expand All @@ -258,7 +257,6 @@ async def test_not_writable_price(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=product_one_time.prices[0].id,
),
auth_subject,
Expand All @@ -285,9 +283,7 @@ async def test_archived_price(
with pytest.raises(PolarRequestValidationError):
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe, product_price_id=price.id
),
CheckoutPriceCreate(product_price_id=price.id),
auth_subject,
)

Expand All @@ -309,7 +305,6 @@ async def test_archived_product(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=product_one_time.prices[0].id,
),
auth_subject,
Expand Down Expand Up @@ -339,7 +334,6 @@ async def test_amount_invalid_limits(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=product_one_time_custom_price.prices[0].id,
amount=amount,
),
Expand Down Expand Up @@ -399,7 +393,6 @@ async def test_invalid_not_existing_subscription(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
subscription_id=uuid.uuid4(),
metadata={"key": "value"},
Expand All @@ -425,7 +418,6 @@ async def test_invalid_not_existing_discount(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
discount_id=uuid.uuid4(),
),
Expand All @@ -451,7 +443,6 @@ async def test_invalid_not_applicable_discount(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
discount_id=discount_fixed_once.id,
),
Expand Down Expand Up @@ -482,7 +473,6 @@ async def test_invalid_paid_subscription(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
subscription_id=subscription.id,
metadata={"key": "value"},
Expand All @@ -508,7 +498,6 @@ async def test_valid_fixed_price(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
amount=amount,
metadata={"key": "value"},
Expand Down Expand Up @@ -540,7 +529,6 @@ async def test_valid_free_price(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
amount=amount,
metadata={"key": "value"},
Expand Down Expand Up @@ -575,7 +563,6 @@ async def test_valid_custom_price(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
amount=amount,
metadata={"key": "value"},
Expand Down Expand Up @@ -608,7 +595,6 @@ async def test_valid_tax_id(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
customer_billing_address=Address.model_validate({"country": "FR"}),
customer_tax_id="FR61954506077",
Expand All @@ -632,7 +618,6 @@ async def test_valid_success_url_with_interpolation(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
success_url=HttpUrl(
"https://example.com/success?checkout_id={CHECKOUT_ID}"
Expand All @@ -659,7 +644,6 @@ async def test_valid_success_url_with_invalid_interpolation_variable(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
success_url=HttpUrl(
"https://example.com/success?checkout_id={CHECKOUT_SESSION_ID}"
Expand Down Expand Up @@ -691,7 +675,6 @@ async def test_silent_calculate_tax_error(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
customer_billing_address=Address.model_validate({"country": "US"}),
),
Expand All @@ -718,7 +701,6 @@ async def test_valid_calculate_tax(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
customer_billing_address=Address.model_validate({"country": "FR"}),
),
Expand Down Expand Up @@ -753,7 +735,6 @@ async def test_valid_subscription_upgrade(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
subscription_id=subscription.id,
metadata={"key": "value"},
Expand Down Expand Up @@ -787,7 +768,6 @@ async def test_invalid_custom_field_data(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
custom_field_data=custom_field_data,
),
Expand All @@ -810,7 +790,6 @@ async def test_valid_custom_field_data(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
custom_field_data={"text": "abc", "select": "a"},
),
Expand All @@ -837,7 +816,6 @@ async def test_valid_embed_origin(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
amount=amount,
embed_origin="https://example.com",
Expand All @@ -860,7 +838,6 @@ async def test_valid_tax_not_applicable(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
customer_billing_address=Address.model_validate({"country": "FR"}),
),
Expand All @@ -885,7 +862,6 @@ async def test_valid_discount(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
discount_id=discount_fixed_once.id,
),
Expand All @@ -908,7 +884,6 @@ async def test_product_not_existing(
await checkout_service.create(
session,
CheckoutProductCreate(
payment_processor=PaymentProcessor.stripe,
product_id=uuid.uuid4(),
),
auth_subject,
Expand All @@ -928,7 +903,6 @@ async def test_product_not_writable(
await checkout_service.create(
session,
CheckoutProductCreate(
payment_processor=PaymentProcessor.stripe,
product_id=product_one_time.id,
),
auth_subject,
Expand All @@ -951,7 +925,6 @@ async def test_product_archived(
await checkout_service.create(
session,
CheckoutProductCreate(
payment_processor=PaymentProcessor.stripe,
product_id=product_one_time.id,
),
auth_subject,
Expand All @@ -971,7 +944,6 @@ async def test_product_valid(
checkout = await checkout_service.create(
session,
CheckoutProductCreate(
payment_processor=PaymentProcessor.stripe,
product_id=product_one_time.id,
),
auth_subject,
Expand All @@ -998,7 +970,6 @@ async def test_invalid_customer(
await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
customer_id=uuid.uuid4(),
),
Expand All @@ -1023,7 +994,6 @@ async def test_valid_customer(
checkout = await checkout_service.create(
session,
CheckoutPriceCreate(
payment_processor=PaymentProcessor.stripe,
product_price_id=price.id,
customer_id=customer.id,
),
Expand All @@ -1050,7 +1020,6 @@ async def test_customer_metadata(
checkout = await checkout_service.create(
session,
CheckoutProductCreate(
payment_processor=PaymentProcessor.stripe,
product_id=product_one_time.id,
customer_metadata={"key": "value"},
),
Expand Down

0 comments on commit a6be7ba

Please sign in to comment.