| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace Tests\Unit;
- use App\Http\logic\api\PayPlusLogic;
- use App\Services\PayPlus;
- use Tests\TestCase;
- class PayPlusLogicTest extends TestCase
- {
- /** @test */
- public function it_builds_payment_payload_with_configured_method_mapping()
- {
- $service = new PayPlus([
- 'currency' => 'USD',
- 'return' => 'https://example.com/return',
- 'payment_methods' => [
- 1 => 8,
- 2 => 2,
- ],
- ]);
- $logic = new PayPlusLogic($service);
- $payload = $logic->buildPaymentPayload([
- 'order_sn' => 'P100',
- 'amount' => 12.34,
- 'user_id' => 10001,
- 'user_email' => 'user@example.com',
- 'user_phone' => '1234567890',
- 'user_name' => 'Nico Smith',
- 'buy_ip' => '8.8.8.8',
- 'pay_method' => 2,
- ]);
- $this->assertSame('P100', $payload['platform_order_id']);
- $this->assertSame('RECHARGE', $payload['order_type']);
- $this->assertSame('12.34', $payload['amount']);
- $this->assertSame(2, $payload['payment_method']);
- $this->assertSame('10001', $payload['account_info']['merchant_user_id']);
- $this->assertSame('Nico', $payload['account_info']['first_name']);
- $this->assertSame('Smith', $payload['account_info']['last_name']);
- }
- /** @test */
- public function it_maps_successful_capture_only_as_paid()
- {
- $logic = new PayPlusLogic(new PayPlus([]));
- $this->assertTrue($logic->isSuccessfulPayment([
- 'event' => 'PAYMENT.CAPTURE.COMPLETED',
- 'event_detail_name' => 'payment_captured',
- 'data' => ['order_status' => 3],
- ]));
- $this->assertFalse($logic->isSuccessfulPayment([
- 'event' => 'PAYMENT.CAPTURE.COMPLETED',
- 'event_detail_name' => 'payment_declined',
- 'data' => ['order_status' => 4],
- ]));
- }
- }
|