From 0bdaefaee181577146c656cb2600266c4c692b38 Mon Sep 17 00:00:00 2001 From: mustapayev Date: Sun, 5 Jan 2025 17:41:33 +0100 Subject: [PATCH] param integration initial --- config/pos_test.php | 2 +- examples/_common-codes/regular/cancel.php | 4 + examples/_common-codes/regular/history.php | 13 + examples/_common-codes/regular/post-auth.php | 2 + examples/_main_config.php | 1 + examples/parampos/3d-host/_config.php | 13 +- examples/parampos/3d-pay/_config.php | 22 - examples/parampos/3d-pay/form.php | 3 - examples/parampos/3d-pay/index.php | 3 - examples/parampos/3d-pay/response.php | 3 - examples/parampos/_payment_config.php | 18 +- examples/parampos/regular/_config.php | 12 +- examples/parampos/regular/custom_query.php | 17 +- examples/parampos/regular/status.php | 3 + src/Crypt/ParamPosCrypt.php | 35 +- .../ParamPosRequestDataMapper.php | 329 ++- .../ParamPosResponseDataMapper.php | 439 ++-- src/Gateways/AbstractGateway.php | 2 +- src/Gateways/ParamPos.php | 256 +-- src/Serializer/ParamPosSerializer.php | 11 +- tests/Functional/ParamPosTest.php | 17 +- .../ParamPosResponseDataMapperTest.php | 1762 +++++++++-------- .../Serializer/ParamPosSerializerTest.php | 11 +- .../3d_host_form_response_success.xml | 15 + .../status_pay_then_cancel_response.json | 30 + .../status_pay_then_refund_response.json | 30 + .../parampos/status_post_pay_response.json | 30 + .../parampos/status_pre_pay_response.json | 30 + .../status_pre_pay_then_cancel_response.json | 30 + 29 files changed, 1641 insertions(+), 1502 deletions(-) delete mode 100644 examples/parampos/3d-pay/_config.php delete mode 100644 examples/parampos/3d-pay/form.php delete mode 100644 examples/parampos/3d-pay/index.php delete mode 100644 examples/parampos/3d-pay/response.php create mode 100644 examples/parampos/regular/status.php create mode 100644 tests/Unit/test_data/parampos/3d_host_form_response_success.xml create mode 100644 tests/Unit/test_data/parampos/status_pay_then_cancel_response.json create mode 100644 tests/Unit/test_data/parampos/status_pay_then_refund_response.json create mode 100644 tests/Unit/test_data/parampos/status_post_pay_response.json create mode 100644 tests/Unit/test_data/parampos/status_pre_pay_response.json create mode 100644 tests/Unit/test_data/parampos/status_pre_pay_then_cancel_response.json diff --git a/config/pos_test.php b/config/pos_test.php index 09d5636a..01c92514 100644 --- a/config/pos_test.php +++ b/config/pos_test.php @@ -17,8 +17,8 @@ 'gateway_endpoints' => [ //'payment_api' => 'https://testposws.param.com.tr/turkpos.ws/service_turkpos_prod.asmx', //'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx?wsdl', - // 'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx?wsdl', 'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx', //xml + 'gateway_3d_host' => 'https://test-pos.param.com.tr/default.aspx', //'payment_api' => 'https://test-dmz.param.com.tr:4443/turkpos.ws/service_turkpos_test.asmx?WSDL', //prod: 'payment_api' => 'https://posws.param.com.tr/turkpos.ws/service_turkpos_prod.asmx?wsdl', ], diff --git a/examples/_common-codes/regular/cancel.php b/examples/_common-codes/regular/cancel.php index 215a9360..65332e52 100644 --- a/examples/_common-codes/regular/cancel.php +++ b/examples/_common-codes/regular/cancel.php @@ -22,6 +22,10 @@ function createCancelOrder(string $gatewayClass, array $lastResponse, string $ip if (\Mews\Pos\Gateways\GarantiPos::class === $gatewayClass) { $cancelOrder['amount'] = $lastResponse['amount']; + } elseif (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) { + $cancelOrder['amount'] = $lastResponse['amount']; + // on otorizasyon islemin iptali icin PosInterface::TX_TYPE_PAY_PRE_AUTH saglanmasi gerekiyor + $cancelOrder['transaction_type'] = $lastResponse['transaction_type'] ?? PosInterface::TX_TYPE_PAY_AUTH; } elseif (\Mews\Pos\Gateways\KuveytPos::class === $gatewayClass) { $cancelOrder['remote_order_id'] = $lastResponse['remote_order_id']; // banka tarafındaki order id $cancelOrder['auth_code'] = $lastResponse['auth_code']; diff --git a/examples/_common-codes/regular/history.php b/examples/_common-codes/regular/history.php index 03fa8466..52690c4d 100644 --- a/examples/_common-codes/regular/history.php +++ b/examples/_common-codes/regular/history.php @@ -46,6 +46,19 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip): // ya da batch number ile (batch number odeme isleminden alinan response'da bulunur): // $order = [ // 'batch_num' => 24, +// ]; + } elseif (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) { + $order = [ + // Gün aralığı 1 günden fazla girilemez + 'start_date' => $txTime->modify('-23 hour'), + 'end_date' => $txTime, + // optional: + 'transaction_type' => \Mews\Pos\PosInterface::TX_TYPE_PAY_AUTH, // TX_TYPE_CANCEL, TX_TYPE_REFUND + 'order_status' => 'Başarılı', // Başarılı, Başarısız + ]; +// ya da batch number ile (batch number odeme isleminden alinan response'da bulunur): +// $order = [ +// 'batch_num' => 24, // ]; } diff --git a/examples/_common-codes/regular/post-auth.php b/examples/_common-codes/regular/post-auth.php index 11bd2eb2..44d5832c 100644 --- a/examples/_common-codes/regular/post-auth.php +++ b/examples/_common-codes/regular/post-auth.php @@ -43,6 +43,8 @@ function createPostPayOrder(string $gatewayClass, array $lastResponse, string $i $postAuthAmount ); +dump($order); + $transaction = PosInterface::TX_TYPE_PAY_POST_AUTH; require '../../_templates/_finish_non_secure_post_auth_payment.php'; diff --git a/examples/_main_config.php b/examples/_main_config.php index f42465dc..bb5d7f71 100644 --- a/examples/_main_config.php +++ b/examples/_main_config.php @@ -141,6 +141,7 @@ function createPaymentOrder( PosInterface::MODEL_3D_PAY, PosInterface::MODEL_3D_HOST, PosInterface::MODEL_3D_PAY_HOSTING, + PosInterface::MODEL_NON_SECURE, //todo ], true)) { $order['success_url'] = $baseUrl.'response.php'; $order['fail_url'] = $baseUrl.'response.php'; diff --git a/examples/parampos/3d-host/_config.php b/examples/parampos/3d-host/_config.php index 04469014..d4ece4bc 100644 --- a/examples/parampos/3d-host/_config.php +++ b/examples/parampos/3d-host/_config.php @@ -6,14 +6,15 @@ $baseUrl = $bankTestsUrl.'/3d-host/'; //account bilgileri kendi account bilgilerinizle degistiriniz -$account = \Mews\Pos\Factory\AccountFactory::createAkbankPosAccount( - 'akbank-pos', - '2023090417500272654BD9A49CF07574', - '2023090417500284633D137A249DBBEB', - '3230323330393034313735303032363031353172675f357637355f3273387373745f7233725f73323333383737335f323272383774767276327672323531355f', - PosInterface::LANG_TR +$account = \Mews\Pos\Factory\AccountFactory::createParamPosAccount( + 'param-pos', + 10738, + 'Test', + 'Test', + '0C13D406-873B-403B-9C09-A5766840D98C' ); + $pos = getGateway($account, $eventDispatcher); $transaction = PosInterface::TX_TYPE_PAY_AUTH; diff --git a/examples/parampos/3d-pay/_config.php b/examples/parampos/3d-pay/_config.php deleted file mode 100644 index 7f5a9b87..00000000 --- a/examples/parampos/3d-pay/_config.php +++ /dev/null @@ -1,22 +0,0 @@ -get('tx', PosInterface::TX_TYPE_PAY_AUTH); - -$templateTitle = '3D Pay Model Payment'; -$paymentModel = PosInterface::MODEL_3D_PAY; diff --git a/examples/parampos/3d-pay/form.php b/examples/parampos/3d-pay/form.php deleted file mode 100644 index 361d8083..00000000 --- a/examples/parampos/3d-pay/form.php +++ /dev/null @@ -1,3 +0,0 @@ - [ - 'number' => '4446763125813623', + 'number' => '5818775818772285', 'year' => '26', 'month' => '12', - 'cvv' => '000', + 'cvv' => '001', 'name' => 'John Doe', ], +// 'visa1' => [ +// 'number' => '4508034508034509', +// 'year' => '26', +// 'month' => '12', +// 'cvv' => '000', +// 'name' => 'John Doe', +// ] +// 'visa1' => [ +// 'number' => '4446763125813623', +// 'year' => '26', +// 'month' => '12', +// 'cvv' => '000', +// 'name' => 'John Doe', +// ], ]; diff --git a/examples/parampos/regular/_config.php b/examples/parampos/regular/_config.php index 156929bf..58c60ffe 100644 --- a/examples/parampos/regular/_config.php +++ b/examples/parampos/regular/_config.php @@ -6,12 +6,12 @@ $baseUrl = $bankTestsUrl.'/regular/'; //account bilgileri kendi account bilgilerinizle degistiriniz -$account = \Mews\Pos\Factory\AccountFactory::createAkbankPosAccount( - 'akbank-pos', - '2023090417500272654BD9A49CF07574', - '2023090417500284633D137A249DBBEB', - '3230323330393034313735303032363031353172675f357637355f3273387373745f7233725f73323333383737335f323272383774767276327672323531355f', - PosInterface::LANG_TR +$account = \Mews\Pos\Factory\AccountFactory::createParamPosAccount( + 'param-pos', + 10738, + 'Test', + 'Test', + '0c13d406-873b-403b-9c09-a5766840d98c' ); $pos = getGateway($account, $eventDispatcher); diff --git a/examples/parampos/regular/custom_query.php b/examples/parampos/regular/custom_query.php index 0f504dac..6ecaea96 100644 --- a/examples/parampos/regular/custom_query.php +++ b/examples/parampos/regular/custom_query.php @@ -6,20 +6,9 @@ function getCustomRequestData(): array { return [ [ - 'txnCode' => '1020', - 'order' => [ - 'orderTrackId' => 'ae15a6c8-467e-45de-b24c-b98821a42667', - ], - 'payByLink' => [ - 'linkTxnCode' => '3000', - 'linkTransferType' => 'SMS', - 'mobilePhoneNumber' => '5321234567', - ], - 'transaction' => [ - 'amount' => 1.00, - 'currencyCode' => 949, - 'motoInd' => 0, - 'installCount' => 1, + // API hesap bilgileri kutuphane tarafindan otomatik eklenir. + 'TP_Ozel_Oran_Liste' => [ + '@xmlns' => 'https://turkpos.com.tr/', ], ], null, diff --git a/examples/parampos/regular/status.php b/examples/parampos/regular/status.php new file mode 100644 index 00000000..abbd0847 --- /dev/null +++ b/examples/parampos/regular/status.php @@ -0,0 +1,3 @@ +hashString($hashStr, self::HASH_ALGORITHM); } diff --git a/src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php index 2a023cc9..69cd8484 100644 --- a/src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php @@ -85,21 +85,18 @@ class ParamPosRequestDataMapper extends AbstractRequestDataMapper /** * {@inheritDoc} * - * @param array{UCD_MD: string, Islem_GUID: string, Siparis_ID: string, cavv: string, G: array{CLIENT_CODE: string, CLIENT_USERNAME: string, CLIENT_PASSWORD: string}} $responseData + * @param array{TP_WMD_Pay: array} $responseData */ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array $order, string $txType, array $responseData): array { $requestData = $this->getRequestAccountData($posAccount) + [ + '@xmlns' => 'https://turkpos.com.tr/', 'UCD_MD' => (string) $responseData['md'], 'Islem_GUID' => (string) $responseData['islemGUID'], 'Siparis_ID' => (string) $responseData['orderId'], ]; -// //todo -// if (isset($order['recurring'])) { -// $requestData += $this->createRecurringData($order['recurring']); -// } - return $requestData; + return ['TP_WMD_Pay' => $requestData]; } /** @@ -109,12 +106,16 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array * * @return array */ - public function create3DEnrollmentCheckRequestData(AbstractPosAccount $posAccount, array $order, CreditCardInterface $creditCard): array + public function create3DEnrollmentCheckRequestData(AbstractPosAccount $posAccount, array $order, ?CreditCardInterface $creditCard, string $txType, string $paymentModel): array { + if (PosInterface::MODEL_3D_HOST === $paymentModel) { + return $this->create3DHostEnrollmentCheckRequestData($posAccount, $order); + } $order = $this->preparePaymentOrder($order); $requestData = $this->getRequestAccountData($posAccount) + [ - 'Islem_Guvenlik_Tip' => $this->secureTypeMappings[PosInterface::MODEL_3D_SECURE], //todo + '@xmlns' => 'https://turkpos.com.tr/', + 'Islem_Guvenlik_Tip' => $this->secureTypeMappings[$paymentModel], 'Islem_ID' => $this->crypt->generateRandomString(), 'IPAdr' => (string) $order['ip'], 'Siparis_ID' => (string) $order['id'], @@ -137,15 +138,64 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $posAccoun $requestData['Doviz_Kodu'] = $this->mapCurrency($order['currency']); } - $requestData['Islem_Hash'] = $this->crypt->createHash($posAccount, $requestData); -// todo -// if (isset($order['recurring'])) { -// $requestData += $this->createRecurringData($order['recurring']); -// } + $soapAction = PosInterface::CURRENCY_TRY === $order['currency'] ? 'TP_WMD_UCD' : 'TP_Islem_Odeme_WD'; + if (PosInterface::TX_TYPE_PAY_PRE_AUTH === $txType) { + $soapAction = 'TP_Islem_Odeme_OnProv_WMD'; + } + + $requestData = [$soapAction => $requestData]; + + $requestData[$soapAction]['Islem_Hash'] = $this->crypt->createHash($posAccount, $requestData); return $requestData; } + public function create3DHostEnrollmentCheckRequestData(AbstractPosAccount $posAccount, array $order): array + { + $order = $this->preparePaymentOrder($order); + + $requestData = $this->getRequestAccountData($posAccount, PosInterface::MODEL_3D_HOST) + [ + // '@xmlns' => 'https://turkodeme.com.tr/', + '@xmlns' => 'https://turkpos.com.tr/', + 'Borclu_Tutar' => 'r|'.$this->formatAmount($order['amount']), + // Bu alan editable olsun istiyorsanız başına “e|”, readonly olsun istiyorsanız başına “r|” eklemelisiniz. + 'Borclu_Odeme_Tip' => 'r|Diğer', + 'Borclu_AdSoyad' => 'e|john doe', //todo + 'Borclu_Aciklama' => 'e|açıklama', //todo + 'Return_URL' => 'r|'.$order['success_url'], + 'Islem_ID' => $this->crypt->generateRandomString(), + 'Borclu_Kisi_TC' => '', + 'Borclu_GSM' => 'r|5555555555', + // = 0 ise tüm taksitler listelenir. > 0 ise sadece o taksit seçeneği listelenir. + //'Taksit' => $this->mapInstallment((int) $order['installment']), +// 'Islem_Guvenlik_Tip' => $this->secureTypeMappings[PosInterface::MODEL_3D_SECURE], +// 'IPAdr' => (string) $order['ip'], +// 'Siparis_ID' => (string) $order['id'], +// 'Toplam_Tutar' => $this->formatAmount($order['amount']), //todo +// 'Basarili_URL' => (string) $order['success_url'], +// 'Hata_URL' => (string) $order['fail_url'], +// 'KK_Sahibi' => $creditCard->getHolderName(), +// 'KK_No' => $creditCard->getNumber(), +// 'KK_SK_Ay' => $creditCard->getExpirationDate(self::CREDIT_CARD_EXP_MONTH_FORMAT), +// 'KK_SK_Yil' => $creditCard->getExpirationDate(self::CREDIT_CARD_EXP_YEAR_FORMAT), +// 'KK_CVC' => $creditCard->getCvv(), +// 'KK_Sahibi_GSM' => '', //optional olmasina ragmen hic gonderilmeyince hata aliniyor. + ]; + + if (PosInterface::CURRENCY_TRY === $order['currency']) { + $requestData['Taksit'] = $this->mapInstallment((int) $order['installment']); + } else { + $requestData['Doviz_Kodu'] = $this->mapCurrency($order['currency']); + } + + + //$soapAction = PosInterface::CURRENCY_TRY === $order['currency'] ? 'TP_WMD_UCD' : 'TP_Islem_Odeme_WD'; + $soapAction = 'TO_Pre_Encrypting_OOS'; + + return [$soapAction => $requestData]; + } + + //todo @@ -158,14 +208,15 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $posAccount $order = $this->preparePaymentOrder($order); $requestData = $this->getRequestAccountData($posAccount) + [ - 'Islem_Guvenlik_Tip' => $this->secureTypeMappings[PosInterface::MODEL_3D_SECURE], //todo + '@xmlns' => 'https://turkpos.com.tr/', + 'Islem_Guvenlik_Tip' => $this->secureTypeMappings[PosInterface::MODEL_NON_SECURE], 'Islem_ID' => $this->crypt->generateRandomString(), 'IPAdr' => (string) $order['ip'], 'Siparis_ID' => (string) $order['id'], 'Islem_Tutar' => $this->formatAmount($order['amount']), 'Toplam_Tutar' => $this->formatAmount($order['amount']), //todo - 'Basarili_URL' => (string) $order['success_url'], - 'Hata_URL' => (string) $order['fail_url'], +// 'Basarili_URL' => (string) $order['success_url'], +// 'Hata_URL' => (string) $order['fail_url'], 'Taksit' => $this->mapInstallment((int) $order['installment']), 'KK_Sahibi' => $creditCard->getHolderName(), 'KK_No' => $creditCard->getNumber(), @@ -181,11 +232,14 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $posAccount $requestData['Doviz_Kodu'] = $this->mapCurrency($order['currency']); } - $requestData['Islem_Hash'] = $this->crypt->createHash($posAccount, $requestData); -// todo -// if (isset($order['recurring'])) { -// $requestData += $this->createRecurringData($order['recurring']); -// } + $soapAction = PosInterface::CURRENCY_TRY === $order['currency'] ? 'TP_WMD_UCD' : 'TP_Islem_Odeme_WD'; + //$soapAction = 'TP_WMD_UCD'; + if (PosInterface::TX_TYPE_PAY_PRE_AUTH === $txType) { + $soapAction = 'TP_Islem_Odeme_OnProv_WMD'; + } + $requestData = [$soapAction => $requestData]; + + $requestData[$soapAction]['Islem_Hash'] = $this->crypt->createHash($posAccount, $requestData); return $requestData; } @@ -195,52 +249,37 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $posAccount /** * {@inheritDoc} * - * @return array{Type: string, OrderId: string, Name: string, Password: string, ClientId: string, Total: float|null} + * @return array{TP_Islem_Odeme_OnProv_Kapa: array} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $posAccount, array $order): array { $order = $this->preparePostPaymentOrder($order); $requestData = $this->getRequestAccountData($posAccount) + [ - 'Type' => $this->mapTxType(PosInterface::TX_TYPE_PAY_POST_AUTH), - 'OrderId' => (string) $order['id'], - 'Total' => isset($order['amount']) ? (float) $this->formatAmount($order['amount']) : null, + '@xmlns' => 'https://turkpos.com.tr/', + 'Prov_ID' => '', + 'Prov_Tutar' => $this->formatAmount($order['amount']), + 'Siparis_ID' => (string) $order['id'], ]; - if (isset($order['amount'], $order['pre_auth_amount']) && $order['pre_auth_amount'] < $order['amount']) { - // when amount < pre_auth_amount then we need to send PREAMT value - $requestData['Extra']['PREAMT'] = $order['pre_auth_amount']; - } - - return $requestData; + return ['TP_Islem_Odeme_OnProv_Kapa' => $requestData]; } - //todo - /** * {@inheritDoc} */ public function createStatusRequestData(AbstractPosAccount $posAccount, array $order): array { - $statusRequestData = $this->getRequestAccountData($posAccount) + [ - 'Extra' => [ - $this->mapTxType(PosInterface::TX_TYPE_STATUS) => 'QUERY', - ], - ]; - $order = $this->prepareStatusOrder($order); - if (isset($order['id'])) { - $statusRequestData['OrderId'] = $order['id']; - } elseif (isset($order['recurringId'])) { - $statusRequestData['Extra']['RECURRINGID'] = $order['recurringId']; - } + $requestData = $this->getRequestAccountData($posAccount) + [ + '@xmlns' => 'https://turkpos.com.tr/', + 'Siparis_ID' => $order['id'], + ]; - return $statusRequestData; + return ['TP_Islem_Sorgulama4' => $requestData]; } - //todo - /** * {@inheritDoc} */ @@ -248,81 +287,80 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o { $order = $this->prepareCancelOrder($order); - $orderData = []; - if (isset($order['recurringOrderInstallmentNumber'])) { - // this method cancels only pending recurring orders, it will not cancel already fulfilled transactions - $orderData['Extra']['RECORDTYPE'] = 'Order'; - // cancel single installment - $orderData['Extra']['RECURRINGOPERATION'] = 'Cancel'; - /** - * the order ids of recurring order installments: - * 'ORD_ID_1' => '202210121ABC', - * 'ORD_ID_2' => '202210121ABC-2', - * 'ORD_ID_3' => '202210121ABC-3', - * ... - */ - $orderData['Extra']['RECORDID'] = $order['id'].'-'.$order['recurringOrderInstallmentNumber']; - - return $this->getRequestAccountData($posAccount) + $orderData; - } + if (PosInterface::TX_TYPE_PAY_PRE_AUTH === $order['transaction_type']) { + $requestData = $this->getRequestAccountData($posAccount) + [ + '@xmlns' => 'https://turkpos.com.tr/', + 'Prov_ID' => null, + 'Siparis_ID' => $order['id'], + ]; - return $this->getRequestAccountData($posAccount) + [ - 'OrderId' => $order['id'], - 'Type' => $this->mapTxType(PosInterface::TX_TYPE_CANCEL), + return ['TP_Islem_Iptal_OnProv' => $requestData]; + } + $requestData = $this->getRequestAccountData($posAccount) + [ + '@xmlns' => 'https://turkpos.com.tr/', + 'Durum' => 'IPTAL', + 'Siparis_ID' => $order['id'], + 'Tutar' => $order['amount'], ]; + + return ['TP_Islem_Iptal_Iade_Kismi2' => $requestData]; } - //todo /** * {@inheritDoc} - * @return array{OrderId: string, Currency: string, Type: string, Total?: string, Name: string, Password: string, ClientId: string} */ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array { $order = $this->prepareRefundOrder($order); - $requestData = [ - 'OrderId' => (string) $order['id'], - 'Currency' => $this->mapCurrency($order['currency']), - 'Type' => $this->mapTxType($refundTxType), - ]; - - if (isset($order['amount'])) { - $requestData['Total'] = (string) $order['amount']; - } + $requestData = $this->getRequestAccountData($posAccount) + [ + '@xmlns' => 'https://turkpos.com.tr/', + 'Durum' => 'IADE', + 'Siparis_ID' => $order['id'], + 'Tutar' => $order['amount'], + ]; - return $this->getRequestAccountData($posAccount) + $requestData; + return ['TP_Islem_Iptal_Iade_Kismi2' => $requestData]; } - //todo - /** * {@inheritDoc} - * @return array{OrderId: string, Extra: array&array, Name: string, Password: string, ClientId: string} */ public function createOrderHistoryRequestData(AbstractPosAccount $posAccount, array $order): array { - $order = $this->prepareOrderHistoryOrder($order); - - $requestData = [ - 'OrderId' => (string) $order['id'], - 'Extra' => [ - $this->mapTxType(PosInterface::TX_TYPE_HISTORY) => 'QUERY', - ], - ]; - - return $this->getRequestAccountData($posAccount) + $requestData; + throw new NotImplementedException(); } - //todo /** + * // todo bank response is failing ask parampos * {@inheritDoc} */ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $data = []): array { - throw new NotImplementedException(); + $order = $this->prepareHistoryOrder($data); + + $requestData = $this->getRequestAccountData($posAccount) + [ + '@xmlns' => 'https://turkpos.com.tr/', + 'Tarih_Bas' => $this->formatRequestDateTime($order['start_date']), + 'Tarih_Bit' => $this->formatRequestDateTime($order['end_date']), + ]; + + if (isset($data['order_status'])) { + $requestData['Islem_Durum'] = $data['order_status']; + } + if (isset($data['transaction_type'])) { + if (PosInterface::TX_TYPE_PAY_AUTH === $data['transaction_type']) { + $requestData['Islem_Tipi'] = 'Satış'; + } elseif (PosInterface::TX_TYPE_CANCEL === $data['transaction_type']) { + $requestData['Islem_Tipi'] = 'İptal'; + } elseif (PosInterface::TX_TYPE_REFUND === $data['transaction_type']) { + $requestData['Islem_Tipi'] = 'İade'; + } + } + + return ['TP_Islem_Izleme' => $requestData]; } /** @@ -330,6 +368,18 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $ */ public function create3DFormData(?AbstractPosAccount $posAccount, ?array $order, string $paymentModel, string $txType, ?string $gatewayURL = null, ?CreditCardInterface $creditCard = null, array $extraData = []) { + if (PosInterface::MODEL_3D_HOST === $paymentModel) { + $inputs = [ + 's' => $extraData['TO_Pre_Encrypting_OOSResponse']['TO_Pre_Encrypting_OOSResult'], + ]; + + return [ + 'gateway' => $gatewayURL, + 'method' => 'GET', + 'inputs' => $inputs, + ]; + } + if (isset($extraData['UCD_URL'])) { return [ 'gateway' => $extraData['UCD_URL'], @@ -341,61 +391,15 @@ public function create3DFormData(?AbstractPosAccount $posAccount, ?array $order, return $extraData['UCD_HTML']; } - //todo - /** * @inheritDoc */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - return $requestData + $this->getRequestAccountData($posAccount); - } - - //todo - - /** - * @phpstan-param PosInterface::MODEL_3D_* $paymentModel - * @phpstan-param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType - * - * @param AbstractPosAccount $posAccount - * @param array $order - * @param string $paymentModel - * @param string $txType - * @param string $gatewayURL - * @param CreditCardInterface|null $creditCard - * - * @return array{gateway: string, method: 'POST', inputs: array} - * - * @throws UnsupportedTransactionTypeException - */ - protected function create3DFormDataCommon(AbstractPosAccount $posAccount, array $order, string $paymentModel, string $txType, string $gatewayURL, ?CreditCardInterface $creditCard = null): array - { - $inputs = [ - 'clientid' => $posAccount->getClientId(), - 'storetype' => $this->secureTypeMappings[$paymentModel], - 'amount' => (string) $order['amount'], - 'oid' => (string) $order['id'], - 'okUrl' => (string) $order['success_url'], - 'failUrl' => (string) $order['fail_url'], - 'rnd' => $this->crypt->generateRandomString(), - 'lang' => $this->getLang($posAccount, $order), - 'currency' => $this->mapCurrency((string) $order['currency']), - 'taksit' => $this->mapInstallment((int) $order['installment']), - 'islemtipi' => $this->mapTxType($txType), - ]; + $soapAction = \array_key_first($requestData); + $requestData[$soapAction] = $requestData[$soapAction] + $this->getRequestAccountData($posAccount); - if ($creditCard instanceof CreditCardInterface) { - $inputs['pan'] = $creditCard->getNumber(); - $inputs['Ecom_Payment_Card_ExpDate_Month'] = $creditCard->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT); - $inputs['Ecom_Payment_Card_ExpDate_Year'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT); - $inputs['cv2'] = $creditCard->getCvv(); - } - - return [ - 'gateway' => $gatewayURL, - 'method' => 'POST', - 'inputs' => $inputs, - ]; + return $requestData; } /** @@ -409,8 +413,6 @@ protected function mapInstallment(int $installment): string return $installment > 1 ? (string) $installment : '1'; } - //todo - /** * @inheritDoc */ @@ -418,10 +420,8 @@ protected function preparePaymentOrder(array $order): array { return \array_merge($order, [ 'installment' => $order['installment'] ?? 0, - 'currency' => $order['currency'] ?? PosInterface::CURRENCY_TRY, //todo doviz odeme nasil olacak? + 'currency' => $order['currency'] ?? PosInterface::CURRENCY_TRY, 'amount' => $order['amount'], - 'success_url' => $order['success_url'], - 'fail_url' => $order['fail_url'], 'ip' => $order['ip'], ]); } @@ -436,13 +436,9 @@ protected function preparePostPaymentOrder(array $order): array return [ 'id' => $order['id'], 'amount' => $order['amount'] ?? null, - 'pre_auth_amount' => $order['pre_auth_amount'] ?? null, ]; } - -//todo - /** * @inheritDoc */ @@ -496,9 +492,9 @@ protected function formatAmount(float $amount): string * * @return array{G: array{CLIENT_CODE: string, CLIENT_USERNAME: string, CLIENT_PASSWORD: string}} */ - private function getRequestAccountData(AbstractPosAccount $posAccount): array + private function getRequestAccountData(AbstractPosAccount $posAccount, string $paymentModel = PosInterface::MODEL_3D_SECURE): array { - return [ + $data = [ 'G' => [ 'CLIENT_CODE' => $posAccount->getClientId(), 'CLIENT_USERNAME' => $posAccount->getUsername(), @@ -506,26 +502,21 @@ private function getRequestAccountData(AbstractPosAccount $posAccount): array ], 'GUID' => $posAccount->getStoreKey(), ]; - } - //todo + if (PosInterface::MODEL_3D_HOST === $paymentModel) { + $data['Terminal_ID'] = $posAccount->getClientId(); + } + + return $data; + } /** - * @param array{frequency: int, frequencyType: string, installment: int} $recurringData + * @param \DateTimeInterface $dateTime * - * @return array{PbOrder: array{OrderType: string, OrderFrequencyInterval: string, OrderFrequencyCycle: string, TotalNumberPayments: string}} + * @return string example 20.11.2018 15:00:00 */ - private function createRecurringData(array $recurringData): array + private function formatRequestDateTime(\DateTimeInterface $dateTime): string { - return [ - 'PbOrder' => [ - 'OrderType' => '0', // 0: Varsayılan, taksitsiz - // Periyodik İşlem Frekansı - 'OrderFrequencyInterval' => (string) $recurringData['frequency'], - // D|M|Y - 'OrderFrequencyCycle' => $this->mapRecurringFrequency($recurringData['frequencyType']), - 'TotalNumberPayments' => (string) $recurringData['installment'], - ], - ]; + return $dateTime->format('d.m.Y H:i:s'); } } diff --git a/src/DataMapper/ResponseDataMapper/ParamPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/ParamPosResponseDataMapper.php index 2e0e2432..a52c9a0b 100644 --- a/src/DataMapper/ResponseDataMapper/ParamPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/ParamPosResponseDataMapper.php @@ -8,6 +8,7 @@ use Mews\Pos\Exceptions\NotImplementedException; use Mews\Pos\PosInterface; +use Symfony\Component\VarExporter\VarExporter; class ParamPosResponseDataMapper extends AbstractResponseDataMapper { @@ -20,28 +21,16 @@ class ParamPosResponseDataMapper extends AbstractResponseDataMapper self::PROCEDURE_SUCCESS_CODE => self::TX_APPROVED, ]; - // todo /** - * D : Başarısız işlem - * A : Otorizasyon, gün sonu kapanmadan - * C : Ön otorizasyon kapama, gün sonu kapanmadan - * PN : Bekleyen İşlem - * CNCL : İptal Edilmiş İşlem - * ERR : Hata Almış İşlem - * S : Satış - * R : Teknik İptal gerekiyor - * V : İptal * @var array */ protected array $orderStatusMappings = [ - 'D' => PosInterface::PAYMENT_STATUS_ERROR, - 'ERR' => PosInterface::PAYMENT_STATUS_ERROR, - 'A' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, - 'C' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, - 'S' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, - 'PN' => PosInterface::PAYMENT_STATUS_PAYMENT_PENDING, - 'CNCL' => PosInterface::PAYMENT_STATUS_CANCELED, - 'V' => PosInterface::PAYMENT_STATUS_CANCELED, + 'FAIL' => PosInterface::PAYMENT_STATUS_ERROR, + 'BANK_FAIL' => PosInterface::PAYMENT_STATUS_ERROR, + 'SUCCESS' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, + 'CANCEL' => PosInterface::PAYMENT_STATUS_CANCELED, + 'REFUND' => PosInterface::PAYMENT_STATUS_FULLY_REFUNDED, + 'PARTIAL_REFUND' => PosInterface::PAYMENT_STATUS_PARTIALLY_REFUNDED, ]; /** @@ -58,6 +47,66 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); + if (PosInterface::TX_TYPE_PAY_PRE_AUTH === $txType) { + $payResult = $rawPaymentResponseData['TP_Islem_Odeme_OnProv_WMDResponse']['TP_Islem_Odeme_OnProv_WMDResult']; + } elseif (PosInterface::TX_TYPE_PAY_POST_AUTH === $txType) { + $payResult = $rawPaymentResponseData['TP_Islem_Odeme_OnProv_KapaResponse']['TP_Islem_Odeme_OnProv_KapaResult']; + } else { + $payResult = $rawPaymentResponseData['TP_WMD_UCDResponse']['TP_WMD_UCDResult']; + //$payResult = $rawPaymentResponseData['TP_WMD_PayResponse']['TP_WMD_PayResult']; + } + + $procReturnCode = $this->getProcReturnCode($payResult); + $status = self::TX_DECLINED; + if ($procReturnCode > 0 && PosInterface::TX_TYPE_PAY_POST_AUTH === $txType) { + $status = self::TX_APPROVED; + } elseif ($procReturnCode > 0 && $payResult['Islem_ID'] > 0) { + $status = self::TX_APPROVED; + } + + $mappedResponse = [ + 'proc_return_code' => $procReturnCode, + 'status' => $status, + 'status_detail' => $this->getStatusDetail($procReturnCode), + 'error_code' => self::TX_APPROVED === $status ? null : $procReturnCode, + 'error_message' => self::TX_APPROVED === $status ? null : ($payResult['Sonuc_Str'] ?? $payResult['Bank_HostMsg']), + 'all' => $rawPaymentResponseData, + ]; + if (self::TX_APPROVED === $status) { + if (PosInterface::TX_TYPE_PAY_PRE_AUTH !== $txType) { + $mappedResponse['ref_ret_num'] = $payResult['Bank_HostRefNum']; + } + $mappedResponse['order_id'] = $payResult['Siparis_ID']; + $mappedResponse['transaction_id'] = $payResult['Bank_Trans_ID']; + $mappedResponse['auth_code'] = $payResult['Bank_AuthCode']; + + $mappedResponse['amount'] = $order['amount']; + $mappedResponse['currency'] = $order['currency']; + $mappedResponse['transaction_time'] = new \DateTimeImmutable(); + } + $this->logger->debug('mapped payment response', $mappedResponse); + + return $this->mergeArraysPreferNonNullValues($defaultResponse, $mappedResponse); + } + + /** + * @param array $rawPaymentResponseData + * @param PosInterface::TX_TYPE_PAY_* $txType + * @param array $order + * + * @return array + */ + private function map3DPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array + { + $this->logger->debug('mapping payment response', [$rawPaymentResponseData]); + + $defaultResponse = $this->getDefaultPaymentResponse($txType, PosInterface::MODEL_NON_SECURE); + if ([] === $rawPaymentResponseData) { + return $defaultResponse; + } + + $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); + $payResult = $rawPaymentResponseData['TP_WMD_PayResponse']['TP_WMD_PayResult']; $procReturnCode = $this->getProcReturnCode($payResult); @@ -86,7 +135,64 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType return $this->mergeArraysPreferNonNullValues($defaultResponse, $mappedResponse); } - // todo + /** + * @param array $rawPaymentResponseData + * @param PosInterface::TX_TYPE_PAY_* $txType + * @param array $order + * + * @return array + */ + private function map3DPaymentWithForeignCurrencyResponse(array $rawPaymentResponseData, string $txType, array $order): array + { + $this->logger->debug('mapping payment response', [$rawPaymentResponseData]); + + $defaultResponse = $this->getDefaultPaymentResponse($txType, PosInterface::MODEL_3D_SECURE); + if ([] === $rawPaymentResponseData) { + return $defaultResponse; + } + + $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); + $payResult = $this->removePrefixFrom3DPaymentForeignCurrencyResponse($rawPaymentResponseData); + + $procReturnCode = $this->getProcReturnCode($payResult); + $status = self::TX_DECLINED; + if ($procReturnCode > 0 && $payResult['Dekont_ID'] > 0) { + $status = self::TX_APPROVED; + } + + $mappedResponse = [ + 'proc_return_code' => $procReturnCode, + 'status' => $status, + 'status_detail' => $this->getStatusDetail($procReturnCode), + 'error_code' => self::TX_APPROVED === $status ? null : $procReturnCode, + 'error_message' => self::TX_APPROVED === $status ? null : $payResult['Sonuc_Str'], + 'all' => $rawPaymentResponseData, + ]; + if (self::TX_APPROVED === $status) { + $mappedResponse['order_id'] = $payResult['Siparis_ID']; + $mappedResponse['amount'] = $this->formatAmount($payResult['Tahsilat_Tutari']); + $mappedResponse['currency'] = $payResult['PB']; //todo + $mappedResponse['transaction_time'] = new \DateTimeImmutable($payResult['Islem_Tarih']); + } + $this->logger->debug('mapped payment response', $mappedResponse); + + return $this->mergeArraysPreferNonNullValues($defaultResponse, $mappedResponse); + } + + /** + * @param array $rawPaymentResponseData + * @return array + */ + private function removePrefixFrom3DPaymentForeignCurrencyResponse(array $rawPaymentResponseData): array + { + $newArray = []; + foreach ($rawPaymentResponseData as $key => $value) { + $newKey = \str_replace('TURKPOS_RETVAL_', '', $key); + $newArray[$newKey] = $value; + } + + return $newArray; + } /** * {@inheritdoc} @@ -100,10 +206,22 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen $raw3DAuthResponseData = $this->emptyStringsToNull($raw3DAuthResponseData); $paymentModel = PosInterface::MODEL_3D_SECURE; $paymentResponseData = $this->getDefaultPaymentResponse($txType, $paymentModel); - $mdStatus = $this->extractMdStatus($raw3DAuthResponseData); if (null !== $rawPaymentResponseData) { - $paymentResponseData = $this->mapPaymentResponse($rawPaymentResponseData, $txType, $order); + if (isset($rawPaymentResponseData['TURKPOS_RETVAL_Sonuc'])) { + $paymentResponseData = $this->map3DPaymentWithForeignCurrencyResponse($rawPaymentResponseData, $txType, $order); + $threeDResponse = [ + 'transaction_security' => null, + 'md_status' => null, + 'md_error_message' => null, + '3d_all' => $raw3DAuthResponseData, + ]; + + return $this->mergeArraysPreferNonNullValues($threeDResponse, $paymentResponseData); + } + + $paymentResponseData = $this->map3DPaymentResponse($rawPaymentResponseData, $txType, $order); } + $mdStatus = $this->extractMdStatus($raw3DAuthResponseData); $threeDResponse = [ 'transaction_security' => null, @@ -132,57 +250,12 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen return $result; } - // todo - /** * {@inheritdoc} */ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txType, array $order): array { - $status = self::TX_DECLINED; - - $raw3DAuthResponseData = $this->emptyStringsToNull($raw3DAuthResponseData); - $procReturnCode = $this->getProcReturnCode($raw3DAuthResponseData); - $mdStatus = $this->extractMdStatus($raw3DAuthResponseData); - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode && $this->is3dAuthSuccess($mdStatus)) { - $status = self::TX_APPROVED; - } - - $paymentModel = $this->mapSecurityType($raw3DAuthResponseData['storetype']); - $defaultResponse = $this->getDefaultPaymentResponse($txType, $paymentModel); - - $response = [ - 'order_id' => $raw3DAuthResponseData['oid'], - 'transaction_security' => null === $mdStatus ? null : $this->mapResponseTransactionSecurity($mdStatus), - 'md_status' => $mdStatus, - 'status' => $status, - 'proc_return_code' => $procReturnCode, - 'masked_number' => $raw3DAuthResponseData['maskedCreditCard'], - 'month' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Month'], - 'year' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Year'], - 'amount' => $this->formatAmount($raw3DAuthResponseData['amount']), - 'currency' => $this->mapCurrency($raw3DAuthResponseData['currency']), - 'installment_count' => $this->mapInstallment($raw3DAuthResponseData['taksit']), - 'tx_status' => null, - 'eci' => null, - 'cavv' => null, - 'md_error_message' => $raw3DAuthResponseData['mdErrorMsg'], - 'all' => $raw3DAuthResponseData, - ]; - - if (self::TX_APPROVED === $status) { - $response['auth_code'] = $raw3DAuthResponseData['AuthCode']; - $response['eci'] = $raw3DAuthResponseData['eci']; - $response['cavv'] = $raw3DAuthResponseData['cavv']; - $response['transaction_id'] = $raw3DAuthResponseData['TransId']; - $response['transaction_time'] = new \DateTimeImmutable($raw3DAuthResponseData['EXTRA_TRXDATE']); - $response['ref_ret_num'] = $raw3DAuthResponseData['HostRefNum']; - $response['status_detail'] = $this->getStatusDetail($procReturnCode); - $response['error_message'] = $raw3DAuthResponseData['ErrMsg']; - $response['error_code'] = isset($raw3DAuthResponseData['ErrMsg']) ? $procReturnCode : null; - } - - return $this->mergeArraysPreferNonNullValues($defaultResponse, $response); + throw new NotImplementedException(); } // todo @@ -234,213 +307,114 @@ public function map3DHostResponseData(array $raw3DAuthResponseData, string $txTy return $this->mergeArraysPreferNonNullValues($defaultResponse, $response); } - // todo - /** * {@inheritdoc} */ public function mapRefundResponse(array $rawResponseData): array { - $rawResponseData = $this->emptyStringsToNull($rawResponseData); - $procReturnCode = $this->getProcReturnCode($rawResponseData); - $status = self::TX_DECLINED; - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { - $status = self::TX_APPROVED; - } - - $result = [ - 'order_id' => $rawResponseData['OrderId'], - 'group_id' => null, - 'auth_code' => null, - 'ref_ret_num' => $rawResponseData['HostRefNum'], - 'proc_return_code' => $procReturnCode, - 'transaction_id' => $rawResponseData['TransId'], - 'num_code' => null, - 'error_code' => null, - 'error_message' => $rawResponseData['ErrMsg'], - 'status' => $status, - 'status_detail' => $this->getStatusDetail($procReturnCode), - 'all' => $rawResponseData, - ]; - - if (self::TX_APPROVED === $status) { - $result['group_id'] = $rawResponseData['GroupId']; - $result['auth_code'] = $rawResponseData['AuthCode']; - $result['num_code'] = $rawResponseData['Extra']['NUMCODE']; - } else { - $result['error_code'] = $rawResponseData['Extra']['ERRORCODE'] ?? $rawResponseData['ERRORCODE'] ?? null; - } - - return $result; + return $this->mapCancelResponse($rawResponseData); } - // todo - /** * {@inheritdoc} */ public function mapCancelResponse(array $rawResponseData): array { $rawResponseData = $this->emptyStringsToNull($rawResponseData); - $procReturnCode = $this->getProcReturnCode($rawResponseData); $status = self::TX_DECLINED; - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { - $status = self::TX_APPROVED; - } - if (isset($rawResponseData['RECURRINGOPERATION'])) { - if ('Successfull' === $rawResponseData['RESULT']) { - $status = self::TX_APPROVED; - } + $cancelResponse = $rawResponseData['TP_Islem_Iptal_Iade_Kismi2Response']['TP_Islem_Iptal_Iade_Kismi2Result'] + ?? $rawResponseData['TP_Islem_Iptal_OnProvResponse']['TP_Islem_Iptal_OnProvResult']; + $procReturnCode = $this->getProcReturnCode($cancelResponse); - return [ - 'order_id' => $rawResponseData['RECORDID'], - 'status' => $status, - 'all' => $rawResponseData, - ]; + if ($procReturnCode > 0) { + $status = self::TX_APPROVED; } $result = [ - 'order_id' => $rawResponseData['OrderId'], + 'order_id' => null, 'group_id' => null, 'auth_code' => null, - 'ref_ret_num' => $rawResponseData['HostRefNum'], + 'ref_ret_num' => null, 'proc_return_code' => $procReturnCode, - 'transaction_id' => $rawResponseData['TransId'], - 'error_code' => null, - 'num_code' => null, - 'error_message' => $rawResponseData['ErrMsg'], + 'transaction_id' => null, + 'error_code' => self::TX_APPROVED !== $status ? $procReturnCode : null, + 'error_message' => self::TX_APPROVED !== $status ? $cancelResponse['Sonuc_Str'] : null, 'status' => $status, - 'status_detail' => $this->getStatusDetail($procReturnCode), + 'status_detail' => null, 'all' => $rawResponseData, ]; - - if (self::TX_APPROVED === $status) { - $result['group_id'] = $rawResponseData['GroupId']; - $result['auth_code'] = $rawResponseData['AuthCode']; - $result['num_code'] = $rawResponseData['Extra']['NUMCODE']; - } else { - $result['error_code'] = $rawResponseData['Extra']['ERRORCODE'] ?? $rawResponseData['ERRORCODE'] ?? null; + if (self::TX_APPROVED === $status && isset($rawResponseData['TP_Islem_Iptal_Iade_Kismi2Response'])) { + $result['auth_code'] = $cancelResponse['Bank_AuthCode']; + $result['ref_ret_num'] = $cancelResponse['Bank_HostRefNum']; + $result['transaction_id'] = $cancelResponse['Bank_Trans_ID']; } return $result; } - // todo - /** * {@inheritdoc} */ public function mapStatusResponse(array $rawResponseData): array { + xdebug_break(); $rawResponseData = $this->emptyStringsToNull($rawResponseData); - $procReturnCode = $this->getProcReturnCode($rawResponseData); + + $statusResponse = $rawResponseData['TP_Islem_Sorgulama4Response']['TP_Islem_Sorgulama4Result']; + $procReturnCode = $this->getProcReturnCode($statusResponse); $status = self::TX_DECLINED; - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { + if ($procReturnCode > 0) { $status = self::TX_APPROVED; } - $extra = $rawResponseData['Extra']; - - if (isset($extra['RECURRINGID'])) { - return $this->mapRecurringStatusResponse($rawResponseData); - } - $defaultResponse = $this->getDefaultStatusResponse($rawResponseData); - $defaultResponse['order_id'] = $rawResponseData['OrderId']; + $dtBilgi = $statusResponse['DT_Bilgi']; + + $defaultResponse['order_id'] = $dtBilgi['Siparis_ID']; $defaultResponse['proc_return_code'] = $procReturnCode; - $defaultResponse['transaction_id'] = $rawResponseData['TransId']; - $defaultResponse['error_message'] = self::TX_APPROVED === $status ? null : $rawResponseData['ErrMsg']; + $defaultResponse['transaction_id'] = $dtBilgi['Bank_Trans_ID']; + $defaultResponse['error_message'] = self::TX_APPROVED === $status ? null : $statusResponse['Sonuc_Str']; $defaultResponse['status'] = $status; - $defaultResponse['status_detail'] = $this->getStatusDetail($procReturnCode); + $defaultResponse['status_detail'] = null; $result = $defaultResponse; if (self::TX_APPROVED === $status) { - $result['auth_code'] = $extra['AUTH_CODE']; - $result['ref_ret_num'] = $extra['HOST_REF_NUM']; - $result['first_amount'] = $this->formatAmount($extra['ORIG_TRANS_AMT']); - $result['capture_amount'] = null !== $extra['CAPTURE_AMT'] ? $this->formatAmount($extra['CAPTURE_AMT']) : null; - $result['masked_number'] = $extra['PAN']; - $result['num_code'] = $extra['NUMCODE']; + $result['auth_code'] = $dtBilgi['Bank_AuthCode']; + $result['ref_ret_num'] = $dtBilgi['Bank_HostRefNum']; + $result['masked_number'] = $dtBilgi['KK_No']; + $result['first_amount'] = (float) $dtBilgi['Toplam_Tutar']; + // todo Toplam_Iade_Tutar + + $result['order_status'] = $this->orderStatusMappings[$dtBilgi['Durum']] ?? null; + if ('SALE' === $dtBilgi['Islem_Tip']) { + $result['transaction_type'] = PosInterface::TX_TYPE_PAY_AUTH; + $result['capture_amount'] = $result['first_amount']; + } elseif ('PRE_AUTH' === $dtBilgi['Islem_Tip']) { + $result['transaction_type'] = PosInterface::TX_TYPE_PAY_PRE_AUTH; + $result['order_status'] = PosInterface::PAYMENT_STATUS_PRE_AUTH_COMPLETED; + } elseif ('POST_AUTH' === $dtBilgi['Islem_Tip']) { + $result['transaction_type'] = PosInterface::TX_TYPE_PAY_POST_AUTH; + } $result['capture'] = $result['first_amount'] === $result['capture_amount']; - $txType = 'S' === $extra['CHARGE_TYPE_CD'] ? PosInterface::TX_TYPE_PAY_AUTH : PosInterface::TX_TYPE_REFUND; - $result['transaction_type'] = $txType; - $result['order_status'] = $this->orderStatusMappings[$extra['TRANS_STAT']] ?? null; - $result['transaction_time'] = isset($extra['AUTH_DTTM']) ? new \DateTimeImmutable($extra['AUTH_DTTM']) : null; - $result['capture_time'] = isset($extra['CAPTURE_DTTM']) ? new \DateTimeImmutable($extra['CAPTURE_DTTM']) : null; - $result['cancel_time'] = isset($extra['VOID_DTTM']) ? new \DateTimeImmutable($extra['VOID_DTTM']) : null; - } - - return $result; - } - -// todo - - /** - * @param array $rawResponseData - * - * @return array - */ - public function mapRecurringStatusResponse(array $rawResponseData): array - { - $status = self::TX_DECLINED; - /** @var array $extra */ - $extra = $rawResponseData['Extra']; - if (isset($extra['RECURRINGCOUNT']) && $extra['RECURRINGCOUNT'] > 0) { - // when order not found for the given recurring order id then RECURRINGCOUNT = 0 - $status = self::TX_APPROVED; - } + // todo refund_amount - $recurringOrderResponse = [ - 'recurringId' => $extra['RECURRINGID'], - 'recurringInstallmentCount' => $extra['RECURRINGCOUNT'], - 'status' => $status, - 'num_code' => $extra['NUMCODE'], - 'error_message' => $status !== self::TX_APPROVED ? $rawResponseData['ErrMsg'] : null, - 'all' => $rawResponseData, - ]; - - for ($i = 1; isset($extra[\sprintf('ORD_ID_%d', $i)]); ++$i) { - $recurringOrderResponse['recurringOrders'][] = $this->mapSingleRecurringOrderStatus($extra, $i); + $result['transaction_time'] = isset($dtBilgi['Tarih']) ? new \DateTimeImmutable($dtBilgi['Tarih']) : null; + //todo + $result['capture_time'] = isset($dtBilgi['Tarih']) ? new \DateTimeImmutable($dtBilgi['Tarih']) : null; + $result['cancel_time'] = isset($dtBilgi['Tarih']) ? new \DateTimeImmutable($dtBilgi['Tarih']) : null; } - return $recurringOrderResponse; + return $result; } - // todo - /** * {@inheritDoc} */ public function mapOrderHistoryResponse(array $rawResponseData): array { - $rawResponseData = $this->emptyStringsToNull($rawResponseData); - $procReturnCode = $this->getProcReturnCode($rawResponseData); - $status = self::TX_DECLINED; - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { - $status = self::TX_APPROVED; - } - - $transactions = []; - $i = 1; - while (isset($rawResponseData['Extra']['TRX'.$i])) { - $rawTx = \explode("\t", $rawResponseData['Extra']['TRX'.$i]); - $transactions[] = $this->mapSingleOrderHistoryTransaction($rawTx); - ++$i; - } - - return [ - 'order_id' => $rawResponseData['OrderId'], - 'proc_return_code' => $procReturnCode, - 'error_message' => $rawResponseData['ErrMsg'], - 'num_code' => $rawResponseData['Extra']['NUMCODE'], - 'trans_count' => (int) $rawResponseData['Extra']['TRXCOUNT'], - 'transactions' => \array_reverse($transactions), - 'status' => $status, - 'status_detail' => $this->getStatusDetail($procReturnCode), - 'all' => $rawResponseData, - ]; + throw new NotImplementedException(); } // todo @@ -473,39 +447,6 @@ public function extractMdStatus(array $raw3DAuthResponseData): ?string return $raw3DAuthResponseData['mdStatus'] ?? null; } - // todo - - /** - * @param string $mdStatus - * - * @return string - */ - protected function mapResponseTransactionSecurity(string $mdStatus): string - { - $transactionSecurity = 'MPI fallback'; - if ('1' === $mdStatus) { - $transactionSecurity = 'Full 3D Secure'; - } elseif (\in_array($mdStatus, ['2', '3', '4'])) { - $transactionSecurity = 'Half 3D Secure'; - } - - return $transactionSecurity; - } - - // todo - - /** - * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null - */ - protected function getStatusDetail(?string $procReturnCode): ?string - { - return $this->codes[$procReturnCode] ?? null; - } - /** * @param array $response * diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 2f8b4533..ad3b879c 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -257,7 +257,7 @@ public function makeRegularPayment(array $order, CreditCardInterface $creditCard ]); $requestData = $event->getRequestData(); } - +dump($requestData); $contents = $this->serializer->encode($requestData, $txType); $bankResponse = $this->send( $contents, diff --git a/src/Gateways/ParamPos.php b/src/Gateways/ParamPos.php index eecb69a0..2cae6344 100644 --- a/src/Gateways/ParamPos.php +++ b/src/Gateways/ParamPos.php @@ -19,7 +19,6 @@ use Mews\Pos\Exceptions\UnsupportedTransactionTypeException; use Mews\Pos\PosInterface; use Psr\Http\Client\ClientExceptionInterface; -use SoapFault; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\VarExporter\VarExporter; @@ -46,17 +45,17 @@ class ParamPos extends AbstractGateway protected static array $supportedTransactions = [ PosInterface::TX_TYPE_PAY_AUTH => [ PosInterface::MODEL_3D_SECURE, - PosInterface::MODEL_3D_PAY, PosInterface::MODEL_3D_HOST, PosInterface::MODEL_NON_SECURE, ], PosInterface::TX_TYPE_PAY_PRE_AUTH => [ - PosInterface::MODEL_3D_PAY, - PosInterface::MODEL_3D_HOST, + PosInterface::MODEL_3D_SECURE, + PosInterface::MODEL_3D_HOST, //todo test + PosInterface::MODEL_NON_SECURE, ], - PosInterface::TX_TYPE_HISTORY => false, - PosInterface::TX_TYPE_ORDER_HISTORY => true, + PosInterface::TX_TYPE_HISTORY => true, + PosInterface::TX_TYPE_ORDER_HISTORY => false, PosInterface::TX_TYPE_PAY_POST_AUTH => true, PosInterface::TX_TYPE_CANCEL => true, PosInterface::TX_TYPE_REFUND => true, @@ -73,37 +72,6 @@ public function getAccount(): AbstractPosAccount return $this->account; } - // todo -// /** -// * @inheritDoc -// * -// * @throws UnsupportedTransactionTypeException -// * @throws \InvalidArgumentException when transaction type or payment model are not provided -// */ -// public function getApiURL(string $txType = null, string $paymentModel = null, ?string $orderTxType = null): string -// { -// if (null !== $txType && null !== $paymentModel) { -// return parent::getApiURL().'/'.$this->getRequestURIByTransactionType($txType, $paymentModel); -// } -// -// throw new \InvalidArgumentException('Transaction type and payment model are required to generate API URL'); -// } - - // todo - /** - * @inheritDoc - * - * @param string $threeDSessionId - */ - public function get3DGatewayURL(string $paymentModel = PosInterface::MODEL_3D_SECURE, string $threeDSessionId = null): string - { - if (PosInterface::MODEL_3D_HOST === $paymentModel) { - return parent::get3DGatewayURL($paymentModel).'/'.$threeDSessionId; - } - - return parent::get3DGatewayURL($paymentModel); - } - // todo /** * @inheritDoc @@ -112,6 +80,18 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr { $request = $request->request; + if ($request->get('TURKPOS_RETVAL_Sonuc') !== null) { + // Doviz ile odeme + $this->response = $this->responseDataMapper->map3DPaymentData( + [], + $request->all(), + $txType, + $order + ); + + return $this; + } + if (!$this->is3DAuthSuccess($request->all())) { $this->response = $this->responseDataMapper->map3DPaymentData( $request->all(), @@ -149,7 +129,7 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr $requestData = $event->getRequestData(); } - $contents = $this->serializer->encode($requestData, 'TP_WMD_Pay'); + $contents = $this->serializer->encode($requestData, $txType); $provisionResponse = $this->send( $contents, $txType, @@ -170,23 +150,12 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr return $this; } - // todo /** * @inheritDoc */ public function make3DPayPayment(Request $request, array $order, string $txType): PosInterface { - $request = $request->request; - - if ($this->is3DAuthSuccess($request->all()) && !$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->all())) { - throw new HashMismatchException(); - } - - $this->response = $this->responseDataMapper->map3DPayResponseData($request->all(), $txType, $order); - - $this->logger->debug('finished 3D payment', ['mapped_response' => $this->response]); - - return $this; + throw new UnsupportedPaymentModelException(); } // todo @@ -217,13 +186,22 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $data = $this->registerPayment($order, $paymentModel, $txType, $creditCard); - if (isset($data['soap:Fault'])) { - $this->logger->error('soap error response', $data['soap:Fault']); - - throw new \RuntimeException($data['soap:Fault']['faultstring']); + if (PosInterface::MODEL_3D_HOST === $paymentModel) { + return $this->requestDataMapper->create3DFormData( + $this->account, + [], + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + null, + $data + ); } - $result = $data['TP_WMD_UCDResponse']['TP_WMD_UCDResult'] ?? $data['TP_Islem_Odeme_WDResponse']['TP_Islem_Odeme_WDResult'] ?? null; + $result = $data['TP_WMD_UCDResponse']['TP_WMD_UCDResult'] + ?? $data['TP_Islem_Odeme_WDResponse']['TP_Islem_Odeme_WDResult'] + ?? $data['TP_Islem_Odeme_OnProv_WMDResponse']['TP_Islem_Odeme_OnProv_WMDResult'] // on provizyon + ; if ($result['Sonuc'] < 0) { $this->logger->error('soap error response', $result); @@ -241,28 +219,16 @@ public function get3DFormData(array $order, string $paymentModel, string $txType ); } - // todo /** * @inheritDoc */ public function customQuery(array $requestData, string $apiUrl = null): PosInterface { - if (null === $apiUrl) { - throw new \InvalidArgumentException('API URL is required for custom query'); - } + $apiUrl ??= $this->getApiURL(PosInterface::TX_TYPE_CUSTOM_QUERY); return parent::customQuery($requestData, $apiUrl); } - // todo - /** - * @inheritDoc - */ - public function history(array $data): PosInterface - { - throw new UnsupportedTransactionTypeException(); - } - // todo /** * @inheritDoc @@ -271,123 +237,39 @@ public function history(array $data): PosInterface */ protected function send($contents, string $txType, string $paymentModel, string $url): array { - // dump($contents); -// $contents = <<$contents*/ -//HTML; - //dd($contents); - //$contents = str_replace([''], '', $contents); - //dump($contents); $this->logger->debug('sending request', ['url' => $url]); -// return $this->data = $this->sendSoapRequest($contents, $txType, $url); + $response = $this->client->post($url, [ 'headers' => [ 'Content-Type' => 'text/xml', - //'Content-Length' => strlen($contents), ], 'body' => $contents, ]); $this->logger->debug('request completed', ['status_code' => $response->getStatusCode()]); -// if ($response->getStatusCode() === 204) { -// $this->logger->warning('response from api is empty'); -// -// return $this->data = []; -// } - $responseContent = $response->getBody()->getContents(); + dump('$requestContent', $contents); dump('$responseContent', $responseContent); //dd($response->getStatusCode(), $responseContent); - return $this->data = $this->serializer->decode($responseContent, $txType); - } + $decodedData = $this->serializer->decode($responseContent, $txType); - /** - * @phpstan-param PosInterface::TX_* - * - * @param array $contents - * @param string $txType - * @param string $url - * - * @return array - * - * @throws SoapFault - * @throws \RuntimeException - */ - private function sendSoapRequest(array $contents, string $txType, string $url): array - { - $this->logger->debug('sending soap request', [ - 'txType' => $txType, - 'url' => $url, - ]); - - $sslConfig = [ - 'allow_self_signed' => true, - 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, - ]; - if ($this->isTestMode()) { - $sslConfig = [ - 'verify_peer' => false, - 'verify_peer_name' => false, - 'allow_self_signed' => true, - 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, - ]; - } - - $options = [ - 'trace' => true, - 'encoding' => 'UTF-8', - 'stream_context' => stream_context_create(['ssl' => $sslConfig]), - 'exceptions' => true, - ]; - - - $client = new \SoapClient($url, $options); - try { - //$contents = json_decode(json_encode($contents)); - dump($url, $contents); -// $result = $client->TP_WMD_UCD($contents); - $result = $client->__soapCall( - //'Pos_Odeme', - 'TP_WMD_UCD', - [$contents] - //['parameters' => ['request' => $contents]] - ); - dd($result); - } catch (SoapFault $soapFault) { + if (isset($decodedData['soap:Fault'])) { $this->logger->error('soap error response', [ - 'message' => $soapFault->getMessage(), + 'status_code' => $response->getStatusCode(), + 'response' => $decodedData, ]); - throw $soapFault; - } - - if (null === $result) { - $this->logger->error('Bankaya istek başarısız!', [ - 'response' => $result, - ]); - throw new \RuntimeException('Bankaya istek başarısız!'); - } - - $encodedResult = \json_encode($result); - - if (false === $encodedResult) { - return []; + throw new \RuntimeException($decodedData['soap:Fault']['faultstring'] ?? 'Bankaya istek başarısız!'); } - return $this->serializer->decode($encodedResult, $txType); + dump($decodedData); + return $this->data = $decodedData; } - - // todo /** - * Ödeme İşlem Başlatma - * - * Ödeme formu ve Ortak Ödeme Sayfası ile ödeme işlemi başlatmak için ThreeDSessionId değeri üretilmelidir. - * Bu servis 3D secure başlatılması için session açar ve sessionId bilgisini döner. - * Bu servisten dönen ThreeDSessionId değeri ödeme formunda veya ortak ödeme sayfa çağırma işleminde kullanılır. * * @phpstan-param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType * @phpstan-param PosInterface::MODEL_3D_* $paymentModel @@ -401,12 +283,14 @@ private function sendSoapRequest(array $contents, string $txType, string $url): * @throws UnsupportedTransactionTypeException * @throws ClientExceptionInterface */ - private function registerPayment(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard): array + private function registerPayment(array $order, string $paymentModel, string $txType, ?CreditCardInterface $creditCard): array { $requestData = $this->requestDataMapper->create3DEnrollmentCheckRequestData( $this->account, $order, $creditCard, + $txType, + $paymentModel ); $event = new RequestDataPreparedEvent( @@ -429,9 +313,7 @@ private function registerPayment(array $order, string $paymentModel, string $txT $requestData = $event->getRequestData(); } - $currency = $order['currency'] ?? PosInterface::CURRENCY_TRY; - $soapAction = PosInterface::CURRENCY_TRY === $currency ? 'TP_WMD_UCD' : 'TP_Islem_Odeme_WD'; - $requestData = $this->serializer->encode($requestData, $soapAction); //todo TP_WMD_UCD + $requestData = $this->serializer->encode($requestData, $txType); return $this->send( $requestData, @@ -440,48 +322,4 @@ private function registerPayment(array $order, string $paymentModel, string $txT $this->getApiURL($txType, $paymentModel) ); } - - // todo - /** - * @phpstan-param PosInterface::TX_TYPE_* $txType - * @phpstan-param PosInterface::MODEL_* $paymentModel - * - * @return string - * - * @throws UnsupportedTransactionTypeException - */ - private function getRequestURIByTransactionType(string $txType, string $paymentModel): string - { - $arr = [ - PosInterface::TX_TYPE_PAY_AUTH => [ - PosInterface::MODEL_NON_SECURE => 'Payment', - PosInterface::MODEL_3D_PAY => 'threeDPayment', - PosInterface::MODEL_3D_HOST => 'threeDPayment', - ], - PosInterface::TX_TYPE_PAY_PRE_AUTH => [ - PosInterface::MODEL_3D_PAY => 'threeDPreAuth', - PosInterface::MODEL_3D_HOST => 'threeDPreAuth', - ], - PosInterface::TX_TYPE_PAY_POST_AUTH => 'postAuth', - PosInterface::TX_TYPE_CANCEL => 'void', - PosInterface::TX_TYPE_REFUND => 'refund', - PosInterface::TX_TYPE_REFUND_PARTIAL => 'refund', - PosInterface::TX_TYPE_STATUS => 'inquiry', - PosInterface::TX_TYPE_ORDER_HISTORY => 'history', - ]; - - if (!isset($arr[$txType])) { - throw new UnsupportedTransactionTypeException(); - } - - if (\is_string($arr[$txType])) { - return $arr[$txType]; - } - - if (!isset($arr[$txType][$paymentModel])) { - throw new UnsupportedTransactionTypeException(); - } - - return $arr[$txType][$paymentModel]; - } } diff --git a/src/Serializer/ParamPosSerializer.php b/src/Serializer/ParamPosSerializer.php index 5e9566b9..59b58294 100644 --- a/src/Serializer/ParamPosSerializer.php +++ b/src/Serializer/ParamPosSerializer.php @@ -37,14 +37,17 @@ public static function supports(string $gatewayClass): bool */ public function encode(array $data, ?string $txType = null) //todo { - $data['@xmlns'] = 'https://turkpos.com.tr/'; + $soapAction = \array_key_first($data); + // $data[$soapAction]['@xmlns'] = 'https://turkpos.com.tr/'; + //$data['@xmlns'] = 'https://turkpos.com.tr/'; $wrapper = [ '@xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', '@xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', '@xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', - 'soap:Body' => [ - $txType => $data, - ], + 'soap:Body' => $data, +// 'soap:Body' => [ +// $txType => $data, +// ], ]; return $this->serializer->encode($wrapper, XmlEncoder::FORMAT); diff --git a/tests/Functional/ParamPosTest.php b/tests/Functional/ParamPosTest.php index efd61398..e768c197 100644 --- a/tests/Functional/ParamPosTest.php +++ b/tests/Functional/ParamPosTest.php @@ -50,15 +50,17 @@ protected function setUp(): void $this->card = CreditCardFactory::createForGateway( $this->pos, - '4446763125813623', + '5818775818772285', '26', '12', - '000', - 'John Doe', - CreditCardInterface::CARD_TYPE_VISA + '001', + 'John Doe' ); } + /** + * response tutarsiz, ara sira fail ediyor! + */ public function testNonSecurePaymentSuccess(): array { $order = $this->createPaymentOrder(PosInterface::MODEL_NON_SECURE); @@ -68,7 +70,7 @@ public function testNonSecurePaymentSuccess(): array function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { $eventIsThrown = true; $this->assertSame(PosInterface::TX_TYPE_PAY_AUTH, $requestDataPreparedEvent->getTxType()); - $this->assertCount(13, $requestDataPreparedEvent->getRequestData()); + $this->assertCount(1, $requestDataPreparedEvent->getRequestData()); } ); @@ -79,9 +81,10 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro $this->card ); - $this->assertTrue($this->pos->isSuccess()); - $response = $this->pos->getResponse(); + + $this->assertTrue($this->pos->isSuccess(), $response['error_message'] ?? 'hata'); + $this->assertIsArray($response); $this->assertNotEmpty($response); $this->assertTrue($eventIsThrown); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/ParamPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/ParamPosResponseDataMapperTest.php index 66cf5fc4..f4e93e21 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/ParamPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/ParamPosResponseDataMapperTest.php @@ -82,7 +82,11 @@ public function testExtractMdStatus(array $responseData, ?string $expected): voi public function testMapPaymentResponse(array $order, string $txType, array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, $order); - $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); + if ($expectedData['transaction_time'] instanceof \DateTimeImmutable && $actualData['transaction_time'] instanceof \DateTimeImmutable) { + $this->assertSame($expectedData['transaction_time']->format('Ymd'), $actualData['transaction_time']->format('Ymd')); + } else { + $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); + } unset($actualData['transaction_time'], $expectedData['transaction_time']); $this->assertArrayHasKey('all', $actualData); @@ -106,11 +110,11 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $txType, $order, ); - if ($expectedData['transaction_time'] instanceof \DateTimeImmutable && $actualData['transaction_time'] instanceof \DateTimeImmutable) { - $this->assertSame($expectedData['transaction_time']->format('Ymd'), $actualData['transaction_time']->format('Ymd')); - } else { - $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); - } +// if ($expectedData['transaction_time'] instanceof \DateTimeImmutable && $actualData['transaction_time'] instanceof \DateTimeImmutable) { +// $this->assertSame($expectedData['transaction_time']->format('Ymd'), $actualData['transaction_time']->format('Ymd')); +// } else { +// $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); +// } unset($actualData['transaction_time'], $expectedData['transaction_time']); $this->assertArrayHasKey('all', $actualData); @@ -121,7 +125,9 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); - $this->assertNotEmpty($actualData['3d_all']); + if ([] !== $threeDResponseData) { + $this->assertNotEmpty($actualData['3d_all']); + } unset($actualData['all'], $actualData['3d_all']); \ksort($expectedData); @@ -179,26 +185,14 @@ public function testMapStatusResponse(array $responseData, array $expectedData): { $actualData = $this->responseDataMapper->mapStatusResponse($responseData); - if (isset($actualData['recurringOrders'])) { - foreach ($actualData['recurringOrders'] as $key => $actualRecurringOrder) { - $expectedRecurringOrder = $expectedData['recurringOrders'][$key]; - \ksort($expectedData['recurringOrders'][$key]); - \ksort($actualData['recurringOrders'][$key]); - $this->assertEquals($expectedRecurringOrder['transaction_time'], $actualRecurringOrder['transaction_time']); - $this->assertEquals($expectedRecurringOrder['capture_time'], $actualRecurringOrder['capture_time']); - unset($actualData['recurringOrders'][$key]['transaction_time'], $expectedData['recurringOrders'][$key]['transaction_time']); - unset($actualData['recurringOrders'][$key]['capture_time'], $expectedData['recurringOrders'][$key]['capture_time']); - } - } else { - $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); - $this->assertEquals($expectedData['capture_time'], $actualData['capture_time']); - $this->assertEquals($expectedData['refund_time'], $actualData['refund_time']); - $this->assertEquals($expectedData['cancel_time'], $actualData['cancel_time']); - unset($actualData['transaction_time'], $expectedData['transaction_time']); - unset($actualData['capture_time'], $expectedData['capture_time']); - unset($actualData['cancel_time'], $expectedData['cancel_time']); - unset($actualData['refund_time'], $expectedData['refund_time']); - } +// $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); +// $this->assertEquals($expectedData['capture_time'], $actualData['capture_time']); +// $this->assertEquals($expectedData['refund_time'], $actualData['refund_time']); +// $this->assertEquals($expectedData['cancel_time'], $actualData['cancel_time']); +// unset($actualData['transaction_time'], $expectedData['transaction_time']); +// unset($actualData['capture_time'], $expectedData['capture_time']); +// unset($actualData['cancel_time'], $expectedData['cancel_time']); +// unset($actualData['refund_time'], $expectedData['refund_time']); $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); @@ -294,190 +288,178 @@ public static function paymentTestDataProvider(): iterable ], 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'responseData' => [ - 'OrderId' => '202210293885', - 'GroupId' => '202210293885', - 'Response' => 'Approved', - 'AuthCode' => 'P48911', - 'HostRefNum' => '230200671758', - 'ProcReturnCode' => '00', - 'TransId' => '22302V8rE11732', - 'ErrMsg' => null, - 'Extra' => [ - 'SETTLEID' => '2286', - 'TRXDATE' => '20221029 21:58:43', - 'ERRORCODE' => null, - 'TERMINALID' => '00655020', - 'MERCHANTID' => '655000200', - 'CARDBRAND' => 'VISA', - 'CARDISSUER' => 'AKBANK T.A.S.', - 'AVSAPPROVE' => 'Y', - 'HOSTDATE' => '1029-215844', - 'AVSERRORCODEDETAIL' => 'avshatali-avshatali-avshatali-avshatali-', - 'NUMCODE' => '00', + 'TP_WMD_UCDResponse' => [ + 'TP_WMD_UCDResult' => [ + 'Islem_ID' => '3007296556', + 'UCD_HTML' => 'NONSECURE', + 'Sonuc' => '1', + 'Sonuc_Str' => 'İşlem Başarılı', + 'Bank_Trans_ID' => '25004OjqB07040101', + 'Bank_AuthCode' => 'P77950', + 'Bank_HostMsg' => '', + 'Banka_Sonuc_Kod' => '0', + 'Bank_Extra' => ' + 15510 + 20250104 14:35:41 + + 0067672 + 306754300 + N + VISA + T. IS BANKASI A.S. + Y + 0104-143542 + KRCvC47lNU5BZZbG6JyiV2Exjo/DOs6USfpermp8ah3XfNOeIh5gInrOJVABJ0VSQmgAAkSfqCVmVjxmPVGaeg== + ver2 + AVS dogrulama yap�l�yor uzunluk yetmedik + avshatali-avshatali-avshatali-avshatali- + 00 + ', + 'Siparis_ID' => '2025010408A0', + 'Bank_HostRefNum' => '500400109501', + ], ], ], 'expectedData' => [ - 'transaction_id' => '22302V8rE11732', - 'transaction_type' => 'pay', - 'transaction_time' => new \DateTimeImmutable('2022-10-29 21:58:43'), - 'payment_model' => 'regular', - 'order_id' => '202210293885', - 'group_id' => '202210293885', - 'auth_code' => 'P48911', - 'ref_ret_num' => '230200671758', + 'amount' => 1.01, + 'auth_code' => 'P77950', 'batch_num' => null, - 'proc_return_code' => '00', - 'status' => 'approved', - 'status_detail' => 'approved', + 'currency' => 'TRY', 'error_code' => null, 'error_message' => null, - 'recurring_id' => null, - 'currency' => 'TRY', - 'amount' => 1.01, 'installment_count' => null, + 'order_id' => '2025010408A0', + 'payment_model' => 'regular', + 'proc_return_code' => 1, + 'ref_ret_num' => '500400109501', + 'status' => 'approved', + 'status_detail' => null, + 'transaction_id' => '25004OjqB07040101', + 'transaction_type' => 'pay', + 'transaction_time' => new \DateTimeImmutable(), ], ]; - yield 'success2WithoutERRORCODE' => [ + yield 'success_pre_payment' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, ], - 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH, 'responseData' => [ - 'OrderId' => '202210293885', - 'GroupId' => '202210293885', - 'Response' => 'Approved', - 'AuthCode' => 'P48911', - 'HostRefNum' => '230200671758', - 'ProcReturnCode' => '00', - 'TransId' => '22302V8rE11732', - 'ErrMsg' => null, - 'Extra' => [ - 'SETTLEID' => '2286', - 'TRXDATE' => '20221029 21:58:43', - 'TERMINALID' => '00655020', - 'MERCHANTID' => '655000200', - 'CARDBRAND' => 'VISA', - 'CARDISSUER' => 'AKBANK T.A.S.', - 'AVSAPPROVE' => 'Y', - 'HOSTDATE' => '1029-215844', - 'AVSERRORCODEDETAIL' => 'avshatali-avshatali-avshatali-avshatali-', - 'NUMCODE' => '00', + 'TP_Islem_Odeme_OnProv_WMDResponse' => [ + 'TP_Islem_Odeme_OnProv_WMDResult' => [ + 'Islem_ID' => '6005034747', + 'Islem_GUID' => '72c9b68c-fedc-488e-9166-ae9fc7d4e523', + 'UCD_HTML' => 'NONSECURE', + 'Sonuc' => '1', + 'Sonuc_Str' => 'Ön Provizyon İşlemi Başarılı', + 'Bank_Trans_ID' => '21292RsEI18157', + 'Bank_AuthCode' => 'P66791', + 'Bank_HostMsg' => '', + 'Banka_Sonuc_Kod' => '0', + 'Bank_Extra' => 'bank data', + 'Siparis_ID' => '2025010408A0', + 'Ext_Data' => 'a|a|a|a|a', + ], ], ], 'expectedData' => [ - 'transaction_id' => '22302V8rE11732', - 'transaction_type' => 'pay', - 'transaction_time' => new \DateTimeImmutable('2022-10-29 21:58:43'), - 'payment_model' => 'regular', - 'order_id' => '202210293885', - 'group_id' => '202210293885', - 'auth_code' => 'P48911', - 'ref_ret_num' => '230200671758', + 'amount' => 1.01, + 'auth_code' => 'P66791', 'batch_num' => null, - 'proc_return_code' => '00', - 'status' => 'approved', - 'status_detail' => 'approved', + 'currency' => 'TRY', 'error_code' => null, 'error_message' => null, - 'recurring_id' => null, - 'currency' => 'TRY', - 'amount' => 1.01, 'installment_count' => null, + 'order_id' => '2025010408A0', + 'payment_model' => 'regular', + 'proc_return_code' => 1, + 'ref_ret_num' => null, + 'status' => 'approved', + 'status_detail' => null, + 'transaction_id' => '21292RsEI18157', + 'transaction_type' => 'pre', + 'transaction_time' => new \DateTimeImmutable(), ], ]; - yield 'fail1' => [ + yield 'success_post_payment' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, ], - 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'txType' => PosInterface::TX_TYPE_PAY_POST_AUTH, 'responseData' => [ - 'OrderId' => '20221029B541', - 'GroupId' => '20221029B541', - 'Response' => 'Error', - 'AuthCode' => '', - 'HostRefNum' => '', - 'ProcReturnCode' => '99', - 'TransId' => '22302WcCC13836', - 'ErrMsg' => 'Kredi karti numarasi gecerli formatta degil.', - 'Extra' => [ - 'SETTLEID' => '', - 'TRXDATE' => '20221029 22:28:01', - 'ERRORCODE' => 'CORE-2012', - 'NUMCODE' => '992012', + 'TP_Islem_Odeme_OnProv_KapaResponse' => [ + 'TP_Islem_Odeme_OnProv_KapaResult' => [ + 'Sonuc' => '1', + 'Sonuc_Str' => 'Provizyon Kapama İşlem Başarılı', + 'Prov_ID' => 'f7184b1f-c4c2-4d2e-8428-fc6014a00900', + 'Dekont_ID' => '6004466311', + 'Banka_Sonuc_Kod' => '0', + 'Siparis_ID' => '20250105CB05', + 'Bank_Trans_ID' => '25005RvnD11226', + 'Bank_AuthCode' => '519104', + 'Bank_HostRefNum' => '500517472728', + 'Bank_Extra' => 'bank-data', + 'Bank_HostMsg' => null, + ], ], ], 'expectedData' => [ - 'transaction_id' => '22302WcCC13836', - 'transaction_type' => 'pay', - 'transaction_time' => null, - 'payment_model' => 'regular', - 'order_id' => '20221029B541', - 'group_id' => '20221029B541', - 'auth_code' => null, - 'ref_ret_num' => null, + 'amount' => 1.01, + 'auth_code' => '519104', 'batch_num' => null, - 'proc_return_code' => '99', - 'status' => 'declined', - 'status_detail' => 'general_error', - 'error_code' => 'CORE-2012', - 'error_message' => 'Kredi karti numarasi gecerli formatta degil.', - 'recurring_id' => null, 'currency' => 'TRY', - 'amount' => 1.01, + 'error_code' => null, + 'error_message' => null, 'installment_count' => null, + 'order_id' => '20250105CB05', + 'payment_model' => 'regular', + 'proc_return_code' => 1, + 'ref_ret_num' => '500517472728', + 'status' => 'approved', + 'status_detail' => null, + 'transaction_id' => '25005RvnD11226', + 'transaction_type' => 'post', + 'transaction_time' => new \DateTimeImmutable(), ], ]; - - yield 'success_2' => [ + yield 'fail_try_again' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, ], 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'responseData' => [ - 'OrderId' => '20221030FAC5', - 'GroupId' => '20221030FAC5', - 'Response' => 'Approved', - 'AuthCode' => 'P90325', - 'HostRefNum' => '230300671782', - 'ProcReturnCode' => '00', - 'TransId' => '22303Md4C19254', - 'ErrMsg' => '', - 'Extra' => [ - 'SETTLEID' => '2287', - 'TRXDATE' => '20221030 12:29:53', - 'ERRORCODE' => '', - 'TERMINALID' => '00655020', - 'MERCHANTID' => '655000200', - 'CARDBRAND' => 'VISA', - 'CARDISSUER' => 'AKBANK T.A.S.', - 'AVSAPPROVE' => 'Y', - 'HOSTDATE' => '1030-122954', - 'AVSERRORCODEDETAIL' => 'avshatali-avshatali-avshatali-avshatali-', - 'NUMCODE' => '00', + 'TP_WMD_UCDResponse' => [ + 'TP_WMD_UCDResult' => [ + 'Islem_ID' => '0', + 'UCD_HTML' => 'NONSECURE', + 'Sonuc' => '-1', + 'Sonuc_Str' => 'Tekrar girin, tekrar deneyin.', + 'Banka_Sonuc_Kod' => '99', + 'Bank_Extra' => ''."\n".' '."\n".' 20250104 14:25:24'."\n".' ISO8583-19'."\n".' 99858319'."\n".' ', + 'Siparis_ID' => '20250104586F', + ], ], ], 'expectedData' => [ - 'transaction_id' => '22303Md4C19254', - 'transaction_type' => 'pay', - 'transaction_time' => new \DateTimeImmutable('2022-10-30 12:29:53'), - 'payment_model' => 'regular', - 'order_id' => '20221030FAC5', - 'group_id' => '20221030FAC5', - 'auth_code' => 'P90325', - 'ref_ret_num' => '230300671782', + 'amount' => null, + 'auth_code' => null, 'batch_num' => null, - 'proc_return_code' => '00', - 'status' => 'approved', - 'status_detail' => 'approved', - 'error_code' => null, - 'error_message' => null, - 'recurring_id' => null, - 'currency' => 'TRY', - 'amount' => 1.01, + 'currency' => null, + 'error_code' => -1, + 'error_message' => 'Tekrar girin, tekrar deneyin.', 'installment_count' => null, + 'order_id' => null, + 'payment_model' => 'regular', + 'proc_return_code' => -1, + 'ref_ret_num' => null, + 'status' => 'declined', + 'status_detail' => null, + 'transaction_id' => null, + 'transaction_type' => 'pay', + 'transaction_time' => null, ], ]; } @@ -486,7 +468,7 @@ public static function paymentTestDataProvider(): iterable public static function threeDPaymentDataProvider(): array { return [ - 'success1' => [ + 'success1' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, @@ -551,7 +533,53 @@ public static function threeDPaymentDataProvider(): array 'transaction_time' => new \DateTimeImmutable(), ], ], - '3d_auth_fail' => [ + 'success_foreign_currency_payment' => [ + 'order' => [ + ], + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'threeDResponseData' => [], + 'paymentData' => [ + "TURKPOS_RETVAL_Islem_ID" => "25B4E0BAAD1F3FC05D46F5B4", + "TURKPOS_RETVAL_Sonuc" => "1", + "TURKPOS_RETVAL_Sonuc_Str" => "Odeme Islemi Basarili", + "TURKPOS_RETVAL_GUID" => "0c13d406-873b-403b-9c09-a5766840d98c", + "TURKPOS_RETVAL_Islem_Tarih" => "5.01.2025 14:52:20", + "TURKPOS_RETVAL_Dekont_ID" => "3007296668", + "TURKPOS_RETVAL_Tahsilat_Tutari" => "10,01", + "TURKPOS_RETVAL_Odeme_Tutari" => "9,83", + "TURKPOS_RETVAL_Siparis_ID" => "202501053F4F", + "TURKPOS_RETVAL_Ext_Data" => "||||", + "TURKPOS_RETVAL_Banka_Sonuc_Kod" => "0", + "TURKPOS_RETVAL_PB" => "USD", + "TURKPOS_RETVAL_KK_No" => "581877******2285", + "TURKPOS_RETVAL_Taksit" => "0", + "TURKPOS_RETVAL_Hash" => "LrFgOcE6S8HzNF4tzvtORAh3C20=", + "TURKPOS_RETVAL_Islem_GUID" => "597b2fc9-df6d-40d7-861a-c4f5d0e94ed3", + "TURKPOS_RETVAL_SanalPOS_Islem_ID" => "6021842602", + ], + 'expectedData' => [ + 'amount' => 10.01, + 'auth_code' => null, + 'batch_num' => null, + 'currency' => 'USD', + 'error_code' => null, + 'error_message' => null, + 'installment_count' => null, + 'md_error_message' => null, + 'md_status' => null, + 'order_id' => '202501053F4F', + 'payment_model' => '3d', + 'proc_return_code' => 1, + 'ref_ret_num' => null, + 'status' => 'approved', + 'status_detail' => null, + 'transaction_id' => null, + 'transaction_security' => null, + 'transaction_type' => 'pay', + 'transaction_time' => new \DateTimeImmutable('5.01.2025 14:52:20'), + ], + ], + '3d_auth_fail' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, @@ -591,7 +619,7 @@ public static function threeDPaymentDataProvider(): array 'transaction_type' => 'pay', ], ], - '3d_auth_success_payment_fail' => [ + '3d_auth_success_payment_fail' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, @@ -640,7 +668,56 @@ public static function threeDPaymentDataProvider(): array 'transaction_time' => null, ], ], - '3d_auth_success_payment_fail_wong_cvv' => [ + '3d_auth_success_payment_fail_not_found' => [ + 'order' => [ + 'currency' => PosInterface::CURRENCY_TRY, + 'amount' => 1.01, + ], + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'threeDResponseData' => [ + "md" => "444676:A78A6D388E30776DA8F0EB5920F615F9AA523AC0E1EBA1499DB65C2B2BC4F29B:4474:##190100000", + "mdStatus" => "1", + "orderId" => "20250104E733", + "transactionAmount" => "10,01", + "islemGUID" => "45c47ad7-2d2a-4e9f-adca-a9641cd34b74", + "islemHash" => "TLN7U1O+XAreUpt7nx6UlP63nzc=", + "bankResult" => "Y-status/Challenge authentication via ACS: https://3ds-acs.test.modirum.com/mdpayacs/5KExb5V_7OxhntjM/creq;token=339263081.17359 1", + "dc" => null, + "dcURL" => "https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx", + ], + 'paymentData' => [ + "TP_WMD_PayResponse" => [ + "TP_WMD_PayResult" => [ + "Sonuc" => "-1", + "Sonuc_Ack" => "İşlem bilgisi sorgulanamadı.", + "Bank_Sonuc_Kod" => "-1", + "Komisyon_Oran" => "0", + ], + ], + ], + 'expectedData' => [ + 'amount' => 10.01, + 'auth_code' => null, + 'batch_num' => null, + 'currency' => 'TRY', + 'error_code' => -1, + 'error_message' => 'İşlem bilgisi sorgulanamadı.', + 'installment_count' => null, + 'md_error_message' => null, + 'md_status' => '1', + 'order_id' => '20250104E733', + 'payment_model' => '3d', + 'proc_return_code' => -1, + 'ref_ret_num' => null, + 'status' => 'declined', + 'status_detail' => null, + 'transaction_id' => null, + 'transaction_security' => null, + 'transaction_type' => 'pay', + 'transaction_time' => null, + ], + ], + '3d_auth_success_payment_fail_wong_cvv' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY, 'amount' => 1.01, @@ -1114,668 +1191,781 @@ public static function threeDHostPaymentDataProvider(): array } - public static function statusTestDataProvider(): array + public static function statusTestDataProvider(): iterable { - return [ - 'success1' => [ - 'responseData' => [ - 'ErrMsg' => 'Record(s) found for 20221030FAC5', - 'ProcReturnCode' => '00', - 'Response' => 'Approved', - 'OrderId' => '20221030FAC5', - 'TransId' => '22303Md4C19254', - 'Extra' => [ - 'AUTH_CODE' => 'P90325', - 'AUTH_DTTM' => '2022-10-30 12:29:53.773', - 'CAPTURE_AMT' => '', - 'CAPTURE_DTTM' => '', - 'CAVV_3D' => '', - 'CHARGE_TYPE_CD' => 'S', - 'ECI_3D' => '', - 'HOSTDATE' => '1030-122954', - 'HOST_REF_NUM' => '230300671782', - 'MDSTATUS' => '', - 'NUMCODE' => '0', - 'ORDERSTATUS' => "ORD_ID:20221030FAC5\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:\tTRANS_STAT:A\tAUTH_DTTM:2022-10-30 12:29:53.773\tCAPTURE_DTTM:\tAUTH_CODE:P90325\tTRANS_ID:22303Md4C19254", - 'ORD_ID' => '20221030FAC5', - 'ORIG_TRANS_AMT' => '101', - 'PAN' => '4355 08** **** 4358', - 'PROC_RET_CD' => '00', - 'SETTLEID' => '', - 'TRANS_ID' => '22303Md4C19254', - 'TRANS_STAT' => 'A', - 'XID_3D' => '', + yield 'success_payment' => [ + 'responseData' => [ + 'TP_Islem_Sorgulama4Response' => [ + 'TP_Islem_Sorgulama4Result' => [ + 'DT_Bilgi' => [ + 'Odeme_Sonuc' => '1', + 'Odeme_Sonuc_Aciklama' => 'İşlem Başarılı', + 'Dekont_ID' => '3007296662', + 'Siparis_ID' => '20250105E324', + 'Islem_ID' => '665C5908BA1D7583BDF62D3A', + 'Durum' => 'SUCCESS', + 'Tarih' => '05.01.2025 13:14:32', + 'Toplam_Tutar' => '10.01', + 'Komisyon_Oran' => '1.75', + 'Komisyon_Tutar' => '0.18', + 'Banka_Sonuc_Aciklama' => '', + 'Taksit' => '1', + 'Ext_Data' => '||||', + 'Toplam_Iade_Tutar' => '0', + 'KK_No' => '581877******2285', + 'Bank_Extra' => ' + 222905 + 2025-01-05 13:14:32.162 + 1001 + 2025-01-05 13:14:32.162 + + S + + 0105-131432 + 500513472717 + + 0 + ORD_ID:10126021842587 CHARGE_TYPE_CD:S ORIG_TRANS_AMT:1001 CAPTURE_AMT:1001 TRANS_STAT:C AUTH_DTTM:2025-01-05 13:14:32.162 CAPTURE_DTTM:2025-01-05 13:14:32.162 AUTH_CODE:222905 TRANS_ID:25005NOgE12061 + 10126021842587 + 1001 + 5818 77** **** 2285 + 00 + + 25005NOgE12061 + C + + ', + 'Islem_Tip' => 'SALE', + 'Bank_Trans_ID' => '25005NOgE12061', + 'Bank_AuthCode' => '222905', + 'Bank_HostRefNum' => '500513472717', + ], + 'Sonuc' => '1', + 'Sonuc_Str' => 'Başarılı', ], ], - 'expectedData' => [ - 'order_id' => '20221030FAC5', - 'auth_code' => 'P90325', - 'proc_return_code' => '00', - 'transaction_id' => '22303Md4C19254', - 'error_message' => null, - 'ref_ret_num' => '230300671782', - 'order_status' => 'PAYMENT_COMPLETED', - 'transaction_type' => 'pay', - 'masked_number' => '4355 08** **** 4358', - 'num_code' => '0', - 'first_amount' => 1.01, - 'capture_amount' => null, - 'currency' => null, - 'status' => 'approved', - 'error_code' => null, - 'status_detail' => 'approved', - 'capture' => false, - 'transaction_time' => new \DateTimeImmutable('2022-10-30 12:29:53.773'), - 'capture_time' => null, - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => null, - ], ], - 'fail1' => [ - 'responseData' => [ - 'ErrMsg' => 'No record found for 2022103088D22', - 'ProcReturnCode' => '99', - 'Response' => 'Declined', - 'OrderId' => '', - 'TransId' => '', - 'Extra' => [ - 'NUMCODE' => '0', - 'ORDERSTATUS' => "ORD_ID:\tCHARGE_TYPE_CD:\tORIG_TRANS_AMT:\tCAPTURE_AMT:\tTRANS_STAT:\tAUTH_DTTM:\tCAPTURE_DTTM:\tAUTH_CODE:", - ], - ], - 'expectedData' => [ - 'order_id' => null, - 'auth_code' => null, - 'proc_return_code' => '99', - 'transaction_id' => null, - 'error_message' => 'No record found for 2022103088D22', - 'ref_ret_num' => null, - 'order_status' => null, - 'transaction_type' => null, - 'masked_number' => null, - 'first_amount' => null, - 'capture_amount' => null, - 'status' => 'declined', - 'error_code' => null, - 'status_detail' => 'general_error', - 'capture' => null, - 'transaction_time' => null, - 'capture_time' => null, - 'currency' => null, - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => null, - ], + 'expectedData' => [ + 'order_id' => '20221030FAC5', + 'auth_code' => 'P90325', + 'proc_return_code' => '00', + 'transaction_id' => '22303Md4C19254', + 'error_message' => null, + 'ref_ret_num' => '230300671782', + 'order_status' => 'PAYMENT_COMPLETED', + 'transaction_type' => 'pay', + 'masked_number' => '4355 08** **** 4358', + 'num_code' => '0', + 'first_amount' => 1.01, + 'capture_amount' => null, + 'currency' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => false, + 'transaction_time' => new \DateTimeImmutable('2022-10-30 12:29:53.773'), + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, ], - 'pay_order_status' => [ - 'responseData' => [ - 'ErrMsg' => 'Record(s) found for 2024010354F1', - 'ProcReturnCode' => '00', - 'Response' => 'Approved', - 'OrderId' => '2024010354F1', - 'TransId' => '24003Vl7F13152', - 'Extra' => [ - 'AUTH_CODE' => 'P77974', - 'AUTH_DTTM' => '2024-01-03 21:37:57.259', - 'CAPTURE_AMT' => '101', - 'CAPTURE_DTTM' => '2024-01-03 21:37:57.259', - 'CAVV_3D' => '', - 'CHARGE_TYPE_CD' => 'S', - 'ECI_3D' => '', - 'HOSTDATE' => '0103-213757', - 'HOST_REF_NUM' => '400300744233', - 'MDSTATUS' => '', - 'NUMCODE' => '0', - 'ORDERSTATUS' => "ORD_ID:2024010354F1\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:101\tTRANS_STAT:C\tAUTH_DTTM:2024-01-03 21:37:57.259\tCAPTURE_DTTM:2024-01-03 21:37:57.259\tAUTH_CODE:P77974\tTRANS_ID:24003Vl7F13152", - 'ORD_ID' => '2024010354F1', - 'ORIG_TRANS_AMT' => '101', - 'PAN' => '4546 71** **** 7894', - 'PROC_RET_CD' => '00', - 'SETTLEID' => '', - 'TRANS_ID' => '24003Vl7F13152', - 'TRANS_STAT' => 'C', - 'XID_3D' => '', - ], - ], - 'expectedData' => [ - 'auth_code' => 'P77974', - 'capture' => true, - 'capture_amount' => 1.01, - 'currency' => null, - 'error_code' => null, - 'error_message' => null, - 'first_amount' => 1.01, - 'masked_number' => '4546 71** **** 7894', - 'num_code' => '0', - 'order_id' => '2024010354F1', - 'order_status' => 'PAYMENT_COMPLETED', - 'proc_return_code' => '00', - 'ref_ret_num' => '400300744233', - 'status' => 'approved', - 'status_detail' => 'approved', - 'transaction_time' => new \DateTimeImmutable('2024-01-03 21:37:57.259'), - 'capture_time' => new \DateTimeImmutable('2024-01-03 21:37:57.259'), - 'transaction_id' => '24003Vl7F13152', - 'transaction_type' => 'pay', - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => null, - ], + ]; + + $responseData = json_decode(file_get_contents(__DIR__.'/../../test_data/parampos/status_pay_then_refund_response.json'), true); + yield 'success_pay_then_refund' => [ + 'responseData' => $responseData, + 'expectedData' => [ + 'order_id' => '20221030FAC5', + 'auth_code' => 'P90325', + 'proc_return_code' => '00', + 'transaction_id' => '22303Md4C19254', + 'error_message' => null, + 'ref_ret_num' => '230300671782', + 'order_status' => 'FULLY_REFUNDED', + 'transaction_type' => 'pay', + 'masked_number' => '4355 08** **** 4358', + 'num_code' => '0', + 'first_amount' => 1.01, + 'capture_amount' => null, + 'currency' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => false, + 'transaction_time' => new \DateTimeImmutable('2022-10-30 12:29:53.773'), + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, ], - 'pre_pay_order_status' => [ - 'responseData' => [ - 'ErrMsg' => 'Record(s) found for 202401032AF3', - 'ProcReturnCode' => '00', - 'Response' => 'Approved', - 'OrderId' => '202401032AF3', - 'TransId' => '24003VqkA14152', - 'Extra' => [ - 'AUTH_CODE' => 'T87380', - 'AUTH_DTTM' => '2024-01-03 21:42:35.902', - 'CAPTURE_AMT' => '', - 'CAPTURE_DTTM' => '', - 'CAVV_3D' => '', - 'CHARGE_TYPE_CD' => 'S', - 'ECI_3D' => '', - 'HOSTDATE' => '0103-214236', - 'HOST_REF_NUM' => '400300744234', - 'MDSTATUS' => '', - 'NUMCODE' => '0', - 'ORDERSTATUS' => 'ORD_ID:202401032AF3 CHARGE_TYPE_CD:S ORIG_TRANS_AMT:205 CAPTURE_AMT: TRANS_STAT:A AUTH_DTTM:2024-01-03 21:42:35.902 CAPTURE_DTTM: AUTH_CODE:T87380 TRANS_ID:24003VqkA14152', - 'ORD_ID' => '202401032AF3', - 'ORIG_TRANS_AMT' => '205', - 'PAN' => '4546 71** **** 7894', - 'PROC_RET_CD' => '00', - 'SETTLEID' => '', - 'TRANS_ID' => '24003VqkA14152', - 'TRANS_STAT' => 'A', - 'XID_3D' => '', - ], - ], - 'expectedData' => [ - 'auth_code' => 'T87380', - 'capture' => false, - 'capture_amount' => null, - 'currency' => null, - 'error_code' => null, - 'error_message' => null, - 'first_amount' => 2.05, - 'masked_number' => '4546 71** **** 7894', - 'num_code' => '0', - 'order_id' => '202401032AF3', - 'order_status' => 'PAYMENT_COMPLETED', - 'proc_return_code' => '00', - 'ref_ret_num' => '400300744234', - 'status' => 'approved', - 'status_detail' => 'approved', - 'transaction_time' => new \DateTimeImmutable('2024-01-03 21:42:35.902'), - 'capture_time' => null, - 'transaction_id' => '24003VqkA14152', - 'transaction_type' => 'pay', - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => null, - ], + ]; + + $responseData = json_decode(file_get_contents(__DIR__.'/../../test_data/parampos/status_pay_then_cancel_response.json'), true); + yield 'success_pay_then_canceled' => [ + 'responseData' => $responseData, + 'expectedData' => [ + 'order_id' => '20221030FAC5', + 'auth_code' => 'P90325', + 'proc_return_code' => '00', + 'transaction_id' => '22303Md4C19254', + 'error_message' => null, + 'ref_ret_num' => '230300671782', + 'order_status' => 'CANCELED', + 'transaction_type' => 'pay', + 'masked_number' => '4355 08** **** 4358', + 'num_code' => '0', + 'first_amount' => 1.01, + 'capture_amount' => null, + 'currency' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => false, + 'transaction_time' => new \DateTimeImmutable('2022-10-30 12:29:53.773'), + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, ], - 'canceled_order_status' => [ - 'responseData' => [ - 'ErrMsg' => 'Record(s) found for 20240103BBF9', - 'ProcReturnCode' => '00', - 'Response' => 'Approved', - 'OrderId' => '20240103BBF9', - 'TransId' => '24003VxrB15662', - 'Extra' => [ - 'AUTH_CODE' => 'P42795', - 'AUTH_DTTM' => '2024-01-03 21:49:42.929', - 'CAPTURE_AMT' => '101', - 'CAPTURE_DTTM' => '2024-01-03 21:49:42.929', - 'CAVV_3D' => '', - 'CHARGE_TYPE_CD' => 'S', - 'ECI_3D' => '', - 'HOSTDATE' => '0103-214944', - 'HOST_REF_NUM' => '400300744237', - 'MDSTATUS' => '', - 'NUMCODE' => '0', - 'ORDERSTATUS' => "ORD_ID:20240103BBF9\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:101\tTRANS_STAT:V\tAUTH_DTTM:2024-01-03 21:49:42.929\tCAPTURE_DTTM:2024-01-03 21:49:42.929\tAUTH_CODE:P42795\tTRANS_ID:24003VxrB15662", - 'ORD_ID' => '20240103BBF9', - 'ORIG_TRANS_AMT' => '101', - 'PAN' => '4546 71** **** 7894', - 'PROC_RET_CD' => '00', - 'SETTLEID' => '', - 'TRANS_ID' => '24003VxrB15662', - 'TRANS_STAT' => 'V', - 'VOID_DTTM' => '2024-01-03 21:49:44.301', - 'XID_3D' => '', - ], - ], - 'expectedData' => [ - 'auth_code' => 'P42795', - 'capture' => true, - 'capture_amount' => 1.01, - 'currency' => null, - 'error_code' => null, - 'error_message' => null, - 'first_amount' => 1.01, - 'masked_number' => '4546 71** **** 7894', - 'num_code' => '0', - 'order_id' => '20240103BBF9', - 'order_status' => 'CANCELED', - 'proc_return_code' => '00', - 'ref_ret_num' => '400300744237', - 'status' => 'approved', - 'status_detail' => 'approved', - 'transaction_time' => new \DateTimeImmutable('2024-01-03 21:49:42.929'), - 'capture_time' => new \DateTimeImmutable('2024-01-03 21:49:42.929'), - 'transaction_id' => '24003VxrB15662', - 'transaction_type' => 'pay', - 'cancel_time' => new \DateTimeImmutable('2024-01-03 21:49:44.301'), - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => null, + ]; + + $responseData = json_decode(file_get_contents(__DIR__.'/../../test_data/parampos/status_pre_pay_response.json'), true); + yield 'success_pre_pay' => [ + 'responseData' => $responseData, + 'expectedData' => [ + 'order_id' => '20221030FAC5', + 'auth_code' => 'P90325', + 'proc_return_code' => '00', + 'transaction_id' => '22303Md4C19254', + 'error_message' => null, + 'ref_ret_num' => '230300671782', + 'order_status' => PosInterface::PAYMENT_STATUS_PRE_AUTH_COMPLETED, + 'transaction_type' => 'pre', + 'masked_number' => '4355 08** **** 4358', + 'num_code' => '0', + 'first_amount' => 1.01, + 'capture_amount' => null, + 'currency' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => 'approved', + 'capture' => false, + 'transaction_time' => new \DateTimeImmutable('2022-10-30 12:29:53.773'), + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + + $responseData = json_decode(file_get_contents(__DIR__.'/../../test_data/parampos/status_post_pay_response.json'), true); + yield 'success_post_pay' => [ + 'responseData' => $responseData, + 'expectedData' => [ + 'order_id' => '20250105D70C', + 'auth_code' => '570335', + 'proc_return_code' => 1, + 'transaction_id' => '25005SMEB15694', + 'error_message' => null, + 'ref_ret_num' => '500518472771', + 'order_status' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, + 'transaction_type' => 'pay', + 'masked_number' => '581877******2285', + 'num_code' => null, + 'first_amount' => 10.01, + 'capture_amount' => null, + 'currency' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => null, + 'capture' => false, + 'transaction_time' => new \DateTimeImmutable('05.01.2025 18:12:03'), + 'capture_time' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + + $responseData = json_decode(file_get_contents(__DIR__.'/../../test_data/parampos/status_pre_pay_then_cancel_response.json'), true); + yield 'success_pre_pay_then_cancel' => [ + 'responseData' => $responseData, + 'expectedData' => [ + 'order_id' => '2025010540D6', + 'auth_code' => '105199', + 'proc_return_code' => 1, + 'transaction_id' => '25005SnhJ14709', + 'error_message' => null, + 'ref_ret_num' => '500518472763', + 'order_status' => PosInterface::PAYMENT_STATUS_CANCELED, + 'transaction_type' => 'pre', + 'masked_number' => '581877******2285', + 'first_amount' => 10.01, + 'capture_amount' => null, + 'currency' => null, + 'status' => 'approved', + 'error_code' => null, + 'status_detail' => null, + 'capture' => false, + 'transaction_time' => new \DateTimeImmutable('05.01.2025 18:39:33'), + 'capture_time' => null, + 'cancel_time' => new \DateTimeImmutable('05.01.2025 18:39:33'), + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + + yield 'fail1' => [ + 'responseData' => [ + 'ErrMsg' => 'No record found for 2022103088D22', + 'ProcReturnCode' => '99', + 'Response' => 'Declined', + 'OrderId' => '', + 'TransId' => '', + 'Extra' => [ + 'NUMCODE' => '0', + 'ORDERSTATUS' => "ORD_ID:\tCHARGE_TYPE_CD:\tORIG_TRANS_AMT:\tCAPTURE_AMT:\tTRANS_STAT:\tAUTH_DTTM:\tCAPTURE_DTTM:\tAUTH_CODE:", ], ], - 'refund_order_status' => [ - 'responseData' => [ - 'ErrMsg' => 'Record(s) found for 20240128C0B7', - 'ProcReturnCode' => '00', - 'Response' => 'Approved', - 'OrderId' => '20240128C0B7', - 'TransId' => '24028T8xG11980', - 'Extra' => [ - 'AUTH_CODE' => 'P93736', - 'AUTH_DTTM' => '2024-01-28 19:58:49.382', - 'CAPTURE_AMT' => '201', - 'CAPTURE_DTTM' => '2024-01-28 19:58:49.382', - 'CAVV_3D' => '', - 'CHARGE_TYPE_CD' => 'C', - 'ECI_3D' => '', - 'HOSTDATE' => '0128-195850', - 'HOST_REF_NUM' => '402800747548', - 'MDSTATUS' => '', - 'NUMCODE' => '0', - 'ORDERSTATUS' => 'ORD_ID:20240128C0B7 CHARGE_TYPE_CD:C ORIG_TRANS_AMT:201 CAPTURE_AMT:201 TRANS_STAT:C AUTH_DTTM:2024-01-28 19:58:49.382 CAPTURE_DTTM:2024-01-28 19:58:49.382 AUTH_CODE:P93736 TRANS_ID:24028T8xG11980', - 'ORD_ID' => '20240128C0B7', - 'ORIG_TRANS_AMT' => '201', - 'PAN' => '4546 71** **** 7894', - 'PROC_RET_CD' => '00', - 'SETTLEID' => '', - 'TRANS_ID' => '24028T8xG11980', - 'TRANS_STAT' => 'C', - 'XID_3D' => '', - ], + 'expectedData' => [ + 'order_id' => null, + 'auth_code' => null, + 'proc_return_code' => '99', + 'transaction_id' => null, + 'error_message' => 'No record found for 2022103088D22', + 'ref_ret_num' => null, + 'order_status' => null, + 'transaction_type' => null, + 'masked_number' => null, + 'first_amount' => null, + 'capture_amount' => null, + 'status' => 'declined', + 'error_code' => null, + 'status_detail' => 'general_error', + 'capture' => null, + 'transaction_time' => null, + 'capture_time' => null, + 'currency' => null, + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + yield 'pay_order_status' => [ + 'responseData' => [ + 'ErrMsg' => 'Record(s) found for 2024010354F1', + 'ProcReturnCode' => '00', + 'Response' => 'Approved', + 'OrderId' => '2024010354F1', + 'TransId' => '24003Vl7F13152', + 'Extra' => [ + 'AUTH_CODE' => 'P77974', + 'AUTH_DTTM' => '2024-01-03 21:37:57.259', + 'CAPTURE_AMT' => '101', + 'CAPTURE_DTTM' => '2024-01-03 21:37:57.259', + 'CAVV_3D' => '', + 'CHARGE_TYPE_CD' => 'S', + 'ECI_3D' => '', + 'HOSTDATE' => '0103-213757', + 'HOST_REF_NUM' => '400300744233', + 'MDSTATUS' => '', + 'NUMCODE' => '0', + 'ORDERSTATUS' => "ORD_ID:2024010354F1\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:101\tTRANS_STAT:C\tAUTH_DTTM:2024-01-03 21:37:57.259\tCAPTURE_DTTM:2024-01-03 21:37:57.259\tAUTH_CODE:P77974\tTRANS_ID:24003Vl7F13152", + 'ORD_ID' => '2024010354F1', + 'ORIG_TRANS_AMT' => '101', + 'PAN' => '4546 71** **** 7894', + 'PROC_RET_CD' => '00', + 'SETTLEID' => '', + 'TRANS_ID' => '24003Vl7F13152', + 'TRANS_STAT' => 'C', + 'XID_3D' => '', ], - 'expectedData' => [ - 'auth_code' => 'P93736', - 'capture' => true, - 'currency' => null, - 'error_code' => null, - 'error_message' => null, - 'first_amount' => 2.01, - 'capture_amount' => 2.01, - 'masked_number' => '4546 71** **** 7894', - 'num_code' => '0', - 'order_id' => '20240128C0B7', - 'order_status' => 'PAYMENT_COMPLETED', - 'proc_return_code' => '00', - 'ref_ret_num' => '402800747548', - 'status' => 'approved', - 'status_detail' => 'approved', - 'transaction_time' => new \DateTimeImmutable('2024-01-28 19:58:49.382'), - 'capture_time' => new \DateTimeImmutable('2024-01-28 19:58:49.382'), - 'transaction_id' => '24028T8xG11980', - 'transaction_type' => 'refund', - 'cancel_time' => null, - 'refund_amount' => null, - 'refund_time' => null, - 'installment_count' => null, + ], + 'expectedData' => [ + 'auth_code' => 'P77974', + 'capture' => true, + 'capture_amount' => 1.01, + 'currency' => null, + 'error_code' => null, + 'error_message' => null, + 'first_amount' => 1.01, + 'masked_number' => '4546 71** **** 7894', + 'num_code' => '0', + 'order_id' => '2024010354F1', + 'order_status' => 'PAYMENT_COMPLETED', + 'proc_return_code' => '00', + 'ref_ret_num' => '400300744233', + 'status' => 'approved', + 'status_detail' => 'approved', + 'transaction_time' => new \DateTimeImmutable('2024-01-03 21:37:57.259'), + 'capture_time' => new \DateTimeImmutable('2024-01-03 21:37:57.259'), + 'transaction_id' => '24003Vl7F13152', + 'transaction_type' => 'pay', + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + yield 'pre_pay_order_status' => [ + 'responseData' => [ + 'ErrMsg' => 'Record(s) found for 202401032AF3', + 'ProcReturnCode' => '00', + 'Response' => 'Approved', + 'OrderId' => '202401032AF3', + 'TransId' => '24003VqkA14152', + 'Extra' => [ + 'AUTH_CODE' => 'T87380', + 'AUTH_DTTM' => '2024-01-03 21:42:35.902', + 'CAPTURE_AMT' => '', + 'CAPTURE_DTTM' => '', + 'CAVV_3D' => '', + 'CHARGE_TYPE_CD' => 'S', + 'ECI_3D' => '', + 'HOSTDATE' => '0103-214236', + 'HOST_REF_NUM' => '400300744234', + 'MDSTATUS' => '', + 'NUMCODE' => '0', + 'ORDERSTATUS' => 'ORD_ID:202401032AF3 CHARGE_TYPE_CD:S ORIG_TRANS_AMT:205 CAPTURE_AMT: TRANS_STAT:A AUTH_DTTM:2024-01-03 21:42:35.902 CAPTURE_DTTM: AUTH_CODE:T87380 TRANS_ID:24003VqkA14152', + 'ORD_ID' => '202401032AF3', + 'ORIG_TRANS_AMT' => '205', + 'PAN' => '4546 71** **** 7894', + 'PROC_RET_CD' => '00', + 'SETTLEID' => '', + 'TRANS_ID' => '24003VqkA14152', + 'TRANS_STAT' => 'A', + 'XID_3D' => '', ], ], - 'recurring_order_status' => [ - 'responseData' => [ - 'ErrMsg' => 'Record(s) found for 22303O8EA19252', - 'Extra' => [ - 'AUTH_CODE_1' => 'P34325', - 'AUTH_DTTM_1' => '2022-10-30 14:58:03.449', - 'CAPTURE_AMT_1' => '101', - 'CAPTURE_DTTM_1' => '2022-10-30 14:58:03.449', - 'CAVV_3D_1' => '', - 'CHARGE_TYPE_CD_1' => 'S', - 'CHARGE_TYPE_CD_2' => 'S', - 'ECI_3D_1' => '', - 'HOSTDATE_1' => '1030-145804', - 'HOST_REF_NUM_1' => '230300671790', - 'MDSTATUS_1' => '', - 'NUMCODE' => '0', - 'ORDERSTATUS_1' => "ORD_ID:2022103097CD\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:101\tTRANS_STAT:C\tAUTH_DTTM:2022-10-30 14:58:03.449\tCAPTURE_DTTM:2022-10-30 14:58:03.449\tAUTH_CODE:P34325\tTRANS_ID:22303O8EB19253", - 'ORDERSTATUS_2' => "ORD_ID:2022103097CD-2\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tTRANS_STAT:PN\tPLANNED_START_DTTM:2023-01-30 14:58:03.449", - 'ORD_ID_1' => '2022103097CD', - 'ORD_ID_2' => '2022103097CD-2', - 'ORIG_TRANS_AMT_1' => '101', - 'ORIG_TRANS_AMT_2' => '101', - 'PAN_1' => '4355 08** **** 4358', - 'PAN_2' => '4355 08** **** 4358', - 'PLANNED_START_DTTM_2' => '2023-01-30 14:58:03.449', - 'PROC_RET_CD_1' => '00', - 'RECURRINGCOUNT' => '2', - 'RECURRINGID' => '22303O8EA19252', - 'SETTLEID_1' => '', - 'TRANS_ID_1' => '22303O8EB19253', - 'TRANS_STAT_1' => 'C', - 'TRANS_STAT_2' => 'PN', - 'XID_3D_1' => '', - ], + 'expectedData' => [ + 'auth_code' => 'T87380', + 'capture' => false, + 'capture_amount' => null, + 'currency' => null, + 'error_code' => null, + 'error_message' => null, + 'first_amount' => 2.05, + 'masked_number' => '4546 71** **** 7894', + 'num_code' => '0', + 'order_id' => '202401032AF3', + 'order_status' => 'PAYMENT_COMPLETED', + 'proc_return_code' => '00', + 'ref_ret_num' => '400300744234', + 'status' => 'approved', + 'status_detail' => 'approved', + 'transaction_time' => new \DateTimeImmutable('2024-01-03 21:42:35.902'), + 'capture_time' => null, + 'transaction_id' => '24003VqkA14152', + 'transaction_type' => 'pay', + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + yield 'canceled_order_status' => [ + 'responseData' => [ + 'ErrMsg' => 'Record(s) found for 20240103BBF9', + 'ProcReturnCode' => '00', + 'Response' => 'Approved', + 'OrderId' => '20240103BBF9', + 'TransId' => '24003VxrB15662', + 'Extra' => [ + 'AUTH_CODE' => 'P42795', + 'AUTH_DTTM' => '2024-01-03 21:49:42.929', + 'CAPTURE_AMT' => '101', + 'CAPTURE_DTTM' => '2024-01-03 21:49:42.929', + 'CAVV_3D' => '', + 'CHARGE_TYPE_CD' => 'S', + 'ECI_3D' => '', + 'HOSTDATE' => '0103-214944', + 'HOST_REF_NUM' => '400300744237', + 'MDSTATUS' => '', + 'NUMCODE' => '0', + 'ORDERSTATUS' => "ORD_ID:20240103BBF9\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:101\tTRANS_STAT:V\tAUTH_DTTM:2024-01-03 21:49:42.929\tCAPTURE_DTTM:2024-01-03 21:49:42.929\tAUTH_CODE:P42795\tTRANS_ID:24003VxrB15662", + 'ORD_ID' => '20240103BBF9', + 'ORIG_TRANS_AMT' => '101', + 'PAN' => '4546 71** **** 7894', + 'PROC_RET_CD' => '00', + 'SETTLEID' => '', + 'TRANS_ID' => '24003VxrB15662', + 'TRANS_STAT' => 'V', + 'VOID_DTTM' => '2024-01-03 21:49:44.301', + 'XID_3D' => '', ], - 'expectedData' => [ - 'recurringId' => '22303O8EA19252', - 'recurringInstallmentCount' => '2', - 'status' => 'approved', - 'num_code' => '0', - 'error_message' => null, - 'recurringOrders' => [ - [ - 'auth_code' => 'P34325', - 'capture' => true, - 'capture_amount' => 1.01, - 'currency' => null, - 'error_code' => null, - 'error_message' => null, - 'first_amount' => 1.01, - 'masked_number' => '4355 08** **** 4358', - 'order_id' => '2022103097CD', - 'order_status' => 'PAYMENT_COMPLETED', - 'proc_return_code' => '00', - 'ref_ret_num' => '230300671790', - 'status' => 'approved', - 'status_detail' => 'approved', - 'transaction_time' => new \DateTimeImmutable('2022-10-30 14:58:03.449'), - 'capture_time' => new \DateTimeImmutable('2022-10-30 14:58:03.449'), - 'transaction_id' => '22303O8EB19253', - 'transaction_type' => 'pay', - ], - [ - 'auth_code' => null, - 'capture' => false, - 'capture_amount' => null, - 'currency' => null, - 'error_code' => null, - 'error_message' => null, - 'first_amount' => 1.01, - 'masked_number' => '4355 08** **** 4358', - 'order_id' => '2022103097CD-2', - 'order_status' => 'PAYMENT_PENDING', - 'proc_return_code' => null, - 'ref_ret_num' => null, - 'status' => 'declined', - 'status_detail' => null, - 'transaction_id' => null, - 'transaction_time' => null, - 'capture_time' => null, - 'transaction_type' => 'pay', - ], - ], + ], + 'expectedData' => [ + 'auth_code' => 'P42795', + 'capture' => true, + 'capture_amount' => 1.01, + 'currency' => null, + 'error_code' => null, + 'error_message' => null, + 'first_amount' => 1.01, + 'masked_number' => '4546 71** **** 7894', + 'num_code' => '0', + 'order_id' => '20240103BBF9', + 'order_status' => 'CANCELED', + 'proc_return_code' => '00', + 'ref_ret_num' => '400300744237', + 'status' => 'approved', + 'status_detail' => 'approved', + 'transaction_time' => new \DateTimeImmutable('2024-01-03 21:49:42.929'), + 'capture_time' => new \DateTimeImmutable('2024-01-03 21:49:42.929'), + 'transaction_id' => '24003VxrB15662', + 'transaction_type' => 'pay', + 'cancel_time' => new \DateTimeImmutable('2024-01-03 21:49:44.301'), + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], + ]; + yield 'refund_order_status' => [ + 'responseData' => [ + 'ErrMsg' => 'Record(s) found for 20240128C0B7', + 'ProcReturnCode' => '00', + 'Response' => 'Approved', + 'OrderId' => '20240128C0B7', + 'TransId' => '24028T8xG11980', + 'Extra' => [ + 'AUTH_CODE' => 'P93736', + 'AUTH_DTTM' => '2024-01-28 19:58:49.382', + 'CAPTURE_AMT' => '201', + 'CAPTURE_DTTM' => '2024-01-28 19:58:49.382', + 'CAVV_3D' => '', + 'CHARGE_TYPE_CD' => 'C', + 'ECI_3D' => '', + 'HOSTDATE' => '0128-195850', + 'HOST_REF_NUM' => '402800747548', + 'MDSTATUS' => '', + 'NUMCODE' => '0', + 'ORDERSTATUS' => 'ORD_ID:20240128C0B7 CHARGE_TYPE_CD:C ORIG_TRANS_AMT:201 CAPTURE_AMT:201 TRANS_STAT:C AUTH_DTTM:2024-01-28 19:58:49.382 CAPTURE_DTTM:2024-01-28 19:58:49.382 AUTH_CODE:P93736 TRANS_ID:24028T8xG11980', + 'ORD_ID' => '20240128C0B7', + 'ORIG_TRANS_AMT' => '201', + 'PAN' => '4546 71** **** 7894', + 'PROC_RET_CD' => '00', + 'SETTLEID' => '', + 'TRANS_ID' => '24028T8xG11980', + 'TRANS_STAT' => 'C', + 'XID_3D' => '', ], ], + 'expectedData' => [ + 'auth_code' => 'P93736', + 'capture' => true, + 'currency' => null, + 'error_code' => null, + 'error_message' => null, + 'first_amount' => 2.01, + 'capture_amount' => 2.01, + 'masked_number' => '4546 71** **** 7894', + 'num_code' => '0', + 'order_id' => '20240128C0B7', + 'order_status' => 'PAYMENT_COMPLETED', + 'proc_return_code' => '00', + 'ref_ret_num' => '402800747548', + 'status' => 'approved', + 'status_detail' => 'approved', + 'transaction_time' => new \DateTimeImmutable('2024-01-28 19:58:49.382'), + 'capture_time' => new \DateTimeImmutable('2024-01-28 19:58:49.382'), + 'transaction_id' => '24028T8xG11980', + 'transaction_type' => 'refund', + 'cancel_time' => null, + 'refund_amount' => null, + 'refund_time' => null, + 'installment_count' => null, + ], ]; - } - - public static function cancelTestDataProvider(): array - { - return - [ - 'success1' => [ - 'responseData' => [ - 'OrderId' => '20221030B3FF', - 'GroupId' => '20221030B3FF', - 'Response' => 'Approved', - 'AuthCode' => 'P43467', - 'HostRefNum' => '230300671786', - 'ProcReturnCode' => '00', - 'TransId' => '22303MzZG10851', - 'ErrMsg' => '', - 'Extra' => [ - 'SETTLEID' => '2287', - 'TRXDATE' => '20221030 12:51:25', - 'ERRORCODE' => '', - 'TERMINALID' => '00655020', - 'MERCHANTID' => '655000200', - 'CARDBRAND' => 'VISA', - 'CARDISSUER' => 'AKBANK T.A.S.', - 'HOSTDATE' => '1030-125130', - 'NUMCODE' => '00', - ], - ], - 'expectedData' => [ - 'order_id' => '20221030B3FF', - 'group_id' => '20221030B3FF', - 'auth_code' => 'P43467', - 'ref_ret_num' => '230300671786', - 'proc_return_code' => '00', - 'transaction_id' => '22303MzZG10851', - 'error_code' => null, - 'num_code' => '00', - 'error_message' => null, - 'status' => 'approved', - 'status_detail' => 'approved', - ], + yield 'recurring_order_status' => [ + 'responseData' => [ + 'ErrMsg' => 'Record(s) found for 22303O8EA19252', + 'Extra' => [ + 'AUTH_CODE_1' => 'P34325', + 'AUTH_DTTM_1' => '2022-10-30 14:58:03.449', + 'CAPTURE_AMT_1' => '101', + 'CAPTURE_DTTM_1' => '2022-10-30 14:58:03.449', + 'CAVV_3D_1' => '', + 'CHARGE_TYPE_CD_1' => 'S', + 'CHARGE_TYPE_CD_2' => 'S', + 'ECI_3D_1' => '', + 'HOSTDATE_1' => '1030-145804', + 'HOST_REF_NUM_1' => '230300671790', + 'MDSTATUS_1' => '', + 'NUMCODE' => '0', + 'ORDERSTATUS_1' => "ORD_ID:2022103097CD\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tCAPTURE_AMT:101\tTRANS_STAT:C\tAUTH_DTTM:2022-10-30 14:58:03.449\tCAPTURE_DTTM:2022-10-30 14:58:03.449\tAUTH_CODE:P34325\tTRANS_ID:22303O8EB19253", + 'ORDERSTATUS_2' => "ORD_ID:2022103097CD-2\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:101\tTRANS_STAT:PN\tPLANNED_START_DTTM:2023-01-30 14:58:03.449", + 'ORD_ID_1' => '2022103097CD', + 'ORD_ID_2' => '2022103097CD-2', + 'ORIG_TRANS_AMT_1' => '101', + 'ORIG_TRANS_AMT_2' => '101', + 'PAN_1' => '4355 08** **** 4358', + 'PAN_2' => '4355 08** **** 4358', + 'PLANNED_START_DTTM_2' => '2023-01-30 14:58:03.449', + 'PROC_RET_CD_1' => '00', + 'RECURRINGCOUNT' => '2', + 'RECURRINGID' => '22303O8EA19252', + 'SETTLEID_1' => '', + 'TRANS_ID_1' => '22303O8EB19253', + 'TRANS_STAT_1' => 'C', + 'TRANS_STAT_2' => 'PN', + 'XID_3D_1' => '', ], - 'success_without_extra_error_code' => [ - 'responseData' => [ - 'OrderId' => '230', - 'GroupId' => '800', - 'Response' => 'Approved', - 'AuthCode' => '160769', - 'HostRefNum' => '48', - 'ProcReturnCode' => '00', - 'TransId' => '2836', - 'ErrMsg' => '', - 'ERRORCODE' => '', - 'Extra' => [ - 'KULLANILANPUAN' => '000000000000', - 'CARDBRAND' => 'VISA', - 'TRXDATE' => '2017 13:14:06', - 'KULLANILABILIRPUAN' => '000000000380', - 'ACQSTAN' => '769388', - 'KAZANILANPUAN' => '000000000229', - 'TRACEID' => '4d68eab86e6', - 'NUMCODE' => '00', - 'SETTLEID' => '87', - ], - ], - 'expectedData' => [ - 'order_id' => '230', - 'group_id' => '800', - 'auth_code' => '160769', - 'ref_ret_num' => '48', - 'proc_return_code' => '00', - 'transaction_id' => '2836', + ], + 'expectedData' => [ + 'recurringId' => '22303O8EA19252', + 'recurringInstallmentCount' => '2', + 'status' => 'approved', + 'num_code' => '0', + 'error_message' => null, + 'recurringOrders' => [ + [ + 'auth_code' => 'P34325', + 'capture' => true, + 'capture_amount' => 1.01, + 'currency' => null, 'error_code' => null, - 'num_code' => '00', 'error_message' => null, + 'first_amount' => 1.01, + 'masked_number' => '4355 08** **** 4358', + 'order_id' => '2022103097CD', + 'order_status' => 'PAYMENT_COMPLETED', + 'proc_return_code' => '00', + 'ref_ret_num' => '230300671790', 'status' => 'approved', 'status_detail' => 'approved', + 'transaction_time' => new \DateTimeImmutable('2022-10-30 14:58:03.449'), + 'capture_time' => new \DateTimeImmutable('2022-10-30 14:58:03.449'), + 'transaction_id' => '22303O8EB19253', + 'transaction_type' => 'pay', ], - ], - 'fail_order_not_found_1' => [ - 'responseData' => [ - 'OrderId' => '', - 'GroupId' => '', - 'Response' => 'Error', - 'AuthCode' => '', - 'HostRefNum' => '', - 'ProcReturnCode' => '99', - 'TransId' => '22303M5IA11121', - 'ErrMsg' => 'İptal edilmeye uygun satış işlemi bulunamadı.', - 'Extra' => [ - 'SETTLEID' => '', - 'TRXDATE' => '20221030 12:55:08', - 'ERRORCODE' => 'CORE-2008', - 'NUMCODE' => '992008', - ], - ], - 'expectedData' => [ - 'order_id' => null, - 'group_id' => null, + [ 'auth_code' => null, + 'capture' => false, + 'capture_amount' => null, + 'currency' => null, + 'error_code' => null, + 'error_message' => null, + 'first_amount' => 1.01, + 'masked_number' => '4355 08** **** 4358', + 'order_id' => '2022103097CD-2', + 'order_status' => 'PAYMENT_PENDING', + 'proc_return_code' => null, 'ref_ret_num' => null, - 'proc_return_code' => '99', - 'transaction_id' => '22303M5IA11121', - 'error_code' => 'CORE-2008', - 'num_code' => null, - 'error_message' => 'İptal edilmeye uygun satış işlemi bulunamadı.', 'status' => 'declined', - 'status_detail' => 'general_error', + 'status_detail' => null, + 'transaction_id' => null, + 'transaction_time' => null, + 'capture_time' => null, + 'transaction_type' => 'pay', ], ], - 'fail_order_not_found_2' => [ - 'responseData' => [ - 'OrderId' => 'a1a7d184', - 'GroupId' => 'a1a7d184', - 'Response' => 'Declined', - 'HostRefNum' => '413719757716', - 'ProcReturnCode' => '99', - 'TransId' => '', - 'ErrMsg' => 'İptal edilmeye uygun satış işlemi bulunamadı.', - 'Extra' => [ - 'TRXDATE' => '20240516 22:56:09', - 'EXTENDED_ERROR_CODE' => '215001', - 'TRACEID' => '3f423f86e9d886bf1cffae49d93268be', - 'NUMCODE' => '99', - 'ERRORCODE' => 'CORE-2008', - ], + ], + ]; + } + + public static function cancelTestDataProvider(): iterable + { + yield 'success_payment' => [ + 'responseData' => [ + "TP_Islem_Iptal_Iade_Kismi2Response" => [ + "TP_Islem_Iptal_Iade_Kismi2Result" => [ + "Sonuc" => "1", + "Sonuc_Str" => "Approved", + "Banka_Sonuc_Kod" => "0", + "Bank_AuthCode" => "142436", + "Bank_Trans_ID" => "25005OB6H12275", + "Bank_Extra" => " + +2976 +20250105 14:01:56 + +MASTERCARD +T. HALK BANKASI A.S. +3 +00 + + ", + "Bank_HostRefNum" => "500514472735", ], - 'expectedData' => [ - 'order_id' => 'a1a7d184', - 'group_id' => null, - 'auth_code' => null, - 'ref_ret_num' => '413719757716', - 'proc_return_code' => '99', - 'transaction_id' => null, - 'error_code' => 'CORE-2008', - 'num_code' => null, - 'error_message' => 'İptal edilmeye uygun satış işlemi bulunamadı.', - 'status' => 'declined', - 'status_detail' => 'general_error', + ], + ], + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => '142436', + 'ref_ret_num' => '500514472735', + 'proc_return_code' => 1, + 'transaction_id' => '25005OB6H12275', + 'error_code' => null, + 'num_code' => null, + 'error_message' => null, + 'status' => 'approved', + 'status_detail' => null, + ], + ]; + yield 'success_pre_pay' => [ + 'responseData' => [ + "TP_Islem_Iptal_OnProvResponse" => [ + "TP_Islem_Iptal_OnProvResult" => [ + "Sonuc" => "1", + "Sonuc_Str" => "Approved", + "Banka_Sonuc_Kod" => "00", ], ], - 'success_recurring_1' => [ - 'responseData' => [ - 'RECURRINGOPERATION' => 'CANCEL', - 'RECORDTYPE' => 'ORDER', - 'RECORDID' => '2022103072C1-2', - 'RESULT' => 'Successfull', - 'Extra' => '', + ], + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => 1, + 'transaction_id' => null, + 'error_code' => null, + 'num_code' => null, + 'error_message' => null, + 'status' => 'approved', + 'status_detail' => null, + ], + ]; + yield 'fail_order_not_found_1' => [ + 'responseData' => [ + "TP_Islem_Iptal_Iade_Kismi2Response" => [ + "TP_Islem_Iptal_Iade_Kismi2Result" => [ + 'Sonuc' => '-210', + 'Sonuc_Str' => 'İptal/İadeye uygun işlem bulunamadı.', ], - 'expectedData' => [ - 'order_id' => '2022103072C1-2', - 'status' => 'approved', + ], + ], + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => 210, + 'transaction_id' => null, + 'error_code' => 210, + 'num_code' => null, + 'error_message' => 'İptal/İadeye uygun işlem bulunamadı.', + 'status' => 'declined', + 'status_detail' => null, + ], + ]; + yield 'fail_already_canceled' => [ + 'responseData' => [ + "TP_Islem_Iptal_Iade_Kismi2Response" => [ + "TP_Islem_Iptal_Iade_Kismi2Result" => [ + 'Sonuc' => '-211', + 'Sonuc_Str' => 'İşlem iptal durumunda', ], ], - ]; + ], + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => -211, + 'transaction_id' => null, + 'error_code' => -211, + 'num_code' => null, + 'error_message' => 'İşlem iptal durumunda', + 'status' => 'declined', + 'status_detail' => null, + ], + ]; } - public static function refundTestDataProvider(): array + public static function refundTestDataProvider(): iterable { - return [ - 'success1' => [ - 'responseData' => [ - 'OrderId' => 'df0e', - 'GroupId' => 'dfc36f0e', - 'Response' => 'Approved', - 'AuthCode' => '46', - 'HostRefNum' => '41', - 'ProcReturnCode' => '00', - 'TransId' => '24138', - 'ErrMsg' => '', - 'ERRORCODE' => '', - 'Extra' => [ - 'KULLANILANPUAN' => '000000000000', - 'CARDBRAND' => 'MASTERCARD', - 'CARDHOLDERNAME' => 'ME* DE*', - 'TRXDATE' => '20240517 13:30:43', - 'KULLANILABILIRPUAN' => '000000005450', - 'ACQSTAN' => '74', - 'KAZANILANPUAN' => '000000000000', - 'TRACEID' => 'e7ba2a6', - 'NUMCODE' => '00', - 'SETTLEID' => '', + yield 'success_payment' => [ + 'responseData' => [ + "TP_Islem_Iptal_Iade_Kismi2Response" => [ + "TP_Islem_Iptal_Iade_Kismi2Result" => [ + "Sonuc" => "1", + "Sonuc_Str" => "Approved", + "Banka_Sonuc_Kod" => "0", + "Bank_AuthCode" => "142436", + "Bank_Trans_ID" => "25005OB6H12275", + "Bank_Extra" => " + +2976 +20250105 14:01:56 + +MASTERCARD +T. HALK BANKASI A.S. +3 +00 + + ", + "Bank_HostRefNum" => "500514472735", ], ], - 'expectedData' => [ - 'order_id' => 'df0e', - 'group_id' => 'dfc36f0e', - 'auth_code' => '46', - 'ref_ret_num' => '41', - 'proc_return_code' => '00', - 'transaction_id' => '24138', - 'num_code' => '00', - 'error_code' => null, - 'error_message' => null, - 'status' => 'approved', - 'status_detail' => 'approved', - ], ], - 'fail1' => [ - 'responseData' => [ - 'OrderId' => '20221030B3FF', - 'GroupId' => '20221030B3FF', - 'Response' => 'Error', - 'AuthCode' => '', - 'HostRefNum' => '', - 'ProcReturnCode' => '99', - 'TransId' => '22303M8rC11328', - 'ErrMsg' => 'Iade yapilamaz, siparis gunsonuna girmemis.', - 'Extra' => [ - 'SETTLEID' => '', - 'TRXDATE' => '20221030 12:58:42', - 'ERRORCODE' => 'CORE-2508', - 'NUMCODE' => '992508', + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => '142436', + 'ref_ret_num' => '500514472735', + 'proc_return_code' => 1, + 'transaction_id' => '25005OB6H12275', + 'error_code' => null, + 'num_code' => null, + 'error_message' => null, + 'status' => 'approved', + 'status_detail' => null, + ], + ]; + yield 'fail_order_not_found_1' => [ + 'responseData' => [ + "TP_Islem_Iptal_Iade_Kismi2Response" => [ + "TP_Islem_Iptal_Iade_Kismi2Result" => [ + 'Sonuc' => '-210', + 'Sonuc_Str' => 'İptal/İadeye uygun işlem bulunamadı.', ], ], - 'expectedData' => [ - 'order_id' => '20221030B3FF', - 'group_id' => null, - 'auth_code' => null, - 'ref_ret_num' => null, - 'proc_return_code' => '99', - 'transaction_id' => '22303M8rC11328', - 'num_code' => null, - 'error_code' => 'CORE-2508', - 'error_message' => 'Iade yapilamaz, siparis gunsonuna girmemis.', - 'status' => 'declined', - 'status_detail' => 'general_error', - ], ], - 'fail2' => [ - 'responseData' => [ - 'OrderId' => '2c544d', - 'Response' => 'Declined', - 'HostRefNum' => '413051', - 'TransId' => '24082', - 'ErrMsg' => 'Net Tutar 0.', - 'Extra' => [ - 'TRXDATE' => '20240517 14:28:33', - 'TRACEID' => '73631448ab0c1e', - 'ERRORCODE' => '215021', + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => 210, + 'transaction_id' => null, + 'error_code' => 210, + 'num_code' => null, + 'error_message' => 'İptal/İadeye uygun işlem bulunamadı.', + 'status' => 'declined', + 'status_detail' => null, + ], + ]; + yield 'fail_refund_twice' => [ + 'responseData' => [ + "TP_Islem_Iptal_Iade_Kismi2Response" => [ + "TP_Islem_Iptal_Iade_Kismi2Result" => [ + 'Sonuc' => '-221', + 'Sonuc_Str' => 'İade tutarı, iade edilebilir tutardan büyük olamaz.', ], ], - 'expectedData' => [ - 'order_id' => '2c544d', - 'group_id' => null, - 'auth_code' => null, - 'ref_ret_num' => '413051', - 'proc_return_code' => null, - 'transaction_id' => '24082', - 'num_code' => null, - 'error_code' => '215021', - 'error_message' => 'Net Tutar 0.', - 'status' => 'declined', - 'status_detail' => null, - ], + ], + 'expectedData' => [ + 'order_id' => null, + 'group_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => '-221', + 'transaction_id' => null, + 'error_code' => '-221', + 'num_code' => null, + 'error_message' => 'İade tutarı, iade edilebilir tutardan büyük olamaz.', + 'status' => 'declined', + 'status_detail' => null, ], ]; } diff --git a/tests/Unit/Serializer/ParamPosSerializerTest.php b/tests/Unit/Serializer/ParamPosSerializerTest.php index f4ac9737..e79f3a33 100644 --- a/tests/Unit/Serializer/ParamPosSerializerTest.php +++ b/tests/Unit/Serializer/ParamPosSerializerTest.php @@ -7,11 +7,9 @@ namespace Mews\Pos\Tests\Unit\Serializer; use Generator; -use Mews\Pos\DataMapper\RequestDataMapper\ParamPosRequestDataMapper; use Mews\Pos\Gateways\ParamPos; use Mews\Pos\PosInterface; use Mews\Pos\Serializer\ParamPosSerializer; -use Mews\Pos\Tests\Unit\DataMapper\RequestDataMapper\ParamPosRequestDataMapperTest; use PHPUnit\Framework\TestCase; /** @@ -101,5 +99,14 @@ public static function decodeDataProvider(): Generator ], ], ]; + yield '3d_host_form_success' => [ + 'input' => \file_get_contents(__DIR__.'/../test_data/parampos/3d_host_form_response_success.xml'), + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'expected' => [ + 'TO_Pre_Encrypting_OOSResponse' => [ + 'TO_Pre_Encrypting_OOSResult' => 'ImBuIu4mlRqIABImnjl/ikGHMe5ZOjZjP3wx61Wa7FxC3XrjnDTCsn7PngJ8DPdEV840PmqT+jVgsm+KaWcIZQq/lcJQKD3TdM99+MUcOKLxxFyByUJP3DkY9zZ4/2TJ7Px2HzZdfccockhMooHuM+A8PxjHKdK8z4pOvW/tpo/U4i6/jJPT9ZnhHL4GdRNOtu9l6sGtPHeKYC/FHYAZpGNXjR9+RCZGP/xTeFgC+Gl1o7dpRZaibII6PdPK1CNMdF8O1d1QI+PDCq/TxDSQxyyJgqovzYfBHT5mWjOx+WhiajrswNzVirR9hpii+Hq3sk+LnH90Psobh5db3F4BPpgUIuS6moVERKgq5HIhLkR4fe5TMfxcvOhj3Pg0RBQR', + ], + ], + ]; } } diff --git a/tests/Unit/test_data/parampos/3d_host_form_response_success.xml b/tests/Unit/test_data/parampos/3d_host_form_response_success.xml new file mode 100644 index 00000000..7396efa1 --- /dev/null +++ b/tests/Unit/test_data/parampos/3d_host_form_response_success.xml @@ -0,0 +1,15 @@ + + + + + 10738 + Test + Test + + + + + ImBuIu4mlRqIABImnjl/ikGHMe5ZOjZjP3wx61Wa7FxC3XrjnDTCsn7PngJ8DPdEV840PmqT+jVgsm+KaWcIZQq/lcJQKD3TdM99+MUcOKLxxFyByUJP3DkY9zZ4/2TJ7Px2HzZdfccockhMooHuM+A8PxjHKdK8z4pOvW/tpo/U4i6/jJPT9ZnhHL4GdRNOtu9l6sGtPHeKYC/FHYAZpGNXjR9+RCZGP/xTeFgC+Gl1o7dpRZaibII6PdPK1CNMdF8O1d1QI+PDCq/TxDSQxyyJgqovzYfBHT5mWjOx+WhiajrswNzVirR9hpii+Hq3sk+LnH90Psobh5db3F4BPpgUIuS6moVERKgq5HIhLkR4fe5TMfxcvOhj3Pg0RBQR + + + diff --git a/tests/Unit/test_data/parampos/status_pay_then_cancel_response.json b/tests/Unit/test_data/parampos/status_pay_then_cancel_response.json new file mode 100644 index 00000000..d7cf06bd --- /dev/null +++ b/tests/Unit/test_data/parampos/status_pay_then_cancel_response.json @@ -0,0 +1,30 @@ +{ + "TP_Islem_Sorgulama4Response": { + "TP_Islem_Sorgulama4Result": { + "DT_Bilgi": { + "Odeme_Sonuc": "13", + "Odeme_Sonuc_Aciklama": "\u0130ade", + "Dekont_ID": "3007296662", + "Siparis_ID": "20250105E324", + "Islem_ID": "665C5908BA1D7583BDF62D3A", + "Durum": "REFUND", + "Tarih": "05.01.2025 13:14:32", + "Toplam_Tutar": "10.01", + "Komisyon_Oran": "1.75", + "Komisyon_Tutar": "0.18", + "Banka_Sonuc_Aciklama": "", + "Taksit": "1", + "Ext_Data": "||||", + "Toplam_Iade_Tutar": "10.01", + "KK_No": "581877******2285", + "Bank_Extra": "\n 142436<\/AUTH_CODE>\n 2025-01-05 14:01:56.399<\/AUTH_DTTM>\n 1001<\/CAPTURE_AMT>\n 2025-01-05 14:01:56.399<\/CAPTURE_DTTM>\n <\/CAVV_3D>\n C<\/CHARGE_TYPE_CD>\n <\/ECI_3D>\n 0105-140156<\/HOSTDATE>\n 500514472735<\/HOST_REF_NUM>\n <\/MDSTATUS>\n 0<\/NUMCODE>\n ORD_ID:10126021842587\tCHARGE_TYPE_CD:C\tORIG_TRANS_AMT:1001\tCAPTURE_AMT:1001\tTRANS_STAT:C\tAUTH_DTTM:2025-01-05 14:01:56.399\tCAPTURE_DTTM:2025-01-05 14:01:56.399\tAUTH_CODE:142436\tTRANS_ID:25005OB6H12275<\/ORDERSTATUS>\n 10126021842587<\/ORD_ID>\n 1001<\/ORIG_TRANS_AMT>\n 5818 77** **** 2285<\/PAN>\n 00<\/PROC_RET_CD>\n <\/SETTLEID>\n 25005OB6H12275<\/TRANS_ID>\n C<\/TRANS_STAT>\n <\/XID_3D>\n <\/Extra>", + "Islem_Tip": "SALE", + "Bank_Trans_ID": "25005NOgE12061", + "Bank_AuthCode": "222905", + "Bank_HostRefNum": "500513472717" + }, + "Sonuc": "1", + "Sonuc_Str": "Ba\u015far\u0131l\u0131" + } + } +} diff --git a/tests/Unit/test_data/parampos/status_pay_then_refund_response.json b/tests/Unit/test_data/parampos/status_pay_then_refund_response.json new file mode 100644 index 00000000..d7cf06bd --- /dev/null +++ b/tests/Unit/test_data/parampos/status_pay_then_refund_response.json @@ -0,0 +1,30 @@ +{ + "TP_Islem_Sorgulama4Response": { + "TP_Islem_Sorgulama4Result": { + "DT_Bilgi": { + "Odeme_Sonuc": "13", + "Odeme_Sonuc_Aciklama": "\u0130ade", + "Dekont_ID": "3007296662", + "Siparis_ID": "20250105E324", + "Islem_ID": "665C5908BA1D7583BDF62D3A", + "Durum": "REFUND", + "Tarih": "05.01.2025 13:14:32", + "Toplam_Tutar": "10.01", + "Komisyon_Oran": "1.75", + "Komisyon_Tutar": "0.18", + "Banka_Sonuc_Aciklama": "", + "Taksit": "1", + "Ext_Data": "||||", + "Toplam_Iade_Tutar": "10.01", + "KK_No": "581877******2285", + "Bank_Extra": "\n 142436<\/AUTH_CODE>\n 2025-01-05 14:01:56.399<\/AUTH_DTTM>\n 1001<\/CAPTURE_AMT>\n 2025-01-05 14:01:56.399<\/CAPTURE_DTTM>\n <\/CAVV_3D>\n C<\/CHARGE_TYPE_CD>\n <\/ECI_3D>\n 0105-140156<\/HOSTDATE>\n 500514472735<\/HOST_REF_NUM>\n <\/MDSTATUS>\n 0<\/NUMCODE>\n ORD_ID:10126021842587\tCHARGE_TYPE_CD:C\tORIG_TRANS_AMT:1001\tCAPTURE_AMT:1001\tTRANS_STAT:C\tAUTH_DTTM:2025-01-05 14:01:56.399\tCAPTURE_DTTM:2025-01-05 14:01:56.399\tAUTH_CODE:142436\tTRANS_ID:25005OB6H12275<\/ORDERSTATUS>\n 10126021842587<\/ORD_ID>\n 1001<\/ORIG_TRANS_AMT>\n 5818 77** **** 2285<\/PAN>\n 00<\/PROC_RET_CD>\n <\/SETTLEID>\n 25005OB6H12275<\/TRANS_ID>\n C<\/TRANS_STAT>\n <\/XID_3D>\n <\/Extra>", + "Islem_Tip": "SALE", + "Bank_Trans_ID": "25005NOgE12061", + "Bank_AuthCode": "222905", + "Bank_HostRefNum": "500513472717" + }, + "Sonuc": "1", + "Sonuc_Str": "Ba\u015far\u0131l\u0131" + } + } +} diff --git a/tests/Unit/test_data/parampos/status_post_pay_response.json b/tests/Unit/test_data/parampos/status_post_pay_response.json new file mode 100644 index 00000000..14846dcc --- /dev/null +++ b/tests/Unit/test_data/parampos/status_post_pay_response.json @@ -0,0 +1,30 @@ +{ + "TP_Islem_Sorgulama4Response": { + "TP_Islem_Sorgulama4Result": { + "DT_Bilgi": { + "Odeme_Sonuc": "1", + "Odeme_Sonuc_Aciklama": "\u0130\u015flem Ba\u015far\u0131l\u0131", + "Dekont_ID": "6021842631", + "Siparis_ID": "20250105D70C", + "Islem_ID": "213153846F3D7E573C38E548", + "Durum": "SUCCESS", + "Tarih": "05.01.2025 18:12:03", + "Toplam_Tutar": "10.01", + "Komisyon_Oran": "1.75", + "Komisyon_Tutar": "0.18", + "Banka_Sonuc_Aciklama": "", + "Taksit": "1", + "Ext_Data": "||||", + "Toplam_Iade_Tutar": "0", + "KK_No": "581877******2285", + "Bank_Extra": "\n 913042<\/AUTH_CODE>\n 2025-01-05 18:12:57.997<\/AUTH_DTTM>\n 1021<\/CAPTURE_AMT>\n 2025-01-05 18:12:57.997<\/CAPTURE_DTTM>\n <\/CAVV_3D>\n S<\/CHARGE_TYPE_CD>\n <\/ECI_3D>\n 0105-181257<\/HOSTDATE>\n 500518472773<\/HOST_REF_NUM>\n <\/MDSTATUS>\n 0<\/NUMCODE>\n ORD_ID:10126021842631\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:1021\tCAPTURE_AMT:1021\tTRANS_STAT:C\tAUTH_DTTM:2025-01-05 18:12:57.997\tCAPTURE_DTTM:2025-01-05 18:12:57.997\tAUTH_CODE:913042\tTRANS_ID:25005SM8B16520<\/ORDERSTATUS>\n 10126021842631<\/ORD_ID>\n 1021<\/ORIG_TRANS_AMT>\n 5818 77** **** 2285<\/PAN>\n 00<\/PROC_RET_CD>\n <\/SETTLEID>\n 25005SM8B16520<\/TRANS_ID>\n C<\/TRANS_STAT>\n <\/XID_3D>\n <\/Extra>", + "Islem_Tip": "PRE_AUTH", + "Bank_Trans_ID": "25005SMEB15694", + "Bank_AuthCode": "570335", + "Bank_HostRefNum": "500518472771" + }, + "Sonuc": "1", + "Sonuc_Str": "Ba\u015far\u0131l\u0131" + } + } +} diff --git a/tests/Unit/test_data/parampos/status_pre_pay_response.json b/tests/Unit/test_data/parampos/status_pre_pay_response.json new file mode 100644 index 00000000..86934485 --- /dev/null +++ b/tests/Unit/test_data/parampos/status_pre_pay_response.json @@ -0,0 +1,30 @@ +{ + "TP_Islem_Sorgulama4Response": { + "TP_Islem_Sorgulama4Result": { + "DT_Bilgi": { + "Odeme_Sonuc": "1", + "Odeme_Sonuc_Aciklama": "\u0130\u015flem Ba\u015far\u0131l\u0131", + "Dekont_ID": "6021842617", + "Siparis_ID": "20250105F546", + "Islem_ID": "79910D3EAD3C10A9769A9BE0", + "Durum": "SUCCESS", + "Tarih": "05.01.2025 16:14:18", + "Toplam_Tutar": "10.01", + "Komisyon_Oran": "1.75", + "Komisyon_Tutar": "0.18", + "Banka_Sonuc_Aciklama": "", + "Taksit": "1", + "Ext_Data": "||||", + "Toplam_Iade_Tutar": "0", + "KK_No": "581877******2285", + "Bank_Extra": "\n 308452<\/AUTH_CODE>\n 2025-01-05 16:14:18.699<\/AUTH_DTTM>\n <\/CAPTURE_AMT>\n <\/CAPTURE_DTTM>\n <\/CAVV_3D>\n S<\/CHARGE_TYPE_CD>\n <\/ECI_3D>\n 0105-161418<\/HOSTDATE>\n 500516472750<\/HOST_REF_NUM>\n <\/MDSTATUS>\n 0<\/NUMCODE>\n ORD_ID:10126021842617\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:1001\tCAPTURE_AMT:\tTRANS_STAT:A\tAUTH_DTTM:2025-01-05 16:14:18.699\tCAPTURE_DTTM:\tAUTH_CODE:308452\tTRANS_ID:25005QOSI13750<\/ORDERSTATUS>\n 10126021842617<\/ORD_ID>\n 1001<\/ORIG_TRANS_AMT>\n 5818 77** **** 2285<\/PAN>\n 00<\/PROC_RET_CD>\n <\/SETTLEID>\n 25005QOSI13750<\/TRANS_ID>\n A<\/TRANS_STAT>\n <\/XID_3D>\n <\/Extra>", + "Islem_Tip": "PRE_AUTH", + "Bank_Trans_ID": "25005QOSI13750", + "Bank_AuthCode": "308452", + "Bank_HostRefNum": "500516472750" + }, + "Sonuc": "1", + "Sonuc_Str": "Ba\u015far\u0131l\u0131" + } + } +} diff --git a/tests/Unit/test_data/parampos/status_pre_pay_then_cancel_response.json b/tests/Unit/test_data/parampos/status_pre_pay_then_cancel_response.json new file mode 100644 index 00000000..dd077224 --- /dev/null +++ b/tests/Unit/test_data/parampos/status_pre_pay_then_cancel_response.json @@ -0,0 +1,30 @@ +{ + "TP_Islem_Sorgulama4Response": { + "TP_Islem_Sorgulama4Result": { + "DT_Bilgi": { + "Odeme_Sonuc": "12", + "Odeme_Sonuc_Aciklama": "\u0130ptal", + "Dekont_ID": "6021842640", + "Siparis_ID": "2025010540D6", + "Islem_ID": "5D966B189881D9CDB572319A", + "Durum": "CANCEL", + "Tarih": "05.01.2025 18:39:33", + "Toplam_Tutar": "10.01", + "Komisyon_Oran": "1.75", + "Komisyon_Tutar": "0.18", + "Banka_Sonuc_Aciklama": "", + "Taksit": "1", + "Ext_Data": "||||", + "Toplam_Iade_Tutar": "0", + "KK_No": "581877******2285", + "Bank_Extra": "\n 105199<\/AUTH_CODE>\n 2025-01-05 18:39:33.691<\/AUTH_DTTM>\n <\/CAPTURE_AMT>\n <\/CAPTURE_DTTM>\n <\/CAVV_3D>\n S<\/CHARGE_TYPE_CD>\n <\/ECI_3D>\n 0105-184025<\/HOSTDATE>\n 500518472763<\/HOST_REF_NUM>\n <\/MDSTATUS>\n 0<\/NUMCODE>\n ORD_ID:10126021842640\tCHARGE_TYPE_CD:S\tORIG_TRANS_AMT:1001\tCAPTURE_AMT:\tTRANS_STAT:V\tAUTH_DTTM:2025-01-05 18:39:33.691\tCAPTURE_DTTM:\tAUTH_CODE:105199\tTRANS_ID:25005SnhJ14709<\/ORDERSTATUS>\n 10126021842640<\/ORD_ID>\n 1001<\/ORIG_TRANS_AMT>\n 5818 77** **** 2285<\/PAN>\n 00<\/PROC_RET_CD>\n <\/SETTLEID>\n 25005SnhJ14709<\/TRANS_ID>\n V<\/TRANS_STAT>\n 2025-01-05 18:40:25.396<\/VOID_DTTM>\n <\/XID_3D>\n <\/Extra>", + "Islem_Tip": "PRE_AUTH", + "Bank_Trans_ID": "25005SnhJ14709", + "Bank_AuthCode": "105199", + "Bank_HostRefNum": "500518472763" + }, + "Sonuc": "1", + "Sonuc_Str": "Ba\u015far\u0131l\u0131" + } + } +}