chore(payment): NHN KCP와 NICE 결제 플러그인 개발 브랜치 분리
정식 develop에서는 기본 번들 정책에 따라 제거된 결제 플러그인을 별도 개발 브랜치에서 계속 유지보수할 수 있도록 복원한다.
This commit is contained in:
1 parent
49b21e788c
commit
657f546efc
651 files changed
+49118
-20476
No files matched your search
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayNicepayments\Tests\Feature\Controllers;
|
||||
|
||||
use Modules\Sirsoft\Ecommerce\Database\Factories\OrderFactory;
|
||||
use Modules\Sirsoft\Ecommerce\Database\Factories\OrderPaymentFactory;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\OrderStatusEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\PaymentMethodEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\PaymentStatusEnum;
|
||||
use Plugins\Sirsoft\PayNicepayments\Services\NicePaymentsApiService;
|
||||
use Plugins\Sirsoft\PayNicepayments\Tests\PluginTestCase;
|
||||
|
||||
class AdminEscrowControllerTest extends PluginTestCase
|
||||
{
|
||||
private const TID = 'NICE_ESCROW_TID_001';
|
||||
|
||||
public function test_register_delivery_requires_bound_escrow_payment_and_restores_credentials(): void
|
||||
{
|
||||
$admin = $this->createAdminUser(['sirsoft-ecommerce.orders.update']);
|
||||
$this->createPaidEscrowPayment();
|
||||
|
||||
$apiServiceMock = $this->createMock(NicePaymentsApiService::class);
|
||||
$apiServiceMock->expects($this->once())
|
||||
->method('useStoredCredentials')
|
||||
->with(false, 'SRLIVE001');
|
||||
$apiServiceMock->expects($this->once())
|
||||
->method('registerEscrowDelivery')
|
||||
->with(
|
||||
self::TID,
|
||||
'CJ대한통운',
|
||||
'TRACK123456',
|
||||
'서울시 테스트구 1',
|
||||
'운영자',
|
||||
)
|
||||
->willReturn([
|
||||
'ResultCode' => 'C000',
|
||||
'ResultMsg' => '정상처리',
|
||||
]);
|
||||
$this->app->instance(NicePaymentsApiService::class, $apiServiceMock);
|
||||
|
||||
$response = $this->actingAs($admin)->postJson('/api/plugins/sirsoft-pay_nicepayments/admin/escrow/register-delivery', [
|
||||
'tid' => self::TID,
|
||||
'delivery_name' => 'CJ대한통운',
|
||||
'tracking_number' => 'TRACK123456',
|
||||
'buyer_address' => '서울시 테스트구 1',
|
||||
'register_name' => '운영자',
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('success', true)
|
||||
->assertJsonPath('data.ResultCode', 'C000');
|
||||
}
|
||||
|
||||
public function test_register_delivery_rejects_unbound_tid_before_api_call(): void
|
||||
{
|
||||
$admin = $this->createAdminUser(['sirsoft-ecommerce.orders.update']);
|
||||
$this->createPaidEscrowPayment();
|
||||
|
||||
$apiServiceMock = $this->createMock(NicePaymentsApiService::class);
|
||||
$apiServiceMock->expects($this->never())->method('useStoredCredentials');
|
||||
$apiServiceMock->expects($this->never())->method('registerEscrowDelivery');
|
||||
$this->app->instance(NicePaymentsApiService::class, $apiServiceMock);
|
||||
|
||||
$response = $this->actingAs($admin)->postJson('/api/plugins/sirsoft-pay_nicepayments/admin/escrow/register-delivery', [
|
||||
'tid' => 'ATTACKER_SUPPLIED_TID',
|
||||
'delivery_name' => 'CJ대한통운',
|
||||
'tracking_number' => 'TRACK123456',
|
||||
'buyer_address' => '서울시 테스트구 1',
|
||||
'register_name' => '운영자',
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonPath('success', false);
|
||||
}
|
||||
|
||||
private function createPaidEscrowPayment(): void
|
||||
{
|
||||
$order = OrderFactory::new()->create([
|
||||
'order_status' => OrderStatusEnum::PAYMENT_COMPLETE,
|
||||
'subtotal_amount' => 30000,
|
||||
'total_amount' => 30000,
|
||||
'total_due_amount' => 0,
|
||||
'total_paid_amount' => 30000,
|
||||
'paid_at' => now(),
|
||||
]);
|
||||
|
||||
OrderPaymentFactory::new()->forOrder($order)->create([
|
||||
'payment_status' => PaymentStatusEnum::PAID,
|
||||
'payment_method' => PaymentMethodEnum::CARD,
|
||||
'pg_provider' => 'nicepayments',
|
||||
'is_escrow' => true,
|
||||
'paid_amount_local' => 30000,
|
||||
'paid_at' => now(),
|
||||
'transaction_id' => self::TID,
|
||||
'payment_meta' => [
|
||||
'mid' => 'SRLIVE001',
|
||||
'is_test_mode' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user