|
|
@@ -37,8 +37,8 @@ class PayPlusLogicTest extends TestCase
|
|
|
$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']);
|
|
|
+ $this->assertSame('user', $payload['account_info']['first_name']);
|
|
|
+ $this->assertSame('user', $payload['account_info']['last_name']);
|
|
|
}
|
|
|
|
|
|
/** @test */
|
|
|
@@ -58,4 +58,75 @@ class PayPlusLogicTest extends TestCase
|
|
|
'data' => ['order_status' => 4],
|
|
|
]));
|
|
|
}
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function it_confirms_successful_notify_with_order_query()
|
|
|
+ {
|
|
|
+ $service = new FakePayPlusForPayinQuery([
|
|
|
+ 'decryptedComponentDelta' => [
|
|
|
+ 'order_status' => 3,
|
|
|
+ 'event_detail_name' => 'payment_captured',
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $logic = new PayPlusLogic($service);
|
|
|
+
|
|
|
+ $this->assertTrue($logic->confirmSuccessfulPayment([
|
|
|
+ 'event' => 'PAYMENT.CAPTURE.COMPLETED',
|
|
|
+ 'event_detail_name' => 'payment_captured',
|
|
|
+ 'data' => [
|
|
|
+ 'platform_order_id' => 'P100',
|
|
|
+ 'order_id' => 'O100',
|
|
|
+ 'order_status' => 3,
|
|
|
+ ],
|
|
|
+ ]));
|
|
|
+
|
|
|
+ $this->assertSame('P100', $service->queriedPlatformOrderId);
|
|
|
+ $this->assertSame('O100', $service->queriedOrderId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function it_rejects_successful_notify_when_order_query_is_not_successful()
|
|
|
+ {
|
|
|
+ $service = new FakePayPlusForPayinQuery([
|
|
|
+ 'decryptedComponentDelta' => [
|
|
|
+ 'order_status' => 4,
|
|
|
+ 'event_detail_name' => 'payment_declined',
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $logic = new PayPlusLogic($service);
|
|
|
+
|
|
|
+ $this->assertFalse($logic->confirmSuccessfulPayment([
|
|
|
+ 'event' => 'PAYMENT.CAPTURE.COMPLETED',
|
|
|
+ 'event_detail_name' => 'payment_captured',
|
|
|
+ 'data' => [
|
|
|
+ 'platform_order_id' => 'P100',
|
|
|
+ 'order_id' => 'O100',
|
|
|
+ 'order_status' => 3,
|
|
|
+ ],
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class FakePayPlusForPayinQuery extends PayPlus
|
|
|
+{
|
|
|
+ public $queriedPlatformOrderId;
|
|
|
+ public $queriedOrderId;
|
|
|
+
|
|
|
+ private $queryResult;
|
|
|
+
|
|
|
+ public function __construct(array $queryResult)
|
|
|
+ {
|
|
|
+ parent::__construct([]);
|
|
|
+ $this->queryResult = $queryResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function queryPayinOrder($platformOrderId, $orderId = '')
|
|
|
+ {
|
|
|
+ $this->queriedPlatformOrderId = $platformOrderId;
|
|
|
+ $this->queriedOrderId = $orderId;
|
|
|
+
|
|
|
+ return $this->queryResult;
|
|
|
+ }
|
|
|
}
|