diff --git a/composer.json b/composer.json index 992ab3f..81d1121 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,9 @@ "require": { "php": ">= 5.6.0", "guzzle/guzzle": "3.9.2", - "symfony/event-dispatcher": "^2.7|^3.0" + "symfony/event-dispatcher": "^2.7|^3.0", + "ext-SimpleXML": "*", + "ext-curl" :"*" }, "require-dev": { "phpunit/phpunit": "5.7.*", diff --git a/docs/3-islemler.md b/docs/3-islemler.md index 42f31f8..652e370 100644 --- a/docs/3-islemler.md +++ b/docs/3-islemler.md @@ -1,6 +1,6 @@ # 3. İşlemler -* [3.1. Satış İşlemi](/docs/31-sats-islemi.md) +* [3.1. Satış İşlemi](/docs/31-satis-islemi.md) * 3.2. Ön Onaylı Sipariş İşemi * 3.3. Ön Onaylı Sipariş İşleminin Satış İşlemine Dönüştürülmesi * [3.4. İptal İşlemi](/docs/34-iptal-islemi.md) diff --git a/docs/31-satis-islemi.md b/docs/31-satis-islemi.md index b2b2f6e..198159d 100644 --- a/docs/31-satis-islemi.md +++ b/docs/31-satis-islemi.md @@ -6,14 +6,14 @@ Satış işlemi, müşterinin ödeme aracı bilgilerinin (Kredi kartı vb.) ilgi ## 3.1.2. Satış İsteği Oluşturma -Satış isteği, **Paranoia\Request** tipinde bir nesnenin sipariş ve ödeme aracı (kredi kartı vb.) bilgileri ile doldurulması suretiyle elde edilir. +Satış isteği, **\Paranoia\Request\Request** tipinde bir nesnenin sipariş ve ödeme aracı (kredi kartı vb.) bilgileri ile doldurulması suretiyle elde edilir. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setOrderId('ORDER000000' . time()) ->setAmount(100.35) - ->setCurrency('TRY'); -$card = new \Paranoia\Resource\Card(); + ->setCurrency(\Paranoia\Currency::CODE_TRY); +$card = new \Paranoia\Request\Resource\Card(); $card->setNumber('5406******675403') ->setSecurityCode('000') ->setExpireMonth(12) @@ -37,11 +37,11 @@ $request->setResource($card); * Satış işlemi için yeni bir sipariş isteği oluşturuyoruz. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setOrderId('ORDER000000' . time()) ->setAmount(100.35) - ->setCurrency('TRY'); -$card = new \Paranoia\Resource\Card(); + ->setCurrency(\Paranoia\Currency::CODE_TRY); +$card = new \Paranoia\Request\Resource\Card(); $card->setNumber('5406******675403') ->setSecurityCode('000') ->setExpireMonth(12) @@ -59,7 +59,7 @@ $configuration->setClientId('123456789') ``` -* Satış işlemini gerçekleştiriyoruz. Sağlayıcı uyarlamaları, Sağlayıcının [2. Desteklenen Ödeme Sistemleri](/docs/2-desteklenen-odeme-sistemleri.md) dökümanında belirtilen **ödeme sistemi** nin adı ile adlandırılmışlardır. Örnekte belirtilen NestPay uyarlaması için \Paranoia\Pos\**NestPay** sınıfını kullanabildiğiniz gibi Posnet uyarlaması için **\Paranoia\Pos\**Posnet** sınıfını kullanabilirsiniz. +* Satış işlemini gerçekleştiriyoruz. Sağlayıcı uyarlamaları, Sağlayıcının [2. Desteklenen Ödeme Sistemleri](/docs/2-desteklenen-odeme-sistemleri.md) dökümanında belirtilen **ödeme sistemi** nin adı ile adlandırılmışlardır. Örnekte belirtilen NestPay uyarlaması için \Paranoia\Pos\\**NestPay** sınıfını kullanabildiğiniz gibi Posnet uyarlaması için \Paranoia\Pos\\**Posnet** sınıfını kullanabilirsiniz. ```php try { $adapter = new \Paranoia\Pos\NestPay($configuration); @@ -67,10 +67,6 @@ try { } catch(\Paranoia\Exception\CommunicationError $e) { // Bağlantı hatası durumunda yapılacak işlemleri // bu bölümde greçekleştirebilirsiniz. -} catch(\Paranoia\Exception\UnexpectedResponse $e) { - // Ödeme sistemi sağlayıcısından beklenmedik bir yanıt - // dönmesi (boş yanıt veya beklenmedik bir hata mesajı gibi) - // durumunda yapılacak işlemleri bu bölümde gerçekleştirebilirsiniz. } catch(\Exception $e) { // Uygulamada beklenmedik bir hata meydana gelmesi durumunda // yapılacak işlemleri bu bölümde gerçekleştirebilirsiniz. diff --git a/docs/34-iptal-islemi.md b/docs/34-iptal-islemi.md index 194434b..5396273 100644 --- a/docs/34-iptal-islemi.md +++ b/docs/34-iptal-islemi.md @@ -9,14 +9,14 @@ İptal isteği, **Paranoia\Request** tipinde bir nesnenin transaction numarası ile doldurulması suretiyle elde edilir. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setTransactionId('1234567890'); ``` İptal işlemi sipariş numarası ile de gerçekleştirilebilmektedir.
**Not:** Bu kullanım şekli bazı bankalar tarafından tavsiye edilmemektedir. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setOrderId('987654321'); ``` @@ -33,7 +33,7 @@ $request->setOrderId('987654321'); * İptal işlemi için yeni bir iptal isteği oluşturuyoruz. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setTransactionId('1234567890'); ``` @@ -55,10 +55,6 @@ try { } catch(\Paranoia\Exception\CommunicationError $e) { // Bağlantı hatası durumunda yapılacak işlemleri // bu bölümde greçekleştirebilirsiniz. -} catch(\Paranoia\Exception\UnexpectedResponse $e) { - // Ödeme sistemi sağlayıcısından beklenmedik bir yanıt - // dönmesi (boş yanıt veya beklenmedik bir hata mesajı gibi) - // durumunda yapılacak işlemleri bu bölümde gerçekleştirebilirsiniz. } catch(\Exception $e) { // Uygulamada beklenmedik bir hata meydana gelmesi durumunda // yapılacak işlemleri bu bölümde gerçekleştirebilirsiniz. diff --git a/docs/35-iade-islemi.md b/docs/35-iade-islemi.md index dd4d8c1..6d16902 100644 --- a/docs/35-iade-islemi.md +++ b/docs/35-iade-islemi.md @@ -9,7 +9,7 @@ İade isteği, **Paranoia\Request** tipinde bir nesnenin sipariş numarası ile doldurulması suretiyle elde edilir. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setOrderId('987654321'); ``` @@ -24,7 +24,7 @@ $request->setOrderId('987654321'); * İade işlemi için yeni bir iade isteği oluşturuyoruz. ```php -$request = new \Paranoia\Request(); +$request = new \Paranoia\Request\Request(); $request->setOrderId('1234567890'); ``` @@ -46,10 +46,6 @@ try { } catch(\Paranoia\Exception\CommunicationError $e) { // Bağlantı hatası durumunda yapılacak işlemleri // bu bölümde greçekleştirebilirsiniz. -} catch(\Paranoia\Exception\UnexpectedResponse $e) { - // Ödeme sistemi sağlayıcısından beklenmedik bir yanıt - // dönmesi (boş yanıt veya beklenmedik bir hata mesajı gibi) - // durumunda yapılacak işlemleri bu bölümde gerçekleştirebilirsiniz. } catch(\Exception $e) { // Uygulamada beklenmedik bir hata meydana gelmesi durumunda // yapılacak işlemleri bu bölümde gerçekleştirebilirsiniz. diff --git a/src/Configuration/AbstractConfiguration.php b/src/Configuration/AbstractConfiguration.php index 59dd71b..4eb7533 100644 --- a/src/Configuration/AbstractConfiguration.php +++ b/src/Configuration/AbstractConfiguration.php @@ -27,4 +27,4 @@ public function getApiUrl() { return $this->apiUrl; } -} +} \ No newline at end of file diff --git a/src/Pos/AbstractPos.php b/src/Pos/AbstractPos.php index 759f26b..e3f35e6 100644 --- a/src/Pos/AbstractPos.php +++ b/src/Pos/AbstractPos.php @@ -7,7 +7,6 @@ use Paranoia\Exception\CommunicationError; use Paranoia\Request\Request; use Paranoia\TransactionType; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; abstract class AbstractPos { @@ -16,8 +15,6 @@ abstract class AbstractPos */ protected $configuration; - /** @var EventDispatcherInterface */ - private $dispatcher; public function __construct(AbstractConfiguration $configuration) { @@ -27,7 +24,7 @@ public function __construct(AbstractConfiguration $configuration) /** * build complete raw data for the specified request. * - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * @param string $transactionType * * @return mixed @@ -40,7 +37,7 @@ abstract protected function buildRequest(Request $request, $transactionType); * @param string $rawResponse * @param string $transactionType * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response */ abstract protected function parseResponse($rawResponse, $transactionType); @@ -51,20 +48,22 @@ abstract protected function parseResponse($rawResponse, $transactionType); * @param mixed $data * @param array $options * - * @throws \ErrorException|\Exception + * @throws CommunicationError * @return mixed */ protected function sendRequest($url, $data, $options = null) { $client = new HttpClient(); $client->setConfig(array( - 'curl.options' => array( - CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_SSL_VERIFYHOST => false, - CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2 - ) + 'curl.options' => array( + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_SSL_VERIFYHOST => false, + CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2 + ) )); + $request = $client->post($url, null, $data); + try { return $request->send()->getBody(); } catch (RequestException $e) { @@ -72,6 +71,12 @@ protected function sendRequest($url, $data, $options = null) } } + /** + * @param $request Request + * @param $transactionType + * @return \Paranoia\Response + * @throws CommunicationError + */ private function performTransaction(Request $request, $transactionType) { $rawRequest = $this->buildRequest($request, $transactionType); @@ -81,9 +86,10 @@ private function performTransaction(Request $request, $transactionType) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function preAuthorization(Request $request) { @@ -91,9 +97,10 @@ public function preAuthorization(Request $request) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function postAuthorization(Request $request) { @@ -101,9 +108,10 @@ public function postAuthorization(Request $request) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function sale(Request $request) { @@ -111,9 +119,10 @@ public function sale(Request $request) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function refund(Request $request) { @@ -121,9 +130,10 @@ public function refund(Request $request) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function cancel(Request $request) { @@ -131,9 +141,10 @@ public function cancel(Request $request) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function pointQuery(Request $request) { @@ -141,9 +152,10 @@ public function pointQuery(Request $request) } /** - * @param \Paranoia\Request $request + * @param \Paranoia\Request\Request $request * - * @return \Paranoia\Response\Response + * @return \Paranoia\Response + * @throws CommunicationError */ public function pointUsage(Request $request) { diff --git a/src/Pos/Gvp.php b/src/Pos/Gvp.php index 855ce7a..21b99c9 100644 --- a/src/Pos/Gvp.php +++ b/src/Pos/Gvp.php @@ -24,6 +24,7 @@ public function __construct(AbstractConfiguration $configuration) /** * {@inheritdoc} * @see \Paranoia\Pos\AbstractPos::buildRequest() + * @throws \Paranoia\Exception\NotImplementedError */ protected function buildRequest(Request $request, $transactionType) { diff --git a/src/Pos/NestPay.php b/src/Pos/NestPay.php index d765701..9f74cbb 100644 --- a/src/Pos/NestPay.php +++ b/src/Pos/NestPay.php @@ -26,6 +26,7 @@ public function __construct(AbstractConfiguration $configuration) /** * {@inheritdoc} * @see \Paranoia\Pos\AbstractPos::buildRequest() + * @throws \Paranoia\Exception\NotImplementedError */ protected function buildRequest(Request $request, $transactionType) { diff --git a/src/Pos/Posnet.php b/src/Pos/Posnet.php index ababd15..57e9ceb 100644 --- a/src/Pos/Posnet.php +++ b/src/Pos/Posnet.php @@ -24,6 +24,7 @@ public function __construct(AbstractConfiguration $configuration) /** * {@inheritdoc} * @see \Paranoia\Pos\AbstractPos::buildRequest() + * @throws \Paranoia\Exception\NotImplementedError */ protected function buildRequest(Request $request, $transactionType) { @@ -37,7 +38,6 @@ protected function buildRequest(Request $request, $transactionType) */ protected function parseResponse($rawResponse, $transactionType) { - $rawRequest = $this->builderFactory->createBuilder($transactionType)->build($request); - return array( 'DATA' => $rawRequest); + return $this->processorFactory->createProcessor($transactionType)->process($rawResponse); } } diff --git a/src/Processor/Gvp/CancelResponseProcessor.php b/src/Processor/Gvp/CancelResponseProcessor.php index 8b87a1e..07d8807 100644 --- a/src/Processor/Gvp/CancelResponseProcessor.php +++ b/src/Processor/Gvp/CancelResponseProcessor.php @@ -3,6 +3,11 @@ class CancelResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Gvp/PostAuthorizationResponseProcessor.php b/src/Processor/Gvp/PostAuthorizationResponseProcessor.php index 9b65a63..2b2b3ea 100644 --- a/src/Processor/Gvp/PostAuthorizationResponseProcessor.php +++ b/src/Processor/Gvp/PostAuthorizationResponseProcessor.php @@ -3,6 +3,11 @@ class PostAuthorizationResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Gvp/PreAuthorizationResponseProcessor.php b/src/Processor/Gvp/PreAuthorizationResponseProcessor.php index 4f337ef..cc10c58 100644 --- a/src/Processor/Gvp/PreAuthorizationResponseProcessor.php +++ b/src/Processor/Gvp/PreAuthorizationResponseProcessor.php @@ -3,6 +3,11 @@ class PreAuthorizationResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Gvp/RefundResponseProcessor.php b/src/Processor/Gvp/RefundResponseProcessor.php index 335ecc5..a43078e 100644 --- a/src/Processor/Gvp/RefundResponseProcessor.php +++ b/src/Processor/Gvp/RefundResponseProcessor.php @@ -3,6 +3,11 @@ class RefundResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Gvp/SaleResponseProcessor.php b/src/Processor/Gvp/SaleResponseProcessor.php index b71b051..7a7fda6 100644 --- a/src/Processor/Gvp/SaleResponseProcessor.php +++ b/src/Processor/Gvp/SaleResponseProcessor.php @@ -3,6 +3,11 @@ class SaleResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/NestPay/CancelResponseProcessor.php b/src/Processor/NestPay/CancelResponseProcessor.php index 7d9fed9..86ad38d 100644 --- a/src/Processor/NestPay/CancelResponseProcessor.php +++ b/src/Processor/NestPay/CancelResponseProcessor.php @@ -1,8 +1,14 @@ processCommonResponse($rawResponse); diff --git a/src/Processor/NestPay/PostAuthorizationResponseProcessor.php b/src/Processor/NestPay/PostAuthorizationResponseProcessor.php index 77d22fe..43860cd 100644 --- a/src/Processor/NestPay/PostAuthorizationResponseProcessor.php +++ b/src/Processor/NestPay/PostAuthorizationResponseProcessor.php @@ -3,6 +3,11 @@ class PostAuthorizationResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/NestPay/PreAuthorizationResponseProcessor.php b/src/Processor/NestPay/PreAuthorizationResponseProcessor.php index de9802b..5c5be33 100644 --- a/src/Processor/NestPay/PreAuthorizationResponseProcessor.php +++ b/src/Processor/NestPay/PreAuthorizationResponseProcessor.php @@ -3,6 +3,11 @@ class PreAuthorizationResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/NestPay/RefundResponseProcessor.php b/src/Processor/NestPay/RefundResponseProcessor.php index 736503d..0acb2f2 100644 --- a/src/Processor/NestPay/RefundResponseProcessor.php +++ b/src/Processor/NestPay/RefundResponseProcessor.php @@ -3,6 +3,11 @@ class RefundResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/NestPay/SaleResponseProcessor.php b/src/Processor/NestPay/SaleResponseProcessor.php index 082ed39..7e39c28 100644 --- a/src/Processor/NestPay/SaleResponseProcessor.php +++ b/src/Processor/NestPay/SaleResponseProcessor.php @@ -3,6 +3,11 @@ class SaleResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Posnet/CancelResponseProcessor.php b/src/Processor/Posnet/CancelResponseProcessor.php index 13999a4..aea6088 100644 --- a/src/Processor/Posnet/CancelResponseProcessor.php +++ b/src/Processor/Posnet/CancelResponseProcessor.php @@ -3,6 +3,11 @@ class CancelResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Posnet/PostAuthorizationResponseProcessor.php b/src/Processor/Posnet/PostAuthorizationResponseProcessor.php index c032b13..8667093 100644 --- a/src/Processor/Posnet/PostAuthorizationResponseProcessor.php +++ b/src/Processor/Posnet/PostAuthorizationResponseProcessor.php @@ -3,6 +3,11 @@ class PostAuthorizationResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Posnet/PreAuthorizationResponseProcessor.php b/src/Processor/Posnet/PreAuthorizationResponseProcessor.php index 1a00627..9e29440 100644 --- a/src/Processor/Posnet/PreAuthorizationResponseProcessor.php +++ b/src/Processor/Posnet/PreAuthorizationResponseProcessor.php @@ -3,6 +3,11 @@ class PreAuthorizationResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Posnet/RefundResponseProcessor.php b/src/Processor/Posnet/RefundResponseProcessor.php index d5eaa9a..3d9dc7f 100644 --- a/src/Processor/Posnet/RefundResponseProcessor.php +++ b/src/Processor/Posnet/RefundResponseProcessor.php @@ -3,6 +3,11 @@ class RefundResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse); diff --git a/src/Processor/Posnet/SaleResponseProcessor.php b/src/Processor/Posnet/SaleResponseProcessor.php index 9c2e653..a7e4f77 100644 --- a/src/Processor/Posnet/SaleResponseProcessor.php +++ b/src/Processor/Posnet/SaleResponseProcessor.php @@ -3,6 +3,11 @@ class SaleResponseProcessor extends BaseResponseProcessor { + /** + * @param $rawResponse + * @throws \Paranoia\Exception\BadResponseException + * @return \Paranoia\Response + */ public function process($rawResponse) { return $this->processCommonResponse($rawResponse);