diff --git a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php index c2637081..ea7eea68 100644 --- a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php @@ -341,7 +341,8 @@ protected function preparePostPaymentOrder(array $order): array protected function prepareStatusOrder(array $order): array { return [ - 'id' => $order['id'], + 'id' => $order['id'], + 'transaction_id' => $order['transaction_id'] ?? null, ]; } diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php index 05053f6a..dfe56a2d 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php @@ -248,6 +248,16 @@ public function testCreate3DFormData(): void $this->assertEquals($expectedValue, $actualData); } + /** + * @dataProvider createStatusRequestDataDataProvider + */ + public function testCreateStatusRequestData(array $order, array $expectedData): void + { + $actual = $this->requestDataMapper->createStatusRequestData($this->account, $order); + + $this->assertSame($expectedData, $actual); + } + public function testCreateOrderHistoryRequestData(): void { $this->expectException(\Mews\Pos\Exceptions\NotImplementedException::class); @@ -260,6 +270,45 @@ public function testCreateHistoryRequestData(): void $this->requestDataMapper->createHistoryRequestData($this->account, []); } + public static function createStatusRequestDataDataProvider(): array + { + return [ + 'only_with_order_id' => [ + 'order' => [ + 'id' => 'order222', + ], + 'expected' => [ + 'MerchantCriteria' => [ + 'HostMerchantId' => '000000000111111', + 'MerchantPassword' => '3XTgER89as', + ], + 'TransactionCriteria' => [ + 'TransactionId' => '', + 'OrderId' => 'order222', + 'AuthCode' => '', + ], + ], + ], + 'with_order_id_and_tx_id' => [ + 'order' => [ + 'id' => 'order222', + 'transaction_id' => 'tx222', + ], + 'expected' => [ + 'MerchantCriteria' => [ + 'HostMerchantId' => '000000000111111', + 'MerchantPassword' => '3XTgER89as', + ], + 'TransactionCriteria' => [ + 'TransactionId' => 'tx222', + 'OrderId' => 'order222', + 'AuthCode' => '', + ], + ], + ], + ]; + } + /** * @return array */