Skip to content

Commit 38eafe5

Browse files
committed
fix: 0원 결제 불가에 대해 다시 추가
1 parent c144799 commit 38eafe5

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

app/core/const/shop_error_messages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ProductNotOrderableErrorMessages:
1818
SOLDOUT = "{} 상품은 매진되었습니다."
1919
ALREADY_ORDERED_TOO_MUCH = "{} 상품의 인당 최대 구매 수량 초과로 구매하실 수 없습니다."
2020
TOO_MUCH_CART_PRODUCT = "{} 상품의 재고 수량을 초과하여 구매하실 수 없습니다. 장바구니에 담은 수량을 확인해주세요."
21+
PRICE_TOO_LOW = "결제 금액이 너무 낮습니다, 최소한 1원 이상으로 구매해주세요."
2122
PRICE_TOO_HIGH = "결제 금액이 너무 높습니다, 후원 금액 등을 줄여 100만원 미만으로 구매해주세요."
2223
DONATION_NOT_ALLOWED = "{} 상품은 후원이 불가능한 상품입니다."
2324
DONATION_PRICE_OUT_OF_RANGE = "{} 상품의 후원 금액이 범위를 벗어났습니다. {}원 이상 {}원 이하로 입력해주세요."

app/shop/serializers/cart_validation/product.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ def validate(
206206
)
207207
)
208208

209-
# 후원 금액 포함 단일 상품 금액이 0원 미만인 경우 주문 불가능
210209
total_price = (
211210
product.price
212211
+ donation_price
213212
+ sum(o["product_option"].additional_price for o in options if o["product_option"])
214213
)
214+
# 후원 금액 포함 단일 상품 금액이 0원 이하인 경우 주문 불가능 — PortOne 결제는 0원 금액에서 실패하므로 사전 차단.
215+
if total_price <= 0:
216+
raise serializers.ValidationError(ProductNotOrderableErrorMessages.PRICE_TOO_LOW)
215217
# 후원 금액 포함 단일 상품 금액이 100만원 이상인 경우 주문 불가능
216218
if total_price >= 1_000_000:
217219
raise serializers.ValidationError(ProductNotOrderableErrorMessages.PRICE_TOO_HIGH)

app/shop/test/cart_validation_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ def test_product_rejects_when_option_does_not_belong_to_product(customer_user, p
271271
lambda _product: ProductNotOrderableErrorMessages.PRICE_TOO_HIGH,
272272
id="total_price_too_high",
273273
),
274+
pytest.param(
275+
{"price": 0},
276+
0,
277+
lambda _product: ProductNotOrderableErrorMessages.PRICE_TOO_LOW,
278+
id="total_price_is_zero",
279+
),
274280
],
275281
)
276282
@pytest.mark.django_db

0 commit comments

Comments
 (0)