From dfbc5bf8370236a7d34752f08e4a2c8493d9c7ae Mon Sep 17 00:00:00 2001 From: Ibrahim Gunduz Date: Wed, 2 May 2018 14:27:03 +0000 Subject: [PATCH] Added nestpay processor tests --- docs/31-satis-islemi.md | 24 +- src/Builder/AbstractRequestBuilder.php | 2 +- src/Builder/Gvp/BaseRequestBuilder.php | 19 +- src/Builder/Gvp/CancelRequestBuilder.php | 2 +- .../Gvp/PostAuthorizationRequestBuilder.php | 2 +- .../Gvp/PreAuthorizationRequestBuilder.php | 6 +- src/Builder/Gvp/RefundRequestBuilder.php | 2 +- src/Builder/Gvp/SaleRequestBuilder.php | 6 +- src/Builder/NestPay/BaseRequestBuilder.php | 23 ++ src/Builder/NestPay/CancelRequestBuilder.php | 2 +- .../PostAuthorizationRequestBuilder.php | 2 +- .../PreAuthorizationRequestBuilder.php | 13 +- src/Builder/NestPay/RefundRequestBuilder.php | 2 +- src/Builder/NestPay/SaleRequestBuilder.php | 13 +- src/Builder/Posnet/BaseRequestBuilder.php | 25 +- src/Builder/Posnet/CancelRequestBuilder.php | 2 +- .../PostAuthorizationRequestBuilder.php | 2 +- .../Posnet/PreAuthorizationRequestBuilder.php | 4 +- src/Builder/Posnet/RefundRequestBuilder.php | 2 +- src/Builder/Posnet/SaleRequestBuilder.php | 4 +- src/Pos/AbstractPos.php | 18 +- src/Pos/Gvp.php | 2 +- src/Pos/NestPay.php | 2 +- src/Pos/Posnet.php | 2 +- src/Processor/Gvp/BaseResponseProcessor.php | 14 +- .../NestPay/BaseResponseProcessor.php | 15 +- .../Posnet/BaseResponseProcessor.php | 14 +- src/Request.php | 286 ------------------ src/Request/Request.php | 155 ++++++++++ src/Request/Resource/Card.php | 89 ++++++ src/Request/Resource/ResourceInterface.php | 7 + .../ResponseAbstract.php => Response.php} | 81 ++--- src/Response/InquiryResponse.php | 7 - src/Response/PaymentResponse.php | 7 - src/Response/ResponseInterface.php | 89 ------ .../Builder/Gvp/CancelRequestBuilderTest.php | 2 +- .../PostAuthorizationRequestBuilderTest.php | 2 +- .../PreAuthorizationRequestBuilderTest.php | 11 +- .../Builder/Gvp/RefundRequestBuilderTest.php | 2 +- tests/Builder/Gvp/SaleRequestBuilderTest.php | 17 +- .../NestPay/CancelRequestBuilderTest.php | 2 +- .../PostAuthorizationRequestBuilderTest.php | 2 +- .../PreAuthorizationRequestBuilderTest.php | 10 +- .../NestPay/RefundRequestBuilderTest.php | 2 +- .../NestPay/SaleRequestBuilderTest.php | 17 +- .../Posnet/CancelRequestBuilderTest.php | 2 +- .../PostAuthorizationRequestBuilderTest.php | 2 +- .../PreAuthorizationRequestBuilderTest.php | 18 +- .../Posnet/RefundRequestBuilderTest.php | 2 +- .../Builder/Posnet/SaleRequestBuilderTest.php | 17 +- .../Gvp/CancelResponseProcessorTest.php | 6 +- ...PostAuthorizationResponseProcessorTest.php | 6 +- .../PreAuthorizationResponseProcessorTest.php | 6 +- .../Gvp/RefundResponseProcessorTest.php | 6 +- .../Gvp/SaleResponseProcessorTest.php | 6 +- .../NestPay/CancelResponseProcessorTest.php | 71 +++++ ...PostAuthorizationResponseProcessorTest.php | 71 +++++ .../PreAuthorizationResponseProcessorTest.php | 71 +++++ .../NestPay/RefundResponseProcessorTest.php | 71 +++++ .../NestPay/SaleResponseProcessorTest.php | 71 +++++ .../Posnet/CancelResponseProcessorTest.php | 6 +- ...PostAuthorizationResponseProcessorTest.php | 6 +- .../PreAuthorizationResponseProcessorTest.php | 6 +- .../Posnet/RefundResponseProcessorTest.php | 6 +- .../Posnet/SaleResponseProcessorTest.php | 6 +- .../response/nestpay/cancel_failed.xml | 22 ++ .../response/nestpay/cancel_successful.xml | 24 ++ .../nestpay/post_authorization_failed.xml | 22 ++ .../nestpay/post_authorization_successful.xml | 24 ++ .../nestpay/pre_authorization_failed.xml | 22 ++ .../nestpay/pre_authorization_successful.xml | 24 ++ .../response/nestpay/refund_failed.xml | 22 ++ .../response/nestpay/refund_successful.xml | 24 ++ .../samples/response/nestpay/sale_failed.xml | 22 ++ .../response/nestpay/sale_successful.xml | 24 ++ 75 files changed, 1089 insertions(+), 609 deletions(-) delete mode 100644 src/Request.php create mode 100644 src/Request/Request.php create mode 100644 src/Request/Resource/Card.php create mode 100644 src/Request/Resource/ResourceInterface.php rename src/{Response/ResponseAbstract.php => Response.php} (57%) delete mode 100644 src/Response/InquiryResponse.php delete mode 100644 src/Response/PaymentResponse.php delete mode 100644 src/Response/ResponseInterface.php create mode 100644 tests/Processor/NestPay/CancelResponseProcessorTest.php create mode 100644 tests/Processor/NestPay/PostAuthorizationResponseProcessorTest.php create mode 100644 tests/Processor/NestPay/PreAuthorizationResponseProcessorTest.php create mode 100644 tests/Processor/NestPay/RefundResponseProcessorTest.php create mode 100644 tests/Processor/NestPay/SaleResponseProcessorTest.php create mode 100644 tests/samples/response/nestpay/cancel_failed.xml create mode 100644 tests/samples/response/nestpay/cancel_successful.xml create mode 100644 tests/samples/response/nestpay/post_authorization_failed.xml create mode 100644 tests/samples/response/nestpay/post_authorization_successful.xml create mode 100644 tests/samples/response/nestpay/pre_authorization_failed.xml create mode 100644 tests/samples/response/nestpay/pre_authorization_successful.xml create mode 100644 tests/samples/response/nestpay/refund_failed.xml create mode 100644 tests/samples/response/nestpay/refund_successful.xml create mode 100644 tests/samples/response/nestpay/sale_failed.xml create mode 100644 tests/samples/response/nestpay/sale_successful.xml diff --git a/docs/31-satis-islemi.md b/docs/31-satis-islemi.md index a28c3d3..b2b2f6e 100644 --- a/docs/31-satis-islemi.md +++ b/docs/31-satis-islemi.md @@ -10,13 +10,15 @@ Satış isteği, **Paranoia\Request** tipinde bir nesnenin sipariş ve ödeme a ```php $request = new \Paranoia\Request(); -$request->setCardNumber('5406******675403') - ->setSecurityCode('000') - ->setExpireMonth(12) - ->setExpireYear(2015) - ->setOrderId('ORDER000000' . time()) +$request->setOrderId('ORDER000000' . time()) ->setAmount(100.35) ->setCurrency('TRY'); +$card = new \Paranoia\Resource\Card(); +$card->setNumber('5406******675403') + ->setSecurityCode('000') + ->setExpireMonth(12) + ->setExpireYear(2015); +$request->setResource($card); ``` ## 3.1.3. Satış İsteği Sırasında Beklenen Parametreler @@ -36,13 +38,15 @@ $request->setCardNumber('5406******675403') * Satış işlemi için yeni bir sipariş isteği oluşturuyoruz. ```php $request = new \Paranoia\Request(); -$request->setCardNumber('5406******675403') - ->setSecurityCode('000') - ->setExpireMonth(12) - ->setExpireYear(2015) - ->setOrderId('ORDER000000' . time()) +$request->setOrderId('ORDER000000' . time()) ->setAmount(100.35) ->setCurrency('TRY'); +$card = new \Paranoia\Resource\Card(); +$card->setNumber('5406******675403') + ->setSecurityCode('000') + ->setExpireMonth(12) + ->setExpireYear(2015); +$request->setResource($card); ``` * Sağlayıcı API'sine bağlantı kurmak için gerekli konfigürasyon bilgilerini dolduruyoruz. Konfigürasyon parametreleri, ödeme sistemi sağlayıcısına göre değişkenlik göstermektedir. Ödeme sağlayıcılarına göre gerekli konfigürasyon tanımlamaları hakkında daha fazla bilgi edinmek için [bu bölümü]() inceleyiniz. diff --git a/src/Builder/AbstractRequestBuilder.php b/src/Builder/AbstractRequestBuilder.php index d10fdf4..addd354 100644 --- a/src/Builder/AbstractRequestBuilder.php +++ b/src/Builder/AbstractRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder; use Paranoia\Configuration\AbstractConfiguration; -use Paranoia\Request; +use Paranoia\Request\Request; abstract class AbstractRequestBuilder { diff --git a/src/Builder/Gvp/BaseRequestBuilder.php b/src/Builder/Gvp/BaseRequestBuilder.php index f5a0030..f23aa11 100644 --- a/src/Builder/Gvp/BaseRequestBuilder.php +++ b/src/Builder/Gvp/BaseRequestBuilder.php @@ -8,7 +8,9 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\MoneyFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; +use Paranoia\Request\Resource\ResourceInterface; abstract class BaseRequestBuilder extends AbstractRequestBuilder { @@ -96,19 +98,24 @@ protected function buildTerminal(Request $request) ); } - protected function buildCard(Request $request) + protected function buildCard(ResourceInterface $card) { + assert($card instanceof Card); + + /** @var Card $_card */ + $_card = $card; + $expireMonth = $this->expireDateFormatter->format( [ - $request->getExpireMonth(), - $request->getExpireYear() + $_card->getExpireMonth(), + $_card->getExpireYear() ] ); return array( - 'Number' => $request->getCardNumber(), + 'Number' => $_card->getNumber(), 'ExpireDate' => $expireMonth, - 'CVV2' => $request->getSecurityCode() + 'CVV2' => $_card->getSecurityCode() ); } diff --git a/src/Builder/Gvp/CancelRequestBuilder.php b/src/Builder/Gvp/CancelRequestBuilder.php index 519eabd..ab99c60 100644 --- a/src/Builder/Gvp/CancelRequestBuilder.php +++ b/src/Builder/Gvp/CancelRequestBuilder.php @@ -3,7 +3,7 @@ use Paranoia\Common\Serializer\Serializer; use Paranoia\Configuration\Gvp; -use Paranoia\Request; +use Paranoia\Request\Request; class CancelRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/Gvp/PostAuthorizationRequestBuilder.php b/src/Builder/Gvp/PostAuthorizationRequestBuilder.php index 1a813dd..8cca901 100644 --- a/src/Builder/Gvp/PostAuthorizationRequestBuilder.php +++ b/src/Builder/Gvp/PostAuthorizationRequestBuilder.php @@ -3,7 +3,7 @@ use Paranoia\Common\Serializer\Serializer; use Paranoia\Configuration\Gvp; -use Paranoia\Request; +use Paranoia\Request\Request; class PostAuthorizationRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/Gvp/PreAuthorizationRequestBuilder.php b/src/Builder/Gvp/PreAuthorizationRequestBuilder.php index 2dde493..ea15eac 100644 --- a/src/Builder/Gvp/PreAuthorizationRequestBuilder.php +++ b/src/Builder/Gvp/PreAuthorizationRequestBuilder.php @@ -3,7 +3,7 @@ use Paranoia\Common\Serializer\Serializer; use Paranoia\Configuration\Gvp; -use Paranoia\Request; +use Paranoia\Request\Request; class PreAuthorizationRequestBuilder extends BaseRequestBuilder { @@ -14,7 +14,7 @@ public function build(Request $request) { $data = array_merge( $this->buildBaseRequest($request), - ['Card' => $this->buildCard($request)] + ['Card' => $this->buildCard($request->getResource())] ); $serializer = new Serializer(Serializer::XML); @@ -53,7 +53,7 @@ protected function buildHash(Request $request, $password) '%s%s%s%s%s', $request->getOrderId(), $configuration->getTerminalId(), - $request->getCardNumber(), + $request->getResource()->getNumber(), $this->amountFormatter->format($request->getAmount()), $this->generateSecurityHash($password) ) diff --git a/src/Builder/Gvp/RefundRequestBuilder.php b/src/Builder/Gvp/RefundRequestBuilder.php index 17a3a4e..179bcb4 100644 --- a/src/Builder/Gvp/RefundRequestBuilder.php +++ b/src/Builder/Gvp/RefundRequestBuilder.php @@ -3,7 +3,7 @@ use Paranoia\Common\Serializer\Serializer; use Paranoia\Configuration\Gvp; -use Paranoia\Request; +use Paranoia\Request\Request; class RefundRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/Gvp/SaleRequestBuilder.php b/src/Builder/Gvp/SaleRequestBuilder.php index 4f6c916..76607d2 100644 --- a/src/Builder/Gvp/SaleRequestBuilder.php +++ b/src/Builder/Gvp/SaleRequestBuilder.php @@ -3,7 +3,7 @@ use Paranoia\Common\Serializer\Serializer; use Paranoia\Configuration\Gvp; -use Paranoia\Request; +use Paranoia\Request\Request; class SaleRequestBuilder extends BaseRequestBuilder { @@ -14,7 +14,7 @@ public function build(Request $request) { $data = array_merge( $this->buildBaseRequest($request), - ['Card' => $this->buildCard($request)] + ['Card' => $this->buildCard($request->getResource())] ); $serializer = new Serializer(Serializer::XML); @@ -54,7 +54,7 @@ protected function buildHash(Request $request, $password) '%s%s%s%s%s', $request->getOrderId(), $configuration->getTerminalId(), - $request->getCardNumber(), + $request->getResource()->getNumber(), $this->amountFormatter->format($request->getAmount()), $this->generateSecurityHash($password) ) diff --git a/src/Builder/NestPay/BaseRequestBuilder.php b/src/Builder/NestPay/BaseRequestBuilder.php index 6d1a21a..7162f3d 100644 --- a/src/Builder/NestPay/BaseRequestBuilder.php +++ b/src/Builder/NestPay/BaseRequestBuilder.php @@ -7,6 +7,8 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\NestPay\ExpireDateFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; +use Paranoia\Request\Resource\Card; +use Paranoia\Request\Resource\ResourceInterface; abstract class BaseRequestBuilder extends AbstractRequestBuilder { @@ -48,4 +50,25 @@ protected function buildBaseRequest($type) 'Type' => $type, ]; } + + protected function buildCard(ResourceInterface $card) + { + assert($card instanceof Card); + + /** @var Card $_card */ + $_card = $card; + + $expireDate = $this->expireDateFormatter->format( + [ + $_card->getExpireMonth(), + $_card->getExpireYear() + ] + ); + + return array( + 'Number' => $_card->getNumber(), + 'Cvv2Val' => $_card->getSecurityCode(), + 'Expires' => $expireDate + ); + } } diff --git a/src/Builder/NestPay/CancelRequestBuilder.php b/src/Builder/NestPay/CancelRequestBuilder.php index 89068ab..7ed3828 100644 --- a/src/Builder/NestPay/CancelRequestBuilder.php +++ b/src/Builder/NestPay/CancelRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\NestPay; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class CancelRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/NestPay/PostAuthorizationRequestBuilder.php b/src/Builder/NestPay/PostAuthorizationRequestBuilder.php index cfb2285..a5d53d4 100644 --- a/src/Builder/NestPay/PostAuthorizationRequestBuilder.php +++ b/src/Builder/NestPay/PostAuthorizationRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\NestPay; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class PostAuthorizationRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/NestPay/PreAuthorizationRequestBuilder.php b/src/Builder/NestPay/PreAuthorizationRequestBuilder.php index c4317c0..fa2eea3 100644 --- a/src/Builder/NestPay/PreAuthorizationRequestBuilder.php +++ b/src/Builder/NestPay/PreAuthorizationRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\NestPay; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class PreAuthorizationRequestBuilder extends BaseRequestBuilder { @@ -17,15 +17,8 @@ public function build(Request $request) 'OrderId' => $request->getOrderId(), 'Total' => $this->amountFormatter->format($request->getAmount()), 'Currency' => $this->currencyCodeFormatter->format($request->getCurrency()), - 'Number' => $request->getCardNumber(), - 'Cvv2Val' => $request->getSecurityCode(), - 'Expires' => $this->expireDateFormatter->format( - [ - $request->getExpireMonth(), - $request->getExpireYear() - ] - ), - ] + ], + $this->buildCard($request->getResource()) ); $serializer = new Serializer(Serializer::XML); diff --git a/src/Builder/NestPay/RefundRequestBuilder.php b/src/Builder/NestPay/RefundRequestBuilder.php index b4fddb9..d150752 100644 --- a/src/Builder/NestPay/RefundRequestBuilder.php +++ b/src/Builder/NestPay/RefundRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\NestPay; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class RefundRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/NestPay/SaleRequestBuilder.php b/src/Builder/NestPay/SaleRequestBuilder.php index 45bc625..5aadfc4 100644 --- a/src/Builder/NestPay/SaleRequestBuilder.php +++ b/src/Builder/NestPay/SaleRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\NestPay; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class SaleRequestBuilder extends BaseRequestBuilder { @@ -17,15 +17,8 @@ public function build(Request $request) 'OrderId' => $request->getOrderId(), 'Total' => $this->amountFormatter->format($request->getAmount()), 'Currency' => $this->currencyCodeFormatter->format($request->getCurrency()), - 'Number' => $request->getCardNumber(), - 'Cvv2Val' => $request->getSecurityCode(), - 'Expires' => $this->expireDateFormatter->format( - [ - $request->getExpireMonth(), - $request->getExpireYear() - ] - ), - ] + ], + $this->buildCard($request->getResource()) ); if ($request->getInstallment()) { diff --git a/src/Builder/Posnet/BaseRequestBuilder.php b/src/Builder/Posnet/BaseRequestBuilder.php index fba0370..08ce526 100644 --- a/src/Builder/Posnet/BaseRequestBuilder.php +++ b/src/Builder/Posnet/BaseRequestBuilder.php @@ -9,17 +9,19 @@ use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter; use Paranoia\Formatter\Posnet\ExpireDateFormatter; use Paranoia\Formatter\Posnet\OrderIdFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; +use Paranoia\Request\Resource\ResourceInterface; abstract class BaseRequestBuilder extends AbstractRequestBuilder { - /** @var DecimalFormatter */ + /** @var MoneyFormatter */ protected $amountFormatter; - /** @var IsoNumericCurrencyCodeFormatter */ + /** @var CustomCurrencyCodeFormatter */ protected $currencyCodeFormatter; - /** @var SingleDigitInstallmentFormatter */ + /** @var MultiDigitInstallmentFormatter */ protected $installmentFormatter; /** @var ExpireDateFormatter */ @@ -56,15 +58,20 @@ protected function buildBaseRequest(Request $request) ]; } - protected function buildCard(Request $request) + protected function buildCard(ResourceInterface $card) { + assert($card instanceof Card); + + /** @var Card $_card */ + $_card = $card; + return [ - 'ccno' => $request->getCardNumber(), - 'cvc' => $request->getSecurityCode(), + 'ccno' => $_card->getNumber(), + 'cvc' => $_card->getSecurityCode(), 'expDate' => $this->expireDateFormatter->format( [ - $request->getExpireMonth(), - $request->getExpireYear() + $_card->getExpireMonth(), + $_card->getExpireYear() ] ) ]; diff --git a/src/Builder/Posnet/CancelRequestBuilder.php b/src/Builder/Posnet/CancelRequestBuilder.php index 0eafaf1..eed6e13 100644 --- a/src/Builder/Posnet/CancelRequestBuilder.php +++ b/src/Builder/Posnet/CancelRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\Posnet; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class CancelRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/Posnet/PostAuthorizationRequestBuilder.php b/src/Builder/Posnet/PostAuthorizationRequestBuilder.php index 2d41226..112c155 100644 --- a/src/Builder/Posnet/PostAuthorizationRequestBuilder.php +++ b/src/Builder/Posnet/PostAuthorizationRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\Posnet; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class PostAuthorizationRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/Posnet/PreAuthorizationRequestBuilder.php b/src/Builder/Posnet/PreAuthorizationRequestBuilder.php index 9550b85..1f97878 100644 --- a/src/Builder/Posnet/PreAuthorizationRequestBuilder.php +++ b/src/Builder/Posnet/PreAuthorizationRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\Posnet; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class PreAuthorizationRequestBuilder extends BaseRequestBuilder { @@ -20,7 +20,7 @@ public function build(Request $request) 'currencyCode' => $this->currencyCodeFormatter->format($request->getCurrency()), 'orderID' => $this->orderIdFormatter->format($request->getOrderId()) ], - $this->buildCard($request) + $this->buildCard($request->getResource()) ) ] ); diff --git a/src/Builder/Posnet/RefundRequestBuilder.php b/src/Builder/Posnet/RefundRequestBuilder.php index 9a1e0b6..ddd658e 100644 --- a/src/Builder/Posnet/RefundRequestBuilder.php +++ b/src/Builder/Posnet/RefundRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\Posnet; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class RefundRequestBuilder extends BaseRequestBuilder { diff --git a/src/Builder/Posnet/SaleRequestBuilder.php b/src/Builder/Posnet/SaleRequestBuilder.php index dde4cd1..a753ad1 100644 --- a/src/Builder/Posnet/SaleRequestBuilder.php +++ b/src/Builder/Posnet/SaleRequestBuilder.php @@ -2,7 +2,7 @@ namespace Paranoia\Builder\Posnet; use Paranoia\Common\Serializer\Serializer; -use Paranoia\Request; +use Paranoia\Request\Request; class SaleRequestBuilder extends BaseRequestBuilder { @@ -20,7 +20,7 @@ public function build(Request $request) 'currencyCode' => $this->currencyCodeFormatter->format($request->getCurrency()), 'orderID' => $this->orderIdFormatter->format($request->getOrderId()) ], - $this->buildCard($request) + $this->buildCard($request->getResource()) ) ] ); diff --git a/src/Pos/AbstractPos.php b/src/Pos/AbstractPos.php index c02c7c2..259b2cb 100644 --- a/src/Pos/AbstractPos.php +++ b/src/Pos/AbstractPos.php @@ -5,7 +5,7 @@ use Guzzle\Http\Exception\RequestException; use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\CommunicationError; -use Paranoia\Request; +use Paranoia\Request\Request; use Paranoia\TransactionType; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -40,7 +40,7 @@ abstract protected function buildRequest(Request $request, $transactionType); * @param string $rawResponse * @param string $transactionType * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ abstract protected function parseResponse($rawResponse, $transactionType); @@ -82,7 +82,7 @@ private function performTransaction(Request $request, $transactionType) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function preAuthorization(Request $request) { @@ -92,7 +92,7 @@ public function preAuthorization(Request $request) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function postAuthorization(Request $request) { @@ -102,7 +102,7 @@ public function postAuthorization(Request $request) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function sale(Request $request) { @@ -112,7 +112,7 @@ public function sale(Request $request) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function refund(Request $request) { @@ -122,7 +122,7 @@ public function refund(Request $request) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function cancel(Request $request) { @@ -132,7 +132,7 @@ public function cancel(Request $request) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function pointQuery(Request $request) { @@ -142,7 +142,7 @@ public function pointQuery(Request $request) /** * @param \Paranoia\Request $request * - * @return \Paranoia\Response\PaymentResponse + * @return \Paranoia\Response\Response */ public function pointUsage(Request $request) { diff --git a/src/Pos/Gvp.php b/src/Pos/Gvp.php index e23358d..855ce7a 100644 --- a/src/Pos/Gvp.php +++ b/src/Pos/Gvp.php @@ -4,7 +4,7 @@ use Paranoia\Builder\GvpBuilderFactory; use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Processor\GvpProcessorFactory; -use Paranoia\Request; +use Paranoia\Request\Request; class Gvp extends AbstractPos { diff --git a/src/Pos/NestPay.php b/src/Pos/NestPay.php index d0913a5..d765701 100644 --- a/src/Pos/NestPay.php +++ b/src/Pos/NestPay.php @@ -5,7 +5,7 @@ use Paranoia\Builder\NestPayBuilderFactory; use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Processor\NestPayProcessorFactory; -use Paranoia\Request; +use Paranoia\Request\Request; class NestPay extends AbstractPos { diff --git a/src/Pos/Posnet.php b/src/Pos/Posnet.php index 43187cf..ababd15 100644 --- a/src/Pos/Posnet.php +++ b/src/Pos/Posnet.php @@ -4,7 +4,7 @@ use Paranoia\Builder\PosnetBuilderFactory; use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Processor\PosnetProcessorFactory; -use Paranoia\Request; +use Paranoia\Request\Request; class Posnet extends AbstractPos { diff --git a/src/Processor/Gvp/BaseResponseProcessor.php b/src/Processor/Gvp/BaseResponseProcessor.php index c66d46a..e846492 100644 --- a/src/Processor/Gvp/BaseResponseProcessor.php +++ b/src/Processor/Gvp/BaseResponseProcessor.php @@ -3,15 +3,15 @@ use Paranoia\Exception\BadResponseException; use Paranoia\Processor\AbstractResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; abstract class BaseResponseProcessor extends AbstractResponseProcessor { /** * @param \SimpleXMLElement $xml - * @param PaymentResponse $response + * @param Response $response */ - private function prepareErrorDetails(\SimpleXMLElement $xml, PaymentResponse $response) + private function prepareErrorDetails(\SimpleXMLElement $xml, Response $response) { $errorMessages = array(); if (property_exists($xml->Transaction->Response, 'ErrorMsg')) { @@ -32,9 +32,9 @@ private function prepareErrorDetails(\SimpleXMLElement $xml, PaymentResponse $re /** * @param \SimpleXMLElement $xml - * @param PaymentResponse $response + * @param Response $response */ - private function prepareTransactionDetails(\SimpleXMLElement $xml, PaymentResponse $response) + private function prepareTransactionDetails(\SimpleXMLElement $xml, Response $response) { if (property_exists($xml, 'Order') && property_exists($xml->Order, 'OrderID')) { $response->setOrderId((string)$xml->Order->OrderID); @@ -53,12 +53,12 @@ private function prepareTransactionDetails(\SimpleXMLElement $xml, PaymentRespon /** * @param $rawResponse - * @return PaymentResponse + * @return Response * @throws BadResponseException */ protected function processCommonResponse($rawResponse) { - $response = new PaymentResponse(); + $response = new Response(); try { /** @var \SimpleXMLElement $xml */ $xml = new \SimpleXmlElement($rawResponse); diff --git a/src/Processor/NestPay/BaseResponseProcessor.php b/src/Processor/NestPay/BaseResponseProcessor.php index 917ba33..42f7862 100644 --- a/src/Processor/NestPay/BaseResponseProcessor.php +++ b/src/Processor/NestPay/BaseResponseProcessor.php @@ -3,15 +3,15 @@ use Paranoia\Exception\BadResponseException; use Paranoia\Processor\AbstractResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; abstract class BaseResponseProcessor extends AbstractResponseProcessor { /** * @param \SimpleXMLElement $xml - * @param PaymentResponse $response + * @param Response $response */ - private function prepareErrorDetails(\SimpleXMLElement $xml, PaymentResponse $response) + private function prepareErrorDetails(\SimpleXMLElement $xml, Response $response) { $errorMessages = array(); if (property_exists($xml, 'Error')) { @@ -35,17 +35,18 @@ private function prepareErrorDetails(\SimpleXMLElement $xml, PaymentResponse $re /** * @param \SimpleXMLElement $xml - * @param PaymentResponse $response + * @param Response $response */ - private function prepareTransactionDetails(\SimpleXMLElement $xml, PaymentResponse $response) + private function prepareTransactionDetails(\SimpleXMLElement $xml, Response $response) { $response->setOrderId((string)$xml->OrderId); $response->setTransactionId((string)$xml->TransId); + $response->setAuthCode((string) $xml->AuthCode); } /** * @param $rawResponse - * @return PaymentResponse + * @return Response * @throws BadResponseException */ protected function processCommonResponse($rawResponse) @@ -58,7 +59,7 @@ protected function processCommonResponse($rawResponse) throw $exception; } $this->validateResponse($xml); - $response = new PaymentResponse(); + $response = new Response(); $response->setIsSuccess((string)$xml->Response == 'Approved'); $response->setResponseCode((string)$xml->ProcReturnCode); if (!$response->isSuccess()) { diff --git a/src/Processor/Posnet/BaseResponseProcessor.php b/src/Processor/Posnet/BaseResponseProcessor.php index 5ca3fe1..1480fe5 100644 --- a/src/Processor/Posnet/BaseResponseProcessor.php +++ b/src/Processor/Posnet/BaseResponseProcessor.php @@ -3,15 +3,15 @@ use Paranoia\Exception\BadResponseException; use Paranoia\Processor\AbstractResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; abstract class BaseResponseProcessor extends AbstractResponseProcessor { /** * @param \SimpleXMLElement $xml - * @param PaymentResponse $response + * @param Response $response */ - private function prepareErrorDetails(\SimpleXMLElement $xml, PaymentResponse $response) + private function prepareErrorDetails(\SimpleXMLElement $xml, Response $response) { $errorMessages = array(); if (property_exists($xml, 'respCode')) { @@ -26,9 +26,9 @@ private function prepareErrorDetails(\SimpleXMLElement $xml, PaymentResponse $re /** * @param \SimpleXMLElement $xml - * @param PaymentResponse $response + * @param Response $response */ - private function prepareTransactionDetails(\SimpleXMLElement $xml, PaymentResponse $response) + private function prepareTransactionDetails(\SimpleXMLElement $xml, Response $response) { if (property_exists($xml, 'orderId')) { $response->setOrderId((string)$xml->orderId); @@ -41,7 +41,7 @@ private function prepareTransactionDetails(\SimpleXMLElement $xml, PaymentRespon /** * @param $rawResponse - * @return PaymentResponse + * @return Response * @throws BadResponseException */ protected function processCommonResponse($rawResponse) @@ -54,7 +54,7 @@ protected function processCommonResponse($rawResponse) throw $exception; } $this->validateResponse($xml); - $response = new PaymentResponse(); + $response = new Response(); $response->setIsSuccess((int)$xml->approved > 0); if (!$response->isSuccess()) { $this->prepareErrorDetails($xml, $response); diff --git a/src/Request.php b/src/Request.php deleted file mode 100644 index 9831797..0000000 --- a/src/Request.php +++ /dev/null @@ -1,286 +0,0 @@ -orderId; - } - - /** - * sets order identity to request object. - * - * @param $orderId - * - * @return self - */ - public function setOrderId($orderId) - { - $this->orderId = $orderId; - return $this; - } - - /** - * returns order amount. - * - * @return float - */ - public function getAmount() - { - return $this->amount; - } - - /** - * sets order amount to request object. - * - * @param float $amount - * - * @return self - */ - public function setAmount($amount) - { - $this->amount = $amount; - return $this; - } - - /** - * returns currency code string which is three digit. - * - * @return string - */ - public function getCurrency() - { - return $this->currency; - } - - /** - * sets currency code to request object. - * - * @param string $currency - * - * @return self - */ - public function setCurrency($currency) - { - $this->currency = $currency; - return $this; - } - - /** - * returns installment amount. - * - * @return integer - */ - public function getInstallment() - { - return $this->installment; - } - - /** - * set installment amount to object. - * - * @param integer $installment - * - * @return self - */ - public function setInstallment($installment) - { - $this->installment = $installment; - return $this; - } - - /** - * returns card number. - * - * @return string - */ - public function getCardNumber() - { - return $this->cardNumber; - } - - /** - * sets card number to request object. - * - * @param string $cardNumber Numeric value - * - * @return self - */ - public function setCardNumber($cardNumber) - { - $this->cardNumber = $cardNumber; - return $this; - } - - /** - * returns card security code. - * - * @return string - */ - public function getSecurityCode() - { - return $this->securityCode; - } - - /** - * sets card security code to request object. - * - * @param string $securityCode - * - * @return self - */ - public function setSecurityCode($securityCode) - { - $this->securityCode = $securityCode; - return $this; - } - - /** - * returns expire month of card. - * - * @return integer - */ - public function getExpireMonth() - { - return $this->expireMonth; - } - - /** - * sets card expire month to request object. - * - * @param integer $expireMonth - * - * @return self - */ - public function setExpireMonth($expireMonth) - { - $this->expireMonth = $expireMonth; - return $this; - } - - /** - * returns expire year of card. - * - * @return integer - */ - public function getExpireYear() - { - return $this->expireYear; - } - - /** - * sets card expire year to request object. - * - * @param integer $expireYear - * - * @return self - */ - public function setExpireYear($expireYear) - { - $this->expireYear = $expireYear; - return $this; - } - - /** - * returns transaction id. - * - * @return string - */ - public function getTransactionId() - { - return $this->transactionId; - } - - /** - * sets transaction id to request object. - * - * @param string $transactionId - * - * @return self - */ - public function setTransactionId($transactionId) - { - $this->transactionId = $transactionId; - return $this; - } - - /** - * returns auth code. - * - * @return string - */ - public function getAuthCode() - { - return $this->authCode; - } - - /** - * sets auth code to request object. - * - * @param string $authCode - * - * @return self - */ - public function setAuthCode($authCode) - { - $this->authCode = $authCode; - return $this; - } -} diff --git a/src/Request/Request.php b/src/Request/Request.php new file mode 100644 index 0000000..087920b --- /dev/null +++ b/src/Request/Request.php @@ -0,0 +1,155 @@ +orderId; + } + + /** + * @param string $orderId + * @return Request + */ + public function setOrderId($orderId) + { + $this->orderId = $orderId; + return $this; + } + + /** + * @return float + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @param float $amount + * @return Request + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * @param string $currency + * @return Request + */ + public function setCurrency($currency) + { + $this->currency = $currency; + return $this; + } + + /** + * @return int + */ + public function getInstallment() + { + return $this->installment; + } + + /** + * @param int $installment + * @return Request + */ + public function setInstallment($installment) + { + $this->installment = $installment; + return $this; + } + + /** + * @return string + */ + public function getTransactionId() + { + return $this->transactionId; + } + + /** + * @param string $transactionId + * @return Request + */ + public function setTransactionId($transactionId) + { + $this->transactionId = $transactionId; + return $this; + } + + /** + * @return string + */ + public function getAuthCode() + { + return $this->authCode; + } + + /** + * @param string $authCode + * @return Request + */ + public function setAuthCode($authCode) + { + $this->authCode = $authCode; + return $this; + } + + /** + * @return ResourceInterface + */ + public function getResource() + { + return $this->resource; + } + + /** + * @param ResourceInterface $resource + * @return Request + */ + public function setResource($resource) + { + $this->resource = $resource; + return $this; + } +} diff --git a/src/Request/Resource/Card.php b/src/Request/Resource/Card.php new file mode 100644 index 0000000..3d18b94 --- /dev/null +++ b/src/Request/Resource/Card.php @@ -0,0 +1,89 @@ +number; + } + + /** + * @param string $number + * @return Card + */ + public function setNumber($number) + { + $this->number = $number; + return $this; + } + + /** + * @return string + */ + public function getSecurityCode() + { + return $this->securityCode; + } + + /** + * @param string $securityCode + * @return Card + */ + public function setSecurityCode($securityCode) + { + $this->securityCode = $securityCode; + return $this; + } + + /** + * @return int + */ + public function getExpireMonth() + { + return $this->expireMonth; + } + + /** + * @param int $expireMonth + * @return Card + */ + public function setExpireMonth($expireMonth) + { + $this->expireMonth = $expireMonth; + return $this; + } + + /** + * @return int + */ + public function getExpireYear() + { + return $this->expireYear; + } + + /** + * @param int $expireYear + * @return Card + */ + public function setExpireYear($expireYear) + { + $this->expireYear = $expireYear; + return $this; + } +} diff --git a/src/Request/Resource/ResourceInterface.php b/src/Request/Resource/ResourceInterface.php new file mode 100644 index 0000000..4f71c9b --- /dev/null +++ b/src/Request/Resource/ResourceInterface.php @@ -0,0 +1,7 @@ +setOrderId('123456') ->setAmount(25.4) - ->setCurrency(Currency::CODE_EUR) - ->setCardNumber('1501501501501500') + ->setCurrency(Currency::CODE_EUR); + + $card = new Card(); + $card->setNumber('1501501501501500') ->setSecurityCode('000') ->setExpireMonth(1) ->setExpireYear(2020); + $request->setResource($card); + return $request; } diff --git a/tests/Builder/Gvp/RefundRequestBuilderTest.php b/tests/Builder/Gvp/RefundRequestBuilderTest.php index b22501b..1035141 100644 --- a/tests/Builder/Gvp/RefundRequestBuilderTest.php +++ b/tests/Builder/Gvp/RefundRequestBuilderTest.php @@ -8,7 +8,7 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\MoneyFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; class RefundRequestBuilderTest extends TestCase diff --git a/tests/Builder/Gvp/SaleRequestBuilderTest.php b/tests/Builder/Gvp/SaleRequestBuilderTest.php index 1e85d47..c948bb1 100644 --- a/tests/Builder/Gvp/SaleRequestBuilderTest.php +++ b/tests/Builder/Gvp/SaleRequestBuilderTest.php @@ -8,7 +8,8 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\MoneyFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; use PHPUnit\Framework\TestCase; class SaleRequestBuilderTest extends TestCase @@ -57,14 +58,18 @@ protected function setupRequest($setInstallment=false) $request = new Request(); $request->setOrderId('123456') ->setAmount(25.4) - ->setCurrency(Currency::CODE_EUR) - ->setCardNumber('1501501501501500') - ->setSecurityCode('000') - ->setExpireMonth(1) - ->setExpireYear(2020); + ->setCurrency(Currency::CODE_EUR); if($setInstallment) { $request->setInstallment(3); } + + $card = new Card(); + $card->setNumber('1501501501501500') + ->setSecurityCode('000') + ->setExpireMonth(1) + ->setExpireYear(2020); + $request->setResource($card); + return $request; } diff --git a/tests/Builder/NestPay/CancelRequestBuilderTest.php b/tests/Builder/NestPay/CancelRequestBuilderTest.php index a60a21e..385b70e 100644 --- a/tests/Builder/NestPay/CancelRequestBuilderTest.php +++ b/tests/Builder/NestPay/CancelRequestBuilderTest.php @@ -7,7 +7,7 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\NestPay\ExpireDateFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; class CancelRequestBuilderTest extends TestCase diff --git a/tests/Builder/NestPay/PostAuthorizationRequestBuilderTest.php b/tests/Builder/NestPay/PostAuthorizationRequestBuilderTest.php index b7028b3..beb40c4 100644 --- a/tests/Builder/NestPay/PostAuthorizationRequestBuilderTest.php +++ b/tests/Builder/NestPay/PostAuthorizationRequestBuilderTest.php @@ -7,7 +7,7 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\NestPay\ExpireDateFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; class PostAuthorizationRequestBuilderTest extends TestCase diff --git a/tests/Builder/NestPay/PreAuthorizationRequestBuilderTest.php b/tests/Builder/NestPay/PreAuthorizationRequestBuilderTest.php index 67d4c7f..9c161eb 100644 --- a/tests/Builder/NestPay/PreAuthorizationRequestBuilderTest.php +++ b/tests/Builder/NestPay/PreAuthorizationRequestBuilderTest.php @@ -8,7 +8,8 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\NestPay\ExpireDateFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; use PHPUnit\Framework\TestCase; class PreAuthorizationRequestBuilderTest extends TestCase @@ -44,11 +45,14 @@ protected function setupRequest() $request = new Request(); $request->setOrderId('123456') ->setAmount(25.4) - ->setCurrency(Currency::CODE_EUR) - ->setCardNumber('1501501501501500') + ->setCurrency(Currency::CODE_EUR); + + $card = new Card(); + $card->setNumber('1501501501501500') ->setSecurityCode('000') ->setExpireMonth(1) ->setExpireYear(2020); + $request->setResource($card); return $request; } diff --git a/tests/Builder/NestPay/RefundRequestBuilderTest.php b/tests/Builder/NestPay/RefundRequestBuilderTest.php index a99a4e2..9bed94a 100644 --- a/tests/Builder/NestPay/RefundRequestBuilderTest.php +++ b/tests/Builder/NestPay/RefundRequestBuilderTest.php @@ -8,7 +8,7 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\NestPay\ExpireDateFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; #TODO: Ensure whether the provider allow full refund without amount and currency fields class RefundRequestBuilderTest extends TestCase diff --git a/tests/Builder/NestPay/SaleRequestBuilderTest.php b/tests/Builder/NestPay/SaleRequestBuilderTest.php index fb7b349..f05e72d 100644 --- a/tests/Builder/NestPay/SaleRequestBuilderTest.php +++ b/tests/Builder/NestPay/SaleRequestBuilderTest.php @@ -8,7 +8,8 @@ use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; use Paranoia\Formatter\NestPay\ExpireDateFormatter; use Paranoia\Formatter\SingleDigitInstallmentFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; use PHPUnit\Framework\TestCase; class SaleRequestBuilderTest extends TestCase @@ -54,14 +55,18 @@ protected function setupRequest($setInstallment=false) $request = new Request(); $request->setOrderId('123456') ->setAmount(25.4) - ->setCurrency(Currency::CODE_EUR) - ->setCardNumber('1501501501501500') - ->setSecurityCode('000') - ->setExpireMonth(1) - ->setExpireYear(2020); + ->setCurrency(Currency::CODE_EUR); if($setInstallment) { $request->setInstallment(3); } + + $card = new Card(); + $card->setNumber('1501501501501500') + ->setSecurityCode('000') + ->setExpireMonth(1) + ->setExpireYear(2020); + $request->setResource($card); + return $request; } diff --git a/tests/Builder/Posnet/CancelRequestBuilderTest.php b/tests/Builder/Posnet/CancelRequestBuilderTest.php index dc24473..ae6ab52 100644 --- a/tests/Builder/Posnet/CancelRequestBuilderTest.php +++ b/tests/Builder/Posnet/CancelRequestBuilderTest.php @@ -7,7 +7,7 @@ use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter; use Paranoia\Formatter\Posnet\ExpireDateFormatter; use Paranoia\Formatter\Posnet\OrderIdFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; use Paranoia\Configuration\Posnet as PosnetConfiguration; diff --git a/tests/Builder/Posnet/PostAuthorizationRequestBuilderTest.php b/tests/Builder/Posnet/PostAuthorizationRequestBuilderTest.php index 1c2fe2f..942ac73 100644 --- a/tests/Builder/Posnet/PostAuthorizationRequestBuilderTest.php +++ b/tests/Builder/Posnet/PostAuthorizationRequestBuilderTest.php @@ -8,7 +8,7 @@ use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter; use Paranoia\Formatter\Posnet\ExpireDateFormatter; use Paranoia\Formatter\Posnet\OrderIdFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; use Paranoia\Configuration\Posnet as PosnetConfiguration; diff --git a/tests/Builder/Posnet/PreAuthorizationRequestBuilderTest.php b/tests/Builder/Posnet/PreAuthorizationRequestBuilderTest.php index c0036de..ad03185 100644 --- a/tests/Builder/Posnet/PreAuthorizationRequestBuilderTest.php +++ b/tests/Builder/Posnet/PreAuthorizationRequestBuilderTest.php @@ -8,7 +8,8 @@ use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter; use Paranoia\Formatter\Posnet\ExpireDateFormatter; use Paranoia\Formatter\Posnet\OrderIdFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; use PHPUnit\Framework\TestCase; use Paranoia\Configuration\Posnet as PosnetConfiguration; @@ -55,14 +56,19 @@ protected function setupRequest($setInstallment=false) $request = new Request(); $request->setOrderId('123456') ->setAmount(25.4) - ->setCurrency(Currency::CODE_EUR) - ->setCardNumber('1501501501501500') - ->setSecurityCode('000') - ->setExpireMonth(1) - ->setExpireYear(2020); + ->setCurrency(Currency::CODE_EUR); + if($setInstallment) { $request->setInstallment(3); } + + $card = new Card(); + $card->setNumber('1501501501501500') + ->setSecurityCode('000') + ->setExpireMonth(1) + ->setExpireYear(2020); + $request->setResource($card); + return $request; } diff --git a/tests/Builder/Posnet/RefundRequestBuilderTest.php b/tests/Builder/Posnet/RefundRequestBuilderTest.php index e76375c..f190502 100644 --- a/tests/Builder/Posnet/RefundRequestBuilderTest.php +++ b/tests/Builder/Posnet/RefundRequestBuilderTest.php @@ -8,7 +8,7 @@ use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter; use Paranoia\Formatter\Posnet\ExpireDateFormatter; use Paranoia\Formatter\Posnet\OrderIdFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; use PHPUnit\Framework\TestCase; use Paranoia\Configuration\Posnet as PosnetConfiguration; diff --git a/tests/Builder/Posnet/SaleRequestBuilderTest.php b/tests/Builder/Posnet/SaleRequestBuilderTest.php index 02089f6..5f44a69 100644 --- a/tests/Builder/Posnet/SaleRequestBuilderTest.php +++ b/tests/Builder/Posnet/SaleRequestBuilderTest.php @@ -8,7 +8,8 @@ use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter; use Paranoia\Formatter\Posnet\ExpireDateFormatter; use Paranoia\Formatter\Posnet\OrderIdFormatter; -use Paranoia\Request; +use Paranoia\Request\Request; +use Paranoia\Request\Resource\Card; use PHPUnit\Framework\TestCase; use Paranoia\Configuration\Posnet as PosnetConfiguration; @@ -55,14 +56,18 @@ protected function setupRequest($setInstallment=false) $request = new Request(); $request->setOrderId('123456') ->setAmount(25.4) - ->setCurrency(Currency::CODE_EUR) - ->setCardNumber('1501501501501500') - ->setSecurityCode('000') - ->setExpireMonth(1) - ->setExpireYear(2020); + ->setCurrency(Currency::CODE_EUR); if($setInstallment) { $request->setInstallment(3); } + + $card = new Card(); + $card->setNumber('1501501501501500') + ->setSecurityCode('000') + ->setExpireMonth(1) + ->setExpireYear(2020); + $request->setResource($card); + return $request; } diff --git a/tests/Processor/Gvp/CancelResponseProcessorTest.php b/tests/Processor/Gvp/CancelResponseProcessorTest.php index 9490b66..5bad626 100644 --- a/tests/Processor/Gvp/CancelResponseProcessorTest.php +++ b/tests/Processor/Gvp/CancelResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Gvp\CancelResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class CancelResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new CancelResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('311616674771', $response->getTransactionId()); $this->assertEquals('489787', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new CancelResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Gvp/PostAuthorizationResponseProcessorTest.php b/tests/Processor/Gvp/PostAuthorizationResponseProcessorTest.php index 0596ac4..7ba6f9b 100644 --- a/tests/Processor/Gvp/PostAuthorizationResponseProcessorTest.php +++ b/tests/Processor/Gvp/PostAuthorizationResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Gvp\PostAuthorizationResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class PostAuthorizationResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PostAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('105809652539', $response->getTransactionId()); $this->assertEquals('914729', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PostAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Gvp/PreAuthorizationResponseProcessorTest.php b/tests/Processor/Gvp/PreAuthorizationResponseProcessorTest.php index f4b5db1..eef9ff0 100644 --- a/tests/Processor/Gvp/PreAuthorizationResponseProcessorTest.php +++ b/tests/Processor/Gvp/PreAuthorizationResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Gvp\PreAuthorizationResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class PreAuthorizationResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PreAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('311710676052', $response->getTransactionId()); $this->assertEquals('412290', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PreAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Gvp/RefundResponseProcessorTest.php b/tests/Processor/Gvp/RefundResponseProcessorTest.php index a4163ea..1d616eb 100644 --- a/tests/Processor/Gvp/RefundResponseProcessorTest.php +++ b/tests/Processor/Gvp/RefundResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Gvp\RefundResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class RefundResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new RefundResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('311616674771', $response->getTransactionId()); $this->assertEquals('489787', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new RefundResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Gvp/SaleResponseProcessorTest.php b/tests/Processor/Gvp/SaleResponseProcessorTest.php index 5475673..edf218e 100644 --- a/tests/Processor/Gvp/SaleResponseProcessorTest.php +++ b/tests/Processor/Gvp/SaleResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Gvp\SaleResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class SaleResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new SaleResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('311710676028', $response->getTransactionId()); $this->assertEquals('245093', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new SaleResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/NestPay/CancelResponseProcessorTest.php b/tests/Processor/NestPay/CancelResponseProcessorTest.php new file mode 100644 index 0000000..92db966 --- /dev/null +++ b/tests/Processor/NestPay/CancelResponseProcessorTest.php @@ -0,0 +1,71 @@ +getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new CancelResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(true, $response->isSuccess()); + $this->assertEquals('15335I94G07024820', $response->getTransactionId()); + $this->assertEquals('PB6356', $response->getAuthCode()); + $this->assertEquals('133577162970961', $response->getOrderId()); + } + + public function test_failed_response() + { + $rawResponse = file_get_contents( + __DIR__ . '/../../samples/response/nestpay/cancel_failed.xml' + ); + + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new CancelResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(false, $response->isSuccess()); + $this->assertEquals(null, $response->getTransactionId()); + $this->assertEquals(null, $response->getOrderId()); + $this->assertEquals('05', $response->getResponseCode()); + $this->assertEquals('Error Message: Genel red Host Message: [RC 05] Red Onaylanmadı - Do Not Honour', $response->getResponseMessage()); + } + + /** + * @dataProvider badResponses + * @param string $rawResponse + */ + public function test_bad_response($rawResponse) + { + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new CancelResponseProcessor($configuration); + + $this->expectException(BadResponseException::class); + $processor->process($rawResponse); + } + + public function badResponses() + { + return [ + [null], + [''], + ['DUMMY'], + [1], + ]; + } + +} diff --git a/tests/Processor/NestPay/PostAuthorizationResponseProcessorTest.php b/tests/Processor/NestPay/PostAuthorizationResponseProcessorTest.php new file mode 100644 index 0000000..1bcf858 --- /dev/null +++ b/tests/Processor/NestPay/PostAuthorizationResponseProcessorTest.php @@ -0,0 +1,71 @@ +getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new PostAuthorizationResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(true, $response->isSuccess()); + $this->assertEquals('15335I94G07024820', $response->getTransactionId()); + $this->assertEquals('PB6356', $response->getAuthCode()); + $this->assertEquals('133577162970961', $response->getOrderId()); + } + + public function test_failed_response() + { + $rawResponse = file_get_contents( + __DIR__ . '/../../samples/response/nestpay/post_authorization_failed.xml' + ); + + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new PostAuthorizationResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(false, $response->isSuccess()); + $this->assertEquals(null, $response->getTransactionId()); + $this->assertEquals(null, $response->getOrderId()); + $this->assertEquals('05', $response->getResponseCode()); + $this->assertEquals('Error Message: Genel red Host Message: [RC 05] Red Onaylanmadı - Do Not Honour', $response->getResponseMessage()); + } + + /** + * @dataProvider badResponses + * @param string $rawResponse + */ + public function test_bad_response($rawResponse) + { + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new PostAuthorizationResponseProcessor($configuration); + + $this->expectException(BadResponseException::class); + $processor->process($rawResponse); + } + + public function badResponses() + { + return [ + [null], + [''], + ['DUMMY'], + [1], + ]; + } + +} diff --git a/tests/Processor/NestPay/PreAuthorizationResponseProcessorTest.php b/tests/Processor/NestPay/PreAuthorizationResponseProcessorTest.php new file mode 100644 index 0000000..3f47a44 --- /dev/null +++ b/tests/Processor/NestPay/PreAuthorizationResponseProcessorTest.php @@ -0,0 +1,71 @@ +getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new PreAuthorizationResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(true, $response->isSuccess()); + $this->assertEquals('15335I94G07024820', $response->getTransactionId()); + $this->assertEquals('PB6356', $response->getAuthCode()); + $this->assertEquals('133577162970961', $response->getOrderId()); + } + + public function test_failed_response() + { + $rawResponse = file_get_contents( + __DIR__ . '/../../samples/response/nestpay/pre_authorization_failed.xml' + ); + + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new PreAuthorizationResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(false, $response->isSuccess()); + $this->assertEquals(null, $response->getTransactionId()); + $this->assertEquals(null, $response->getOrderId()); + $this->assertEquals('05', $response->getResponseCode()); + $this->assertEquals('Error Message: Genel red Host Message: [RC 05] Red Onaylanmadı - Do Not Honour', $response->getResponseMessage()); + } + + /** + * @dataProvider badResponses + * @param string $rawResponse + */ + public function test_bad_response($rawResponse) + { + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new PreAuthorizationResponseProcessor($configuration); + + $this->expectException(BadResponseException::class); + $processor->process($rawResponse); + } + + public function badResponses() + { + return [ + [null], + [''], + ['DUMMY'], + [1], + ]; + } + +} diff --git a/tests/Processor/NestPay/RefundResponseProcessorTest.php b/tests/Processor/NestPay/RefundResponseProcessorTest.php new file mode 100644 index 0000000..38a39a1 --- /dev/null +++ b/tests/Processor/NestPay/RefundResponseProcessorTest.php @@ -0,0 +1,71 @@ +getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new RefundResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(true, $response->isSuccess()); + $this->assertEquals('15335I94G07024820', $response->getTransactionId()); + $this->assertEquals('PB6356', $response->getAuthCode()); + $this->assertEquals('133577162970961', $response->getOrderId()); + } + + public function test_failed_response() + { + $rawResponse = file_get_contents( + __DIR__ . '/../../samples/response/nestpay/refund_failed.xml' + ); + + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new RefundResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(false, $response->isSuccess()); + $this->assertEquals(null, $response->getTransactionId()); + $this->assertEquals(null, $response->getOrderId()); + $this->assertEquals('05', $response->getResponseCode()); + $this->assertEquals('Error Message: Genel red Host Message: [RC 05] Red Onaylanmadı - Do Not Honour', $response->getResponseMessage()); + } + + /** + * @dataProvider badResponses + * @param string $rawResponse + */ + public function test_bad_response($rawResponse) + { + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new RefundResponseProcessor($configuration); + + $this->expectException(BadResponseException::class); + $processor->process($rawResponse); + } + + public function badResponses() + { + return [ + [null], + [''], + ['DUMMY'], + [1], + ]; + } + +} diff --git a/tests/Processor/NestPay/SaleResponseProcessorTest.php b/tests/Processor/NestPay/SaleResponseProcessorTest.php new file mode 100644 index 0000000..4dc4671 --- /dev/null +++ b/tests/Processor/NestPay/SaleResponseProcessorTest.php @@ -0,0 +1,71 @@ +getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new SaleResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(true, $response->isSuccess()); + $this->assertEquals('15335I94G07024820', $response->getTransactionId()); + $this->assertEquals('PB6356', $response->getAuthCode()); + $this->assertEquals('133577162970961', $response->getOrderId()); + } + + public function test_failed_response() + { + $rawResponse = file_get_contents( + __DIR__ . '/../../samples/response/nestpay/sale_failed.xml' + ); + + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new SaleResponseProcessor($configuration); + $response = $processor->process($rawResponse); + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(false, $response->isSuccess()); + $this->assertEquals(null, $response->getTransactionId()); + $this->assertEquals(null, $response->getOrderId()); + $this->assertEquals('05', $response->getResponseCode()); + $this->assertEquals('Error Message: Genel red Host Message: [RC 05] Red Onaylanmadı - Do Not Honour', $response->getResponseMessage()); + } + + /** + * @dataProvider badResponses + * @param string $rawResponse + */ + public function test_bad_response($rawResponse) + { + /** @var AbstractConfiguration $configuration */ + $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); + $processor = new SaleResponseProcessor($configuration); + + $this->expectException(BadResponseException::class); + $processor->process($rawResponse); + } + + public function badResponses() + { + return [ + [null], + [''], + ['DUMMY'], + [1], + ]; + } + +} diff --git a/tests/Processor/Posnet/CancelResponseProcessorTest.php b/tests/Processor/Posnet/CancelResponseProcessorTest.php index 42f10a5..d9a3bac 100644 --- a/tests/Processor/Posnet/CancelResponseProcessorTest.php +++ b/tests/Processor/Posnet/CancelResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Posnet\CancelResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class CancelResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new CancelResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('0001000009P0503281', $response->getTransactionId()); $this->assertEquals('000000', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new CancelResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Posnet/PostAuthorizationResponseProcessorTest.php b/tests/Processor/Posnet/PostAuthorizationResponseProcessorTest.php index 5eaab1a..7b42a33 100644 --- a/tests/Processor/Posnet/PostAuthorizationResponseProcessorTest.php +++ b/tests/Processor/Posnet/PostAuthorizationResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Posnet\PostAuthorizationResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class PostAuthorizationResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PostAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('0001000004P0503281', $response->getTransactionId()); $this->assertEquals('007912', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PostAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Posnet/PreAuthorizationResponseProcessorTest.php b/tests/Processor/Posnet/PreAuthorizationResponseProcessorTest.php index 9ffef22..24feb61 100644 --- a/tests/Processor/Posnet/PreAuthorizationResponseProcessorTest.php +++ b/tests/Processor/Posnet/PreAuthorizationResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Posnet\PreAuthorizationResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class PreAuthorizationResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PreAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('0001000004P0503281', $response->getTransactionId()); $this->assertEquals('007912', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new PreAuthorizationResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Posnet/RefundResponseProcessorTest.php b/tests/Processor/Posnet/RefundResponseProcessorTest.php index dba2239..c3edac8 100644 --- a/tests/Processor/Posnet/RefundResponseProcessorTest.php +++ b/tests/Processor/Posnet/RefundResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Posnet\RefundResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class RefundResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new RefundResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('0001000004P0503281', $response->getTransactionId()); $this->assertEquals('007912', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new RefundResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/Processor/Posnet/SaleResponseProcessorTest.php b/tests/Processor/Posnet/SaleResponseProcessorTest.php index aec24c5..9ae28e5 100644 --- a/tests/Processor/Posnet/SaleResponseProcessorTest.php +++ b/tests/Processor/Posnet/SaleResponseProcessorTest.php @@ -4,7 +4,7 @@ use Paranoia\Configuration\AbstractConfiguration; use Paranoia\Exception\BadResponseException; use Paranoia\Processor\Posnet\SaleResponseProcessor; -use Paranoia\Response\PaymentResponse; +use Paranoia\Response; use PHPUnit\Framework\TestCase; class SaleResponseProcessorTest extends TestCase @@ -19,7 +19,7 @@ public function test_success_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new SaleResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(true, $response->isSuccess()); $this->assertEquals('0001000004P0503281', $response->getTransactionId()); $this->assertEquals('007912', $response->getAuthCode()); @@ -36,7 +36,7 @@ public function test_failed_response() $configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); $processor = new SaleResponseProcessor($configuration); $response = $processor->process($rawResponse); - $this->assertInstanceOf(PaymentResponse::class, $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(false, $response->isSuccess()); $this->assertEquals(null, $response->getTransactionId()); $this->assertEquals(null, $response->getOrderId()); diff --git a/tests/samples/response/nestpay/cancel_failed.xml b/tests/samples/response/nestpay/cancel_failed.xml new file mode 100644 index 0000000..284237e --- /dev/null +++ b/tests/samples/response/nestpay/cancel_failed.xml @@ -0,0 +1,22 @@ + + + 133544933749090 + 133544933749090 + Declined + + 533500707661 + 05 + 15335ACwD07019988 + Genel red + + 20122980 + 20151201 00:02:48 + ISO8583-05 + [RC 05] Red Onaylanmadı - Do Not Honour + MAESTRO + Isbank + 1201-000250 + Y + 05858305 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/cancel_successful.xml b/tests/samples/response/nestpay/cancel_successful.xml new file mode 100644 index 0000000..3dedc1d --- /dev/null +++ b/tests/samples/response/nestpay/cancel_successful.xml @@ -0,0 +1,24 @@ + + + 133577162970961 + 133577162970961 + Approved + PB6356 + 533508523647 + 00 + 15335I94G07024820 + + + 20122981 + 20151201 08:59:54 + + MAXIPUAN : % 0.100 ,KAZANILAN MAXIPUAN : 0.15 TL MAXIPUAN : % 0.100 KAZANILAN MAXIPUAN : 0.15 + TL ,TOPLAM MAXIPUAN : 5.02 TL + + VISA + Isbank + 1201-085956 + Y + 00 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/post_authorization_failed.xml b/tests/samples/response/nestpay/post_authorization_failed.xml new file mode 100644 index 0000000..284237e --- /dev/null +++ b/tests/samples/response/nestpay/post_authorization_failed.xml @@ -0,0 +1,22 @@ + + + 133544933749090 + 133544933749090 + Declined + + 533500707661 + 05 + 15335ACwD07019988 + Genel red + + 20122980 + 20151201 00:02:48 + ISO8583-05 + [RC 05] Red Onaylanmadı - Do Not Honour + MAESTRO + Isbank + 1201-000250 + Y + 05858305 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/post_authorization_successful.xml b/tests/samples/response/nestpay/post_authorization_successful.xml new file mode 100644 index 0000000..3dedc1d --- /dev/null +++ b/tests/samples/response/nestpay/post_authorization_successful.xml @@ -0,0 +1,24 @@ + + + 133577162970961 + 133577162970961 + Approved + PB6356 + 533508523647 + 00 + 15335I94G07024820 + + + 20122981 + 20151201 08:59:54 + + MAXIPUAN : % 0.100 ,KAZANILAN MAXIPUAN : 0.15 TL MAXIPUAN : % 0.100 KAZANILAN MAXIPUAN : 0.15 + TL ,TOPLAM MAXIPUAN : 5.02 TL + + VISA + Isbank + 1201-085956 + Y + 00 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/pre_authorization_failed.xml b/tests/samples/response/nestpay/pre_authorization_failed.xml new file mode 100644 index 0000000..284237e --- /dev/null +++ b/tests/samples/response/nestpay/pre_authorization_failed.xml @@ -0,0 +1,22 @@ + + + 133544933749090 + 133544933749090 + Declined + + 533500707661 + 05 + 15335ACwD07019988 + Genel red + + 20122980 + 20151201 00:02:48 + ISO8583-05 + [RC 05] Red Onaylanmadı - Do Not Honour + MAESTRO + Isbank + 1201-000250 + Y + 05858305 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/pre_authorization_successful.xml b/tests/samples/response/nestpay/pre_authorization_successful.xml new file mode 100644 index 0000000..3dedc1d --- /dev/null +++ b/tests/samples/response/nestpay/pre_authorization_successful.xml @@ -0,0 +1,24 @@ + + + 133577162970961 + 133577162970961 + Approved + PB6356 + 533508523647 + 00 + 15335I94G07024820 + + + 20122981 + 20151201 08:59:54 + + MAXIPUAN : % 0.100 ,KAZANILAN MAXIPUAN : 0.15 TL MAXIPUAN : % 0.100 KAZANILAN MAXIPUAN : 0.15 + TL ,TOPLAM MAXIPUAN : 5.02 TL + + VISA + Isbank + 1201-085956 + Y + 00 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/refund_failed.xml b/tests/samples/response/nestpay/refund_failed.xml new file mode 100644 index 0000000..284237e --- /dev/null +++ b/tests/samples/response/nestpay/refund_failed.xml @@ -0,0 +1,22 @@ + + + 133544933749090 + 133544933749090 + Declined + + 533500707661 + 05 + 15335ACwD07019988 + Genel red + + 20122980 + 20151201 00:02:48 + ISO8583-05 + [RC 05] Red Onaylanmadı - Do Not Honour + MAESTRO + Isbank + 1201-000250 + Y + 05858305 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/refund_successful.xml b/tests/samples/response/nestpay/refund_successful.xml new file mode 100644 index 0000000..3dedc1d --- /dev/null +++ b/tests/samples/response/nestpay/refund_successful.xml @@ -0,0 +1,24 @@ + + + 133577162970961 + 133577162970961 + Approved + PB6356 + 533508523647 + 00 + 15335I94G07024820 + + + 20122981 + 20151201 08:59:54 + + MAXIPUAN : % 0.100 ,KAZANILAN MAXIPUAN : 0.15 TL MAXIPUAN : % 0.100 KAZANILAN MAXIPUAN : 0.15 + TL ,TOPLAM MAXIPUAN : 5.02 TL + + VISA + Isbank + 1201-085956 + Y + 00 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/sale_failed.xml b/tests/samples/response/nestpay/sale_failed.xml new file mode 100644 index 0000000..284237e --- /dev/null +++ b/tests/samples/response/nestpay/sale_failed.xml @@ -0,0 +1,22 @@ + + + 133544933749090 + 133544933749090 + Declined + + 533500707661 + 05 + 15335ACwD07019988 + Genel red + + 20122980 + 20151201 00:02:48 + ISO8583-05 + [RC 05] Red Onaylanmadı - Do Not Honour + MAESTRO + Isbank + 1201-000250 + Y + 05858305 + + \ No newline at end of file diff --git a/tests/samples/response/nestpay/sale_successful.xml b/tests/samples/response/nestpay/sale_successful.xml new file mode 100644 index 0000000..3dedc1d --- /dev/null +++ b/tests/samples/response/nestpay/sale_successful.xml @@ -0,0 +1,24 @@ + + + 133577162970961 + 133577162970961 + Approved + PB6356 + 533508523647 + 00 + 15335I94G07024820 + + + 20122981 + 20151201 08:59:54 + + MAXIPUAN : % 0.100 ,KAZANILAN MAXIPUAN : 0.15 TL MAXIPUAN : % 0.100 KAZANILAN MAXIPUAN : 0.15 + TL ,TOPLAM MAXIPUAN : 5.02 TL + + VISA + Isbank + 1201-085956 + Y + 00 + + \ No newline at end of file