diff --git a/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php index 754b3301..e72a4bde 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php @@ -536,457 +536,466 @@ public static function threeDHostPaymentDataProvider(): array ]; } - - public static function statusResponseDataProvider(): array + public static function statusResponseDataProvider(): \Generator { - return [ - 'success_pay' => [ - 'responseData' => [ - 'TransactionType' => 1, - 'CreateDate' => '20240120005007', - 'OrderId' => '202401199AAA', - 'BankResponseCode' => '00', - 'BankResponseMessage' => null, - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 101, - 'Currency' => 949, - 'InstallmentCount' => 0, - 'ClientId' => 1000000494, - 'CardNo' => '41595600****7732', - 'RequestStatus' => 1, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 98, - 'MerchantCommissionAmount' => 3, - 'MerchantCommissionRate' => 3, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => '', - ], - 'expectedData' => [ - 'order_id' => '202401199AAA', - 'auth_code' => null, - 'proc_return_code' => '00', - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20240120005007'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => '41595600****7732', - 'order_status' => 'PAYMENT_COMPLETED', - 'transaction_type' => 'pay', - 'capture_amount' => 1.01, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => true, - 'currency' => 'TRY', - 'first_amount' => 1.01, - 'capture_time' => new \DateTimeImmutable('20240120005007'), - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 0, - ], + $txTime = new \DateTimeImmutable('20240120005007'); + yield 'success_pay' => [ + 'responseData' => [ + 'TransactionType' => 1, + 'CreateDate' => '20240120005007', + 'OrderId' => '202401199AAA', + 'BankResponseCode' => '00', + 'BankResponseMessage' => null, + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 101, + 'Currency' => 949, + 'InstallmentCount' => 0, + 'ClientId' => 1000000494, + 'CardNo' => '41595600****7732', + 'RequestStatus' => 1, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 98, + 'MerchantCommissionAmount' => 3, + 'MerchantCommissionRate' => 3, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => '', ], - 'success_pre_pay_then_cancel' => [ - 'responseData' => [ - 'TransactionType' => 2, - 'CreateDate' => '20231205224003', - 'OrderId' => '20231205D497', - 'BankResponseCode' => '00', - 'BankResponseMessage' => null, - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 101, - 'Currency' => 949, - 'InstallmentCount' => 0, - 'ClientId' => 1000000494, - 'CardNo' => '41595600****7732', - 'RequestStatus' => 2, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 101, - 'MerchantCommissionAmount' => 0, - 'MerchantCommissionRate' => null, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => null, - ], - 'expectedData' => [ - 'order_id' => '20231205D497', - 'auth_code' => null, - 'proc_return_code' => '00', - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20231205224003'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => '41595600****7732', - 'order_status' => 'CANCELED', - 'transaction_type' => 'pre', - 'capture_amount' => 1.01, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => true, - 'currency' => 'TRY', - 'first_amount' => 1.01, - 'capture_time' => new \DateTimeImmutable('20231205224003'), - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 0, - ], + 'expectedData' => [ + 'order_id' => '202401199AAA', + 'auth_code' => null, + 'proc_return_code' => '00', + 'transaction_id' => null, + 'transaction_time' => $txTime, + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => '41595600****7732', + 'order_status' => 'PAYMENT_COMPLETED', + 'transaction_type' => 'pay', + 'capture_amount' => 1.01, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => true, + 'currency' => 'TRY', + 'first_amount' => 1.01, + 'capture_time' => $txTime, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 0, ], - 'success_waiting_for_3d_auth' => [ - 'responseData' => [ - 'TransactionType' => 1, - 'CreateDate' => '20231204002334', - 'OrderId' => '20231203CA6D', - 'BankResponseCode' => null, - 'BankResponseMessage' => null, - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 101, - 'Currency' => 949, - 'InstallmentCount' => 0, - 'ClientId' => 1000000494, - 'CardNo' => null, - 'RequestStatus' => 10, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 101, - 'MerchantCommissionAmount' => 0, - 'MerchantCommissionRate' => null, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => '', - ], - 'expectedData' => [ - 'order_id' => '20231203CA6D', - 'auth_code' => null, - 'proc_return_code' => null, - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20231204002334'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => null, - 'order_status' => 10, - 'transaction_type' => 'pay', - 'capture_amount' => null, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => null, - 'currency' => 'TRY', - 'first_amount' => 1.01, - 'capture_time' => null, - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 0, - ], + ]; + + $txTime = new \DateTimeImmutable('20231205224003'); + yield 'success_pre_pay_then_cancel' => [ + 'responseData' => [ + 'TransactionType' => 2, + 'CreateDate' => '20231205224003', + 'OrderId' => '20231205D497', + 'BankResponseCode' => '00', + 'BankResponseMessage' => null, + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 101, + 'Currency' => 949, + 'InstallmentCount' => 0, + 'ClientId' => 1000000494, + 'CardNo' => '41595600****7732', + 'RequestStatus' => 2, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 101, + 'MerchantCommissionAmount' => 0, + 'MerchantCommissionRate' => null, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => null, ], - 'success_pre_auth' => [ - 'responseData' => [ - 'TransactionType' => 2, - 'CreateDate' => '20240119230959', - 'OrderId' => '202401196E94', - 'BankResponseCode' => '00', - 'BankResponseMessage' => '', - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 101, - 'Currency' => 949, - 'InstallmentCount' => 0, - 'ClientId' => 1000000494, - 'CardNo' => '41595600****7732', - 'RequestStatus' => 1, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 98, - 'MerchantCommissionAmount' => 3, - 'MerchantCommissionRate' => 3, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => '', - ], - 'expectedData' => [ - 'order_id' => '202401196E94', - 'auth_code' => null, - 'proc_return_code' => '00', - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20240119230959'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => '41595600****7732', - 'order_status' => 'PAYMENT_COMPLETED', - 'transaction_type' => 'pre', - 'capture_amount' => 1.01, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => true, - 'currency' => 'TRY', - 'first_amount' => 1.01, - 'capture_time' => new \DateTimeImmutable('20240119230959'), - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 0, - ], + 'expectedData' => [ + 'order_id' => '20231205D497', + 'auth_code' => null, + 'proc_return_code' => '00', + 'transaction_id' => null, + 'transaction_time' => $txTime, + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => '41595600****7732', + 'order_status' => 'CANCELED', + 'transaction_type' => 'pre', + 'capture_amount' => 1.01, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => true, + 'currency' => 'TRY', + 'first_amount' => 1.01, + 'capture_time' => $txTime, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 0, ], - 'success_pre_auth_then_post_auth' => [ - 'responseData' => [ - 'TransactionType' => 2, - 'CreateDate' => '20231210132528', - 'OrderId' => '20231210A7D0', - 'BankResponseCode' => '00', - 'BankResponseMessage' => null, - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 101, - 'Currency' => 949, - 'InstallmentCount' => 2, - 'ClientId' => 1000000494, - 'CardNo' => '41595600****7732', - 'RequestStatus' => 5, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 101, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 101, - 'MerchantCommissionAmount' => 0, - 'MerchantCommissionRate' => null, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => null, - ], - 'expectedData' => [ - 'order_id' => '20231210A7D0', - 'auth_code' => null, - 'proc_return_code' => '00', - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20231210132528'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => '41595600****7732', - 'order_status' => 'PRE_AUTH_COMPLETED', - 'transaction_type' => 'pre', - 'capture_amount' => 1.01, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => true, - 'currency' => 'TRY', - 'first_amount' => 1.01, - 'capture_time' => new \DateTimeImmutable('20231210132528'), - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 2, - ], + ]; + + yield 'fail_waiting_for_3d_auth' => [ + 'responseData' => [ + 'TransactionType' => 1, + 'CreateDate' => '20231204002334', + 'OrderId' => '20231203CA6D', + 'BankResponseCode' => null, + 'BankResponseMessage' => null, + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 101, + 'Currency' => 949, + 'InstallmentCount' => 0, + 'ClientId' => 1000000494, + 'CardNo' => null, + 'RequestStatus' => 10, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 101, + 'MerchantCommissionAmount' => 0, + 'MerchantCommissionRate' => null, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => '', ], - 'success_pay_and_partial_refund' => [ - 'responseData' => [ - 'TransactionType' => 1, - 'CreateDate' => '20240120005901', - 'OrderId' => '20240119E16A', - 'BankResponseCode' => '00', - 'BankResponseMessage' => null, - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 101, - 'Currency' => 949, - 'InstallmentCount' => 0, - 'ClientId' => 1000000494, - 'CardNo' => '41595600****7732', - 'RequestStatus' => 3, - 'RefundedAmount' => 59, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 98, - 'MerchantCommissionAmount' => 3, - 'MerchantCommissionRate' => 3, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => '', - ], - 'expectedData' => [ - 'order_id' => '20240119E16A', - 'auth_code' => null, - 'proc_return_code' => '00', - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20240120005901'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => '41595600****7732', - 'order_status' => 'PARTIALLY_REFUNDED', - 'transaction_type' => 'pay', - 'capture_amount' => 1.01, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => true, - 'currency' => 'TRY', - 'first_amount' => 1.01, - 'capture_time' => new \DateTimeImmutable('20240120005901'), - 'cancel_time' => null, - 'refund_amount' => 0.59, - 'refund_time' => null, - 'installment_count' => 0, - ], + 'expectedData' => [ + 'order_id' => '20231203CA6D', + 'auth_code' => null, + 'proc_return_code' => null, + 'transaction_id' => null, + 'transaction_time' => new \DateTimeImmutable('20231204002334'), + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => null, + 'order_status' => 10, + 'transaction_type' => 'pay', + 'capture_amount' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => null, + 'currency' => 'TRY', + 'first_amount' => 1.01, + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 0, ], - 'fail_order_not_found' => [ - 'responseData' => [ - 'TransactionType' => 0, - 'CreateDate' => null, - 'OrderId' => null, - 'BankResponseCode' => null, - 'BankResponseMessage' => null, - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 0, - 'Currency' => 0, - 'InstallmentCount' => 0, - 'ClientId' => 0, - 'CardNo' => null, - 'RequestStatus' => 0, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 0, - 'MerchantCommissionAmount' => 0, - 'MerchantCommissionRate' => null, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => null, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => '', - ], - 'expectedData' => [ - 'order_id' => null, - 'auth_code' => null, - 'proc_return_code' => null, - 'transaction_id' => null, - 'transaction_time' => null, - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => null, - 'order_status' => 'ERROR', - 'transaction_type' => null, - 'capture_amount' => null, - 'capture_time' => null, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => null, - 'currency' => null, - 'first_amount' => null, - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 0, - ], + ]; + + $txTime = new \DateTimeImmutable('20240119230959'); + yield 'success_pre_auth' => [ + 'responseData' => [ + 'TransactionType' => 2, + 'CreateDate' => '20240119230959', + 'OrderId' => '202401196E94', + 'BankResponseCode' => '00', + 'BankResponseMessage' => '', + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 101, + 'Currency' => 949, + 'InstallmentCount' => 0, + 'ClientId' => 1000000494, + 'CardNo' => '41595600****7732', + 'RequestStatus' => 1, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 98, + 'MerchantCommissionAmount' => 3, + 'MerchantCommissionRate' => 3, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => '', ], - 'fail_unsuccessful_payment' => [ - 'responseData' => [ - 'TransactionType' => 2, - 'CreateDate' => '20240119231357', - 'OrderId' => '202401195754', - 'BankResponseCode' => 'MD:0', - 'BankResponseMessage' => '', - 'AuthCode' => null, - 'HostReferenceNumber' => null, - 'Amount' => 200, - 'Currency' => 949, - 'InstallmentCount' => 0, - 'ClientId' => 1000000494, - 'CardNo' => '41595600****7732', - 'RequestStatus' => 0, - 'RefundedAmount' => 0, - 'PostAuthedAmount' => 0, - 'TransactionId' => 0, - 'CommissionStatus' => null, - 'NetAmount' => 200, - 'MerchantCommissionAmount' => 0, - 'MerchantCommissionRate' => null, - 'CardBankId' => 0, - 'CardTypeId' => 0, - 'ValorDate' => 0, - 'TransactionDate' => 0, - 'BankValorDate' => 0, - 'ExtraParameters' => null, - 'Code' => 0, - 'Message' => '', - ], - 'expectedData' => [ - 'order_id' => '202401195754', - 'auth_code' => null, - 'proc_return_code' => 'MD:0', - 'transaction_id' => null, - 'transaction_time' => new \DateTimeImmutable('20240119231357'), - 'error_message' => null, - 'ref_ret_num' => null, - 'masked_number' => '41595600****7732', - 'order_status' => 'ERROR', - 'transaction_type' => 'pre', - 'capture_amount' => null, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => null, - 'currency' => 'TRY', - 'first_amount' => 2.0, - 'capture_time' => null, - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => 0, - ], + 'expectedData' => [ + 'order_id' => '202401196E94', + 'auth_code' => null, + 'proc_return_code' => '00', + 'transaction_id' => null, + 'transaction_time' => $txTime, + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => '41595600****7732', + 'order_status' => 'PAYMENT_COMPLETED', + 'transaction_type' => 'pre', + 'capture_amount' => 1.01, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => true, + 'currency' => 'TRY', + 'first_amount' => 1.01, + 'capture_time' => $txTime, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 0, + ], + ]; + + $txTime = new \DateTimeImmutable('20231210132528'); + yield 'success_pre_auth_then_post_auth' => [ + 'responseData' => [ + 'TransactionType' => 2, + 'CreateDate' => '20231210132528', + 'OrderId' => '20231210A7D0', + 'BankResponseCode' => '00', + 'BankResponseMessage' => null, + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 101, + 'Currency' => 949, + 'InstallmentCount' => 2, + 'ClientId' => 1000000494, + 'CardNo' => '41595600****7732', + 'RequestStatus' => 5, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 101, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 101, + 'MerchantCommissionAmount' => 0, + 'MerchantCommissionRate' => null, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => null, + ], + 'expectedData' => [ + 'order_id' => '20231210A7D0', + 'auth_code' => null, + 'proc_return_code' => '00', + 'transaction_id' => null, + 'transaction_time' => $txTime, + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => '41595600****7732', + 'order_status' => 'PRE_AUTH_COMPLETED', + 'transaction_type' => 'pre', + 'capture_amount' => 1.01, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => true, + 'currency' => 'TRY', + 'first_amount' => 1.01, + 'capture_time' => $txTime, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 2, + ], + ]; + + $txTime = new \DateTimeImmutable('20240120005901'); + yield 'success_pay_and_partial_refund' => [ + 'responseData' => [ + 'TransactionType' => 1, + 'CreateDate' => '20240120005901', + 'OrderId' => '20240119E16A', + 'BankResponseCode' => '00', + 'BankResponseMessage' => null, + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 101, + 'Currency' => 949, + 'InstallmentCount' => 0, + 'ClientId' => 1000000494, + 'CardNo' => '41595600****7732', + 'RequestStatus' => 3, + 'RefundedAmount' => 59, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 98, + 'MerchantCommissionAmount' => 3, + 'MerchantCommissionRate' => 3, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => '', + ], + 'expectedData' => [ + 'order_id' => '20240119E16A', + 'auth_code' => null, + 'proc_return_code' => '00', + 'transaction_id' => null, + 'transaction_time' => $txTime, + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => '41595600****7732', + 'order_status' => 'PARTIALLY_REFUNDED', + 'transaction_type' => 'pay', + 'capture_amount' => 1.01, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => true, + 'currency' => 'TRY', + 'first_amount' => 1.01, + 'capture_time' => $txTime, + 'cancel_time' => null, + 'refund_amount' => 0.59, + 'refund_time' => null, + 'installment_count' => 0, + ], + ]; + + yield 'fail_order_not_found' => [ + 'responseData' => [ + 'TransactionType' => 0, + 'CreateDate' => null, + 'OrderId' => null, + 'BankResponseCode' => null, + 'BankResponseMessage' => null, + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 0, + 'Currency' => 0, + 'InstallmentCount' => 0, + 'ClientId' => 0, + 'CardNo' => null, + 'RequestStatus' => 0, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 0, + 'MerchantCommissionAmount' => 0, + 'MerchantCommissionRate' => null, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => null, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => '', + ], + 'expectedData' => [ + 'order_id' => null, + 'auth_code' => null, + 'proc_return_code' => null, + 'transaction_id' => null, + 'transaction_time' => null, + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => null, + 'order_status' => 'ERROR', + 'transaction_type' => null, + 'capture_amount' => null, + 'capture_time' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => null, + 'currency' => null, + 'first_amount' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 0, + ], + ]; + + yield 'fail_unsuccessful_payment' => [ + 'responseData' => [ + 'TransactionType' => 2, + 'CreateDate' => '20240119231357', + 'OrderId' => '202401195754', + 'BankResponseCode' => 'MD:0', + 'BankResponseMessage' => '', + 'AuthCode' => null, + 'HostReferenceNumber' => null, + 'Amount' => 200, + 'Currency' => 949, + 'InstallmentCount' => 0, + 'ClientId' => 1000000494, + 'CardNo' => '41595600****7732', + 'RequestStatus' => 0, + 'RefundedAmount' => 0, + 'PostAuthedAmount' => 0, + 'TransactionId' => 0, + 'CommissionStatus' => null, + 'NetAmount' => 200, + 'MerchantCommissionAmount' => 0, + 'MerchantCommissionRate' => null, + 'CardBankId' => 0, + 'CardTypeId' => 0, + 'ValorDate' => 0, + 'TransactionDate' => 0, + 'BankValorDate' => 0, + 'ExtraParameters' => null, + 'Code' => 0, + 'Message' => '', + ], + 'expectedData' => [ + 'order_id' => '202401195754', + 'auth_code' => null, + 'proc_return_code' => 'MD:0', + 'transaction_id' => null, + 'transaction_time' => new \DateTimeImmutable('20240119231357'), + 'error_message' => null, + 'ref_ret_num' => null, + 'masked_number' => '41595600****7732', + 'order_status' => 'ERROR', + 'transaction_type' => 'pre', + 'capture_amount' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => null, + 'currency' => 'TRY', + 'first_amount' => 2.0, + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => 0, ], ]; } diff --git a/tests/Unit/Gateways/ToslaPosTest.php b/tests/Unit/Gateways/ToslaPosTest.php index 88f9e06f..a5b38f63 100644 --- a/tests/Unit/Gateways/ToslaPosTest.php +++ b/tests/Unit/Gateways/ToslaPosTest.php @@ -570,13 +570,14 @@ public function testOrderHistory( public static function statusDataProvider(): iterable { + $statusResponses = iterator_to_array(ToslaPosResponseDataMapperTest::statusResponseDataProvider()); yield [ 'order' => ToslaPosRequestDataMapperTest::statusRequestDataProvider()[0]['order'], 'requestData' => ToslaPosRequestDataMapperTest::statusRequestDataProvider()[0]['expected'], 'encodedRequestData' => \json_encode(ToslaPosRequestDataMapperTest::statusRequestDataProvider()[0]['expected'], JSON_THROW_ON_ERROR), - 'responseData' => \json_encode(ToslaPosResponseDataMapperTest::statusResponseDataProvider()['success_pay']['responseData'], JSON_THROW_ON_ERROR), - 'decodedResponseData' => ToslaPosResponseDataMapperTest::statusResponseDataProvider()['success_pay']['responseData'], - 'mappedResponse' => ToslaPosResponseDataMapperTest::statusResponseDataProvider()['success_pay']['expectedData'], + 'responseData' => \json_encode($statusResponses['success_pay']['responseData'], JSON_THROW_ON_ERROR), + 'decodedResponseData' => $statusResponses['success_pay']['responseData'], + 'mappedResponse' => $statusResponses['success_pay']['expectedData'], 'isSuccess' => true, ]; }