fix(payment): NHN KCP 다통화 결제 금액 검증 예외 처리 보강

This commit is contained in:
thisgun committed 2026-07-06 10:54:32 +09:00
1 parent c59819645a
commit dee5a12ded
10 files changed
+283 -10

No files matched your search

@@ -72,6 +72,31 @@ class PaymentRetryControllerTest extends PluginTestCase
];
}
private static function invalidUsdCurrencySnapshot(): array
{
return [
'base_currency' => 'KRW',
'order_currency' => 'USD',
'base_unit' => 1000,
'exchange_rates' => [
'KRW' => [
'rate' => 1,
'rounding_unit' => '1',
'rounding_method' => 'round',
'decimal_places' => 0,
'base_unit' => 1000,
],
'USD' => [
'rate' => 0,
'rounding_unit' => '0.01',
'rounding_method' => 'round',
'decimal_places' => 2,
'base_unit' => 1,
],
],
];
}
public function test_retry_returns_ready_for_pending_order(): void
{
$order = $this->createOrder(10000);
@@ -89,6 +114,27 @@ class PaymentRetryControllerTest extends PluginTestCase
$this->assertEquals(PaymentStatusEnum::READY, $order->payment->payment_status);
}
public function test_retry_rejects_invalid_payment_currency_without_server_error(): void
{
$order = $this->createOrder(10000);
$order->update([
'currency' => 'USD',
'currency_snapshot' => self::invalidUsdCurrencySnapshot(),
]);
$response = $this->postJson(self::ENDPOINT, [
'oid' => $order->order_number,
'price' => 10000,
]);
$response->assertStatus(422)
->assertJsonPath('errors.message.0', 'Payment currency is not chargeable.');
$order->refresh();
$this->assertEquals(OrderStatusEnum::PENDING_ORDER, $order->order_status);
$this->assertEquals(PaymentStatusEnum::READY, $order->payment->payment_status);
}
public function test_retry_restores_cancelled_kcp_failure_order(): void
{
$order = $this->createOrder(