From 370b5dbb305a85c20e3359b928b540509ae44fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkin=20=C3=87akar?= Date: Wed, 28 Oct 2015 02:49:20 +0200 Subject: [PATCH] first commit --- .gitignore | 4 + .travis.yml | 13 + LICENSE | 21 ++ README.md | 3 + composer.json | 23 ++ phpunit.xml | 18 + src/Travijuu/BkmExpress/BkmExpress.php | 141 ++++++++ .../BkmExpress/BkmExpressServiceProvider.php | 34 ++ src/Travijuu/BkmExpress/Common/Bank.php | 106 ++++++ src/Travijuu/BkmExpress/Common/Bin.php | 61 ++++ .../BkmExpress/Common/IncomingResult.php | 293 ++++++++++++++++ .../BkmExpress/Common/Installment.php | 113 ++++++ .../Common/MerchantWSResponseCode.php | 19 + src/Travijuu/BkmExpress/Common/Result.php | 86 +++++ src/Travijuu/BkmExpress/Common/VirtualPos.php | 318 +++++++++++++++++ .../BkmExpress/Config/BkmBankList.php | 242 +++++++++++++ .../Exception/ClassNotFoundException.php | 7 + .../Exception/UnexpectedDataType.php | 6 + .../Exception/UnexpectedInstance.php | 7 + .../Exception/VerificationException.php | 7 + .../BkmExpress/Payment/AbstractWSResponse.php | 21 ++ .../InitializePayment/BKMSoapClient.php | 49 +++ .../InitializePayment/InitializePayment.php | 20 ++ .../InitializePaymentResponse.php | 39 +++ .../InitializePaymentWSRequest.php | 132 +++++++ .../InitializePaymentWSResponse.php | 53 +++ .../InitializePayment/RedirectRequest.php | 64 ++++ .../RequestMerchInfo/RequestMerchInfo.php | 21 ++ .../RequestMerchInfoAction.php | 42 +++ .../RequestMerchInfoResponse.php | 45 +++ .../RequestMerchInfoServer.php | 67 ++++ .../RequestMerchInfoSoapClient.php | 87 +++++ .../RequestMerchInfoWSRequest.php | 183 ++++++++++ .../RequestMerchInfoWSResponse.php | 324 ++++++++++++++++++ .../PosResponse/AbstractPosResponse.php | 192 +++++++++++ .../PosResponse/PosResponseInterface.php | 36 ++ .../BkmExpress/PosResponse/ResponseGvp.php | 24 ++ .../PosResponse/ResponseNestPay.php | 25 ++ .../BkmExpress/PosResponse/ResponsePosnet.php | 28 ++ src/Travijuu/BkmExpress/Utility/Calculate.php | 17 + .../BkmExpress/Utility/Certificate.php | 35 ++ tests/.gitkeep | 0 42 files changed, 3026 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 src/Travijuu/BkmExpress/BkmExpress.php create mode 100644 src/Travijuu/BkmExpress/BkmExpressServiceProvider.php create mode 100644 src/Travijuu/BkmExpress/Common/Bank.php create mode 100644 src/Travijuu/BkmExpress/Common/Bin.php create mode 100644 src/Travijuu/BkmExpress/Common/IncomingResult.php create mode 100644 src/Travijuu/BkmExpress/Common/Installment.php create mode 100644 src/Travijuu/BkmExpress/Common/MerchantWSResponseCode.php create mode 100644 src/Travijuu/BkmExpress/Common/Result.php create mode 100644 src/Travijuu/BkmExpress/Common/VirtualPos.php create mode 100644 src/Travijuu/BkmExpress/Config/BkmBankList.php create mode 100644 src/Travijuu/BkmExpress/Exception/ClassNotFoundException.php create mode 100644 src/Travijuu/BkmExpress/Exception/UnexpectedDataType.php create mode 100644 src/Travijuu/BkmExpress/Exception/UnexpectedInstance.php create mode 100644 src/Travijuu/BkmExpress/Exception/VerificationException.php create mode 100644 src/Travijuu/BkmExpress/Payment/AbstractWSResponse.php create mode 100644 src/Travijuu/BkmExpress/Payment/InitializePayment/BKMSoapClient.php create mode 100644 src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePayment.php create mode 100644 src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentResponse.php create mode 100644 src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSRequest.php create mode 100644 src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSResponse.php create mode 100644 src/Travijuu/BkmExpress/Payment/InitializePayment/RedirectRequest.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfo.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoAction.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoResponse.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoServer.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoSoapClient.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSRequest.php create mode 100644 src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSResponse.php create mode 100644 src/Travijuu/BkmExpress/PosResponse/AbstractPosResponse.php create mode 100644 src/Travijuu/BkmExpress/PosResponse/PosResponseInterface.php create mode 100644 src/Travijuu/BkmExpress/PosResponse/ResponseGvp.php create mode 100644 src/Travijuu/BkmExpress/PosResponse/ResponseNestPay.php create mode 100644 src/Travijuu/BkmExpress/PosResponse/ResponsePosnet.php create mode 100644 src/Travijuu/BkmExpress/Utility/Calculate.php create mode 100644 src/Travijuu/BkmExpress/Utility/Certificate.php create mode 100644 tests/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5826402 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.phar +composer.lock +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f60bbe0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - travis_retry composer self-update + - travis_retry composer install --prefer-source --no-interaction --dev + +script: phpunit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b90ff72 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Erkin Cakar (https://github.com/travijuu) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..bddfc07 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# BKM Express PHP Payment Library + +Documentation is preparing. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..466a1fa --- /dev/null +++ b/composer.json @@ -0,0 +1,23 @@ +{ + "name": "travijuu/bkm-express", + "type": "library", + "description": "BKM Express Payment Library", + "keywords": ["bkm express", "payment", "e-commerce"], + "license": "MIT", + "authors": [ + { + "name": "Erkin Cakar", + "email": "erk.cakar@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "illuminate/support": "5.0.*" + }, + "autoload": { + "psr-0": { + "Travijuu\\BkmExpress": "src/" + } + }, + "minimum-stability": "stable" +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..3347b75 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests/ + + + diff --git a/src/Travijuu/BkmExpress/BkmExpress.php b/src/Travijuu/BkmExpress/BkmExpress.php new file mode 100644 index 0000000..8132f2c --- /dev/null +++ b/src/Travijuu/BkmExpress/BkmExpress.php @@ -0,0 +1,141 @@ +mid = $mid; + $this->successUrl = $successUrl; + $this->cancelUrl = $cancelUrl; + $this->privateKeyPath = $privateKeyPath; + $this->publicKeyPath = $publicKeyPath; + $this->bkmPublicKeyPath = $bkmPublicKeyPath; + + $this->bankList = include('Config/BkmBankList.php'); + } + + public function initPayment($wsdl, $sAmount, $cAmount, $banks) + { + $bkmClient = new BKMSoapClient($wsdl, ['trace' => 1]); + $initPayment = new InitializePayment(); + $initPaymentRequest = new InitializePaymentWSRequest(); + + $initPaymentRequest->setMerchantId($this->mid) + ->setSuccessUrl($this->successUrl) + ->setCancelUrl($this->cancelUrl) + ->setSaleAmount($sAmount) + ->setCargoAmount($cAmount) + ->setBanks($banks) + ->setTimestamp(date('Ymd-H:i:s')); + + $dataToBeHashed = $initPaymentRequest->getDataToBeHashed(); + $signature = Certificate::sign($dataToBeHashed, $this->privateKeyPath); + $verified = Certificate::verify($signature, $dataToBeHashed, $this->publicKeyPath); + + if (! $verified) { + throw new VerificationException("Private / Public key does not match!"); + } + + $initPaymentRequest->setSignature(base64_encode($signature)); + $initPayment->setRequest($initPaymentRequest); + $bkmClient->setParams($initPayment); + + $response = $bkmClient->initializePayment(); + + $verified = $response->verify($this->bkmPublicKeyPath); + + if (! $verified) { + throw new VerificationException("Response can not be verified!"); + } + + if ($response->success()) { + return new RedirectRequest($response, $this->privateKeyPath); + } + + return null; + } + + public function requestMerchInfo($wsdl, $virtualPosList, Closure $saveTokenCallback = null) + { + $this->virtualPosList = $virtualPosList; + + $server = new SoapServer($wsdl, ['classmap' => RequestMerchInfoServer::$classmap]); + $server->setClass( + 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoServer', + $this->publicKeyPath, + $this->privateKeyPath, + $virtualPosList, + $saveTokenCallback + ); + $server->handle(); + } + + public function confirm($data) + { + $incomingResult = new IncomingResult($data); + $verified = $incomingResult->verify($this->bkmPublicKeyPath); + + if (Calculate::timeDiff($incomingResult->getTs()) > 30) { + return Result::build('REQUEST_NOT_SYNCHRONIZED'); + } + + if (! $verified) { + return Result::build('MAC_VERIFICATION_FAILED'); + } + + return $incomingResult; + } + + public function getBank($bankId) + { + foreach ($this->bankList as $bank) { + if ($bank['id'] == $bankId) { + return $bank; + } + } + } + + public function getPosResponse($bankId, $data) + { + $bank = $this->getBank($bankId); + $class = 'PosResponse\Response' . $bank['system']; + + if (! class_exists($class)) { + throw new ClassNotFoundException("{$class} not found!"); + } + + return new $class($data); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/BkmExpressServiceProvider.php b/src/Travijuu/BkmExpress/BkmExpressServiceProvider.php new file mode 100644 index 0000000..3a9bec7 --- /dev/null +++ b/src/Travijuu/BkmExpress/BkmExpressServiceProvider.php @@ -0,0 +1,34 @@ +id; + } + + public function setId($id) + { + $this->id = $id; + + return $this; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + + return $this; + } + + public function getDescription() + { + return $this->expBank; + } + + public function setDescription($description) + { + $this->expBank = $description; + + return $this; + } + + public function getBins() + { + return $this->bins; + } + + public function setBins($bins) + { + if (! is_array($bins)) { + + throw new UnexpectedDataType("Bins should be array"); + } + + $this->bins = []; + + foreach ($bins as $bin) { + + $this->addBin($bin); + } + + return $this; + } + + public function addBin($bin) + { + if (! $bin instanceof Bin) { + + throw new UnexpectedInstance("Should be instance of Bin"); + } + + array_push($this->bins, $bin); + + return $this; + } +} + diff --git a/src/Travijuu/BkmExpress/Common/Bin.php b/src/Travijuu/BkmExpress/Common/Bin.php new file mode 100644 index 0000000..db46d9e --- /dev/null +++ b/src/Travijuu/BkmExpress/Common/Bin.php @@ -0,0 +1,61 @@ +value; + } + + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + public function getInstallments() + { + return $this->insts; + } + + public function setInstallments($installments) + { + if (! is_array($installments)) { + + throw new UnexpectedDataType("Installments should be array"); + } + + $this->insts = []; + + foreach ($installments as $installment) { + + $this->addInstallment($installment); + } + + return $this; + } + + public function addInstallment($installment) + { + if (! $installment instanceof Installment) { + + throw new UnexpectedInstance("Should be instance of Installment"); + } + + array_push($this->insts, $installment); + + return $this; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Common/IncomingResult.php b/src/Travijuu/BkmExpress/Common/IncomingResult.php new file mode 100644 index 0000000..2ce9415 --- /dev/null +++ b/src/Travijuu/BkmExpress/Common/IncomingResult.php @@ -0,0 +1,293 @@ +t = array_get($data, 't', null); + $this->r = array_get($data, 'r', 0); + $this->ts = array_get($data, 'ts', null); + $this->s = array_get($data, 's', null); + $this->xid = array_get($data, 'xid', null); + $this->md = array_get($data, 'md', null); + $this->pData = array_get($data, 'pData', null); + $this->eKey1 = array_get($data, 'eKey1', null); + $this->eKey2 = array_get($data, 'eKey2', null); + + $this->posRef = $this->r ? + array_get($data, 'posMessage', null) : + array_get($data, 'posRef', null); + } + + /** + * @return string + */ + public function getT() + { + return $this->t; + } + + /** + * @param string $t + * + * @return $this; + */ + public function setT($t) + { + $this->t = $t; + + return $this; + } + + /** + * @return string + */ + public function getR() + { + return $this->r; + } + + /** + * @param string $r + * + * @return $this; + */ + public function setR($r) + { + $this->r = $r; + + return $this; + } + + /** + * @return string + */ + public function getPosRef() + { + return $this->success() ? htmlspecialchars_decode($this->posRef) : $this->posRef; + } + + /** + * @param string $posRef + * + * @return $this; + */ + public function setPosRef($posRef) + { + $this->posRef = $posRef; + + return $this; + } + + /** + * @return string + */ + public function getTs() + { + return $this->ts; + } + + /** + * @param string $ts + * + * @return $this; + */ + public function setTs($ts) + { + $this->ts = $ts; + + return $this; + } + + /** + * @return string + */ + public function getS() + { + return $this->s; + } + + /** + * @param string $s + * + * @return $this; + */ + public function setS($s) + { + $this->s = $s; + + return $this; + } + + /** + * @return string + */ + public function getXid() + { + return $this->xid; + } + + /** + * @param string $xid + * + * @return $this; + */ + public function setXid($xid) + { + $this->xid = $xid; + + return $this; + } + + /** + * @return string + */ + public function getMd() + { + return $this->md; + } + + /** + * @param string $md + * + * @return $this; + */ + public function setMd($md) + { + $this->md = $md; + + return $this; + } + + /** + * @return string + */ + public function getPData() + { + return $this->pData; + } + + /** + * @param string $pData + * + * @return $this; + */ + public function setPData($pData) + { + $this->pData = $pData; + + return $this; + } + + /** + * @return string + */ + public function getEKey1() + { + return $this->eKey1; + } + + /** + * @param string $eKey1 + * + * @return $this; + */ + public function setEKey1($eKey1) + { + $this->eKey1 = $eKey1; + + return $this; + } + + /** + * @return string + */ + public function getEKey2() + { + return $this->eKey2; + } + + /** + * @param string $eKey2 + * + * @return $this; + */ + public function setEKey2($eKey2) + { + $this->eKey2 = $eKey2; + + return $this; + } + + public function success() + { + return $this->r == 1; + } + + public function verify($bkmPublicKeyPath) + { + $dataToBeVerified = $this->t . $this->pData . $this->eKey1 . $this->eKey2 . $this->ts; + $decodedSignature = base64_decode($this->s); + + return Certificate::verify($decodedSignature, $dataToBeVerified, $bkmPublicKeyPath); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Common/Installment.php b/src/Travijuu/BkmExpress/Common/Installment.php new file mode 100644 index 0000000..09b652c --- /dev/null +++ b/src/Travijuu/BkmExpress/Common/Installment.php @@ -0,0 +1,113 @@ +amountInst = number_format($amount, 2, ",", ""); + return $this; + } + + public function setCargoAmount($amount) + { + $this->cAmount = number_format($amount, 2, ",", ""); + return $this; + } + + public function setPayCargoAtFirstInstallment($value = false) + { + $this->cPaid1stInst = $value; + return $this; + } + + public function setDescription($description) + { + $this->expInst = $description; + return $this; + } + + public function setInstallment($installment) + { + $this->nofInst = $installment; + $this->updateInstallmentAmount(); + return $this; + } + + public function setAmount($amount) + { + $this->tAmount = number_format($amount, 2, ",", ""); + $this->updateInstallmentAmount(); + return $this; + } + + private function updateInstallmentAmount() + { + if ((! $this->amountInst) && $this->nofInst && $this->tAmount) { + + $this->setInstallmentAmount($this->getTotalAmount(false) / $this->nofInst); + } + } + + public function getInstallment() + { + return $this->nofInst; + } + + public function getInstallmentAmount($asString = true) + { + return $asString ? $this->amountInst : floatval(str_replace(',', '.', $this->amountInst)); + } + + public function getCargoAmount($asString = true) + { + return $asString ? $this->cAmount : floatval(str_replace(',', '.', $this->cAmount)); + } + + public function getTotalAmount($asString = true) + { + return $asString ? $this->tAmount : floatval(str_replace(',', '.', $this->tAmount)); + } + + public function getPayCargoAtFirstInstallment() + { + return $this->cPaid1stInst ? 'true' : 'false'; + } + + public function getDescription() + { + return $this->expInst; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Common/MerchantWSResponseCode.php b/src/Travijuu/BkmExpress/Common/MerchantWSResponseCode.php new file mode 100644 index 0000000..cad0f3c --- /dev/null +++ b/src/Travijuu/BkmExpress/Common/MerchantWSResponseCode.php @@ -0,0 +1,19 @@ + 0, "message" => "Success"]; + public static $UNKNOWN_ERROR = ["code" => 1, "message" => "Unknown Error"]; + public static $REQUEST_NOT_SYNCHRONIZED = ["code" => 2, "message" => "Request Not Synchronized"]; + public static $MAC_VERIFICATION_FAILED = ["code" => 3, "message" => "MAC Verification Failed"]; + public static $INPUT_VALIDATION_ERROR = ["code" => 4, "message" => "INPUT_VALIDATION_ERROR"]; + public static $D3S_MPI_MISSING = ["code" => 5, "message" => "D3S_MPI_MISSING"]; + public static $POS_NOT_MATCHING_POS_URL = ["code" => 6, "message" => "POS Not Matching, POS URL"]; + public static $MPI_NOT_MATCHING = ["code" => 7, "message" => "MPI Not Matching"]; + + // Custom Errors +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Common/Result.php b/src/Travijuu/BkmExpress/Common/Result.php new file mode 100644 index 0000000..555b95f --- /dev/null +++ b/src/Travijuu/BkmExpress/Common/Result.php @@ -0,0 +1,86 @@ +resultCode = $resultCode; + $this->resultMsg = $resultMsg; + $this->resultDet = $resultDet; + } + + public function getCode() + { + return $this->resultCode; + } + + /** + * @param int $resultCode + * + * @return $this + */ + public function setCode($resultCode) + { + $this->resultCode = $resultCode; + + return $this; + } + + public function getMessage() + { + return $this->resultMsg; + } + + /** + * @param string $resultMsg + * + * @return $this + */ + public function setMessage($resultMsg) + { + $this->resultMsg = $resultMsg; + + return $this; + } + + public function getDetail() + { + return $this->resultDet; + } + + /** + * @param string $resultDet + * + * @return $this + */ + public function setDetail($resultDet) + { + $this->resultDet = $resultDet; + + return $this; + } + + public static function build($key) + { + $responseCode = MerchantWSResponseCode::$$key; + return new Result($responseCode['code'], $responseCode['message']); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Common/VirtualPos.php b/src/Travijuu/BkmExpress/Common/VirtualPos.php new file mode 100644 index 0000000..b3b9c0d --- /dev/null +++ b/src/Travijuu/BkmExpress/Common/VirtualPos.php @@ -0,0 +1,318 @@ +posUrl; + } + + /** + * @param string $posUrl + * + * @return $this + */ + public function setPosUrl($posUrl) + { + $this->posUrl = $posUrl; + + return $this; + } + + /** + * @return string + */ + public function getPosUid() + { + return $this->posUid; + } + + /** + * @param string $posUid + * + * @return $this + */ + public function setPosUid($posUid) + { + $this->posUid = $posUid; + + return $this; + } + + /** + * @return string + */ + public function getPosPwd() + { + return $this->posPwd; + } + + /** + * @param string $posPwd + * + * @return $this + */ + public function setPosPwd($posPwd) + { + $this->posPwd = $posPwd; + + return $this; + } + + /** + * @return boolean + */ + public function getIs3ds() + { + return $this->is3ds; + } + + /** + * @param boolean $is3ds + * + * @return $this + */ + public function setIs3ds($is3ds) + { + $this->is3ds = $is3ds; + + return $this; + } + + /** + * @return string + */ + public function getMpiUrl() + { + return $this->mpiUrl; + } + + /** + * @param string $mpiUrl + * + * @return $this + */ + public function setMpiUrl($mpiUrl) + { + $this->mpiUrl = $mpiUrl; + + return $this; + } + + /** + * @return string + */ + public function getMpiUid() + { + return $this->mpiUid; + } + + /** + * @param string $mpiUid + * + * @return $this + */ + public function setMpiUid($mpiUid) + { + $this->mpiUid = $mpiUid; + + return $this; + } + + /** + * @return string + */ + public function getMpiPwd() + { + return $this->mpiPwd; + } + + /** + * @param string $mpiPwd + * + * @return $this + */ + public function setMpiPwd($mpiPwd) + { + $this->mpiPwd = $mpiPwd; + + return $this; + } + + /** + * @return string + */ + public function getMd() + { + return $this->md; + } + + /** + * @param string $md + * + * @return $this + */ + public function setMd($md) + { + $this->md = $md; + + return $this; + } + + /** + * @return string + */ + public function getXid() + { + return $this->xid; + } + + /** + * @param string $xid + * + * @return $this + */ + public function setXid($xid) + { + $this->xid = $xid; + + return $this; + } + + /** + * @return boolean + */ + public function getIs3dsFDec() + { + return $this->is3dsFDec; + } + + /** + * @param boolean $is3dsFDec + * + * @return $this + */ + public function setIs3dsFDec($is3dsFDec) + { + $this->is3dsFDec = $is3dsFDec; + + return $this; + } + + /** + * @return string + */ + public function getCIp() + { + return $this->cIp; + } + + /** + * @param string $cIp + * + * @return $this + */ + public function setCIp($cIp) + { + $this->cIp = $cIp; + + return $this; + } + + /** + * @return string + */ + public function getExtra() + { + return $this->extra; + } + + /** + * @param string $extra + * + * @return $this + */ + public function setExtra($extra) + { + $this->extra = $extra; + + return $this; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Config/BkmBankList.php b/src/Travijuu/BkmExpress/Config/BkmBankList.php new file mode 100644 index 0000000..b6d707e --- /dev/null +++ b/src/Travijuu/BkmExpress/Config/BkmBankList.php @@ -0,0 +1,242 @@ + '0015', + 'name' => 'Türkiye Vakıflar Bankası T.A.O.', + 'system' => 'Posnet', + 'bins' => [ + [ + 'bin' => '411724', + 'description' => 'Vakifbank Worldcard' + ], + [ + 'bin' => '547244', + 'description' => 'Vakifbank Businesscard' + ], + [ + 'bin' => '520017', + 'description' => 'Vakifbank Galatasaray Taraftar Kredi Karti' + ], + [ + 'bin' => '542798', + 'description' => 'Vakifbank Besiktas Taraftar Kredi Karti' + ] + ] + ], + [ + 'id' => '0010', + 'name' => 'T.C. Ziraat Bankası A.Ş.', + 'system' => '', + 'bins' => [ + [ + 'bin' => '469884', + 'description' => 'Ziraat Maximum' + ], + ] + ], + [ + 'id' => '0062', + 'name' => 'T. Garanti Bankası A.Ş.', + 'system' => 'Gvp', + 'bins' => [ + [ + 'bin' => '426888', + 'description' => 'Garanti Bonus' + ], + [ + 'bin' => '432154', + 'description' => 'Garanti Flexi' + ], + [ + 'bin' => '482491', + 'description' => 'Garanti Money' + ], + [ + 'bin' => '514915', + 'description' => 'Garanti Miles&Smiles' + ], + [ + 'bin' => '374421', + 'description' => 'Garanti AmEx' + ], + [ + 'bin' => '526955', + 'description' => 'Garanti Bonus Genç' + ] + ] + ], + [ + 'id' => '0064', + 'name' => 'T. İş Bankası A.Ş.', + 'system' => 'NestPay', + 'bins' => [ + [ + 'bin' => '543771', + 'description' => 'İş Bankası Maximum' + ] + ] + ], + [ + 'id' => '0046', + 'name' => 'Akbank T.A.Ş.', + 'system' => 'NestPay', + 'bins' => [ + [ + 'bin' => '557113', + 'description' => 'Akbank Axess Klasik' + ] + ] + ], + [ + 'id' => '0067', + 'name' => 'Yapı ve Kredi Bankası A.Ş.', + 'system' => 'Posnet', + 'bins' => [ + [ + 'bin' => '540129', + 'description' => 'Yapı Kredi World' + ], + [ + 'bin' => '404809', + 'description' => 'Yapı Kredi Crystal Infinite' + ], + [ + 'bin' => '545103', + 'description' => 'Yapı Kredi Crystal Signia' + ], + [ + 'bin' => '542117', + 'description' => 'Yapı Kredi Koç Ailem' + ], + [ + 'bin' => '479795', + 'description' => 'Yapı Kredi Fenerbahçe World' + ], + [ + 'bin' => '552659', + 'description' => 'Yapı Kredi World Business' + ] + ] + ], + [ + 'id' => '0099', + 'name' => 'ING Bank A.Ş.', + 'system' => 'NestPay', + 'bins' => [ + [ + 'bin' => 'ING Bank Bonus', + 'description' => '550074' + ] + ] + ], + [ + 'id' => '0111', + 'name' => 'Finansbank A.Ş.', + 'system' => 'NestPay', + 'bins' => [ + [ + 'bin' => 'Finansbank CF', + 'description' => '545616' + ] + ] + ], + [ + 'id' => '0208', + 'name' => 'Asya Katılım Bankası A.Ş.', + 'system' => '', + 'bins' => [ + [ + 'bin' => 'Bank Asya AsyaCard', + 'description' => '402275' + ] + ] + ], + [ + 'id' => '0032', + 'name' => 'TEB.A.Ş.', + 'system' => 'Gvp', + 'bins' => [ + [ + 'bin' => '402458', + 'description' => 'TEB Bonus' + ], + [ + 'bin' => '438040', + 'description' => 'TEB World' + ] + ] + ], + [ + 'id' => '0134', + 'name' => 'Denizbank A.Ş.', + 'system' => 'Gvp', + 'bins' => [ + [ + 'bin' => '512117', + 'description' => 'Denizbank Bonus' + ] + ] + ], + [ + 'id' => '0206', + 'name' => 'Türkiye Finans Katılım Bankası A.Ş.', + 'system' => '', + 'bins' => [ + [ + 'bin' => '537719', + 'description' => 'Türkiye Finans Bonus' + ] + ] + ], + [ + 'id' => '0059', + 'name' => 'Şekerbank T.A.Ş.', + 'system' => 'Gvp', + 'bins' => [ + [ + 'bin' => '411156', + 'description' => 'Şekerbank Bonus' + ] + ] + ], + [ + 'id' => '0205', + 'name' => 'Kuveyt Türk Katılım Bankası A.Ş.', + 'system' => 'NestPay', + 'bins' => [ + [ + 'bin' => '511660', + 'description' => 'Kuvety Türk Business Plus' + ], + [ + 'bin' => '402589', + 'description' => 'Kuveyt Türk İhtiyaç Kart' + ], + [ + 'bin' => '525312', + 'description' => 'Kuveyt Türk Sale Plus' + ], + [ + 'bin' => '402590', + 'description' => 'Kuveyt Türk Sale Plus Gold' + ], + [ + 'bin' => '512595', + 'description' => 'Kuveyt Türk Seyyah Kart' + ], + ] + ], + [ + 'id' => '0123', + 'name' => 'HSBC Bank A.Ş.', + 'system' => '', + 'bins' => [ + [ + 'bin' => 'HSBC Advantage Classic', + 'description' => '550472' + ] + ] + ], +]; \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Exception/ClassNotFoundException.php b/src/Travijuu/BkmExpress/Exception/ClassNotFoundException.php new file mode 100644 index 0000000..1e59640 --- /dev/null +++ b/src/Travijuu/BkmExpress/Exception/ClassNotFoundException.php @@ -0,0 +1,7 @@ +result; + } + + public function setResult($result) + { + $this->result = $result; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/InitializePayment/BKMSoapClient.php b/src/Travijuu/BkmExpress/Payment/InitializePayment/BKMSoapClient.php new file mode 100644 index 0000000..2589d86 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/InitializePayment/BKMSoapClient.php @@ -0,0 +1,49 @@ + 'Travijuu\BkmExpress\Payment\InitializePayment\InitializePayment', + 'initializePaymentWSRequest' => 'Travijuu\BkmExpress\Payment\InitializePayment\InitializePaymentWSRequest', + 'bank' => 'Travijuu\BkmExpress\Common\Bank', + 'bin' => 'Travijuu\BkmExpress\Common\Bin', + 'installment' => 'Travijuu\BkmExpress\Common\Installment', + 'initializePaymentResponse' => 'Travijuu\BkmExpress\Payment\InitializePayment\InitializePaymentResponse', + 'initializePaymentWSResponse' => 'Travijuu\BkmExpress\Payment\InitializePayment\InitializePaymentWSResponse', + 'result' => 'Travijuu\BkmExpress\Common\Result', + ); + + public function __construct($wsdl, $options = []) { + + foreach(self::$classmap as $wsdlClassName => $phpClassName) { + + if(! isset($options['classmap'][$wsdlClassName])) { + + $options['classmap'][$wsdlClassName] = $phpClassName; + } + } + + parent::__construct($wsdl, $options); + } + + public function setParams($initializePayment) + { + $this->initializePayment = $initializePayment; + } + + /** + * Service Call: initializePayment + * + * @return InitializePaymentResponse + */ + public function initializePayment() + { + return $this->__soapCall('initializePayment', [$this->initializePayment]); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePayment.php b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePayment.php new file mode 100644 index 0000000..533cc68 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePayment.php @@ -0,0 +1,20 @@ +initializePaymentWSRequest; + } + + public function setRequest(InitializePaymentWSRequest $initializePaymentWSRequest) + { + $this->initializePaymentWSRequest = $initializePaymentWSRequest; + + return $this; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentResponse.php b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentResponse.php new file mode 100644 index 0000000..4e0b45e --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentResponse.php @@ -0,0 +1,39 @@ +initializePaymentWSResponse->getResult()->getCode() == 0; + } + + public function getMessage() + { + return $this->initializePaymentWSResponse->getResult()->getMessage(); + } + + public function getWSResponse() + { + return $this->initializePaymentWSResponse; + } + + public function verify($bkmPublicKeyPath) + { + $dataToBeVerified = $this->initializePaymentWSResponse->getToken() . + $this->initializePaymentWSResponse->getUrl() . + $this->initializePaymentWSResponse->getTimestamp(); + + $decodedSignature = base64_decode($this->initializePaymentWSResponse->getSignature()); + + return Certificate::verify($decodedSignature, $dataToBeVerified, $bkmPublicKeyPath); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSRequest.php b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSRequest.php new file mode 100644 index 0000000..d0e5bc4 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSRequest.php @@ -0,0 +1,132 @@ +mId = $mId; + + return $this; + } + + public function setSuccessUrl($url) + { + $this->sUrl = $url; + + return $this; + } + + public function setCancelUrl($url) + { + $this->cUrl = $url; + + return $this; + } + + public function setSaleAmount($amount) + { + $this->sAmount = number_format($amount, 2, ",", ""); + + return $this; + } + + public function setCargoAmount($amount) + { + $this->cAmount = number_format($amount, 2, ",", ""); + + return $this; + } + + public function setBanks($banks) + { + $this->instOpts = $banks; + + return $this; + } + + public function setTimestamp($timestamp) + { + $this->ts = $timestamp; + + return $this; + } + + public function setSignature($signature) + { + $this->s = $signature; + + return $this; + } + + public function getDataToBeHashed() + { + $data = $this->mId . $this->sUrl . $this->cUrl . $this->sAmount . $this->cAmount; + + foreach ($this->instOpts as $bank) { + + $data .= $bank->getId() . $bank->getName() . $bank->getDescription(); + + foreach ($bank->getBins() as $bin) { + + $data .= $bin->getValue(); + + foreach ($bin->getInstallments() as $installment) { + + $data .= $installment->getInstallment() . $installment->getInstallmentAmount() . $installment->getCargoAmount() . $installment->getTotalAmount() . $installment->getPayCargoAtFirstInstallment() . $installment->getDescription(); + } + } + } + + $data .= $this->ts; + + return $data; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSResponse.php b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSResponse.php new file mode 100644 index 0000000..48e1630 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/InitializePayment/InitializePaymentWSResponse.php @@ -0,0 +1,53 @@ +t; + } + + public function getUrl() + { + return $this->url; + } + + public function getTimestamp() + { + return $this->ts; + } + + public function getSignature() + { + return $this->s; + } + + public function getMessage() + { + return $this->result->getMessage(); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/InitializePayment/RedirectRequest.php b/src/Travijuu/BkmExpress/Payment/InitializePayment/RedirectRequest.php new file mode 100644 index 0000000..3fa1f84 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/InitializePayment/RedirectRequest.php @@ -0,0 +1,64 @@ +t = $response->getWSResponse()->getToken(); + $this->url = $response->getWSResponse()->getUrl(); + + $this->createSignature($privateKeyPath); + } + + public function createSignature($privateKeyPath) + { + $this->ts = date("Ymd-H:i:s"); + $data = $this->t . $this->ts; + $this->s = base64_encode(Certificate::sign($data, $privateKeyPath)); + } + + /** + * @return string + */ + public function getToken() + { + return $this->t; + } + + /** + * @return mixed + */ + public function getSignature() + { + return $this->s; + } + + /** + * @return mixed + */ + public function getTimestamp() + { + return $this->ts; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfo.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfo.php new file mode 100644 index 0000000..aa593c2 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfo.php @@ -0,0 +1,21 @@ +requestMerchInfoWSRequest = new RequestMerchInfoWSRequest(); + } + + public function getWSRequest() + { + return $this->requestMerchInfoWSRequest; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoAction.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoAction.php new file mode 100644 index 0000000..725467b --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoAction.php @@ -0,0 +1,42 @@ + $virtualPos) { + if ($key == $bankId) { + return $virtualPos; + } + } + } + + public function verifyRequest(RequestMerchInfoWSRequest $wsRequest, $bkmPublicKeyPath) + { + $decodedSignature = base64_decode($wsRequest->getSignature()); + + $dataToBeHashed = $wsRequest->getToken() . $wsRequest->getBankId() . + $wsRequest->getBankName() . $wsRequest->getCardBin() . + $wsRequest->getInstallment() . $wsRequest->getTimestamp(); + + return Certificate::verify($decodedSignature, $dataToBeHashed, $bkmPublicKeyPath); + } + + public function signResponse(RequestMerchInfoWSResponse $wsResponse, $privateKeyPath) + { + $dataToBeHashed = $wsResponse->getToken() . $wsResponse->getPosUrl() . + $wsResponse->getPosUid() . $wsResponse->getPosPwd() . + $wsResponse->isS3Dauth() . $wsResponse->getMpiUrl() . + $wsResponse->getMpiUid() . $wsResponse->getMpiPwd() . + $wsResponse->getMd() . $wsResponse->getXid() . + $wsResponse->isS3DFDec() . $wsResponse->getCIp() . + $wsResponse->getExtra() . $wsResponse->getTimestamp(); + + return base64_encode(Certificate::sign($dataToBeHashed, $privateKeyPath)); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoResponse.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoResponse.php new file mode 100644 index 0000000..dfea478 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoResponse.php @@ -0,0 +1,45 @@ +requestMerchInfoWSResponse = new RequestMerchInfoWSResponse(); + } + + /** + * @return RequestMerchInfoWSResponse + */ + public function getWSResponse() + { + return $this->requestMerchInfoWSResponse; + } + + public function setVirtualPos(VirtualPos $virtualPos) + { + $this->requestMerchInfoWSResponse->setPosUrl($virtualPos->getPosUrl()); + $this->requestMerchInfoWSResponse->setPosUid($virtualPos->getPosUid()); + $this->requestMerchInfoWSResponse->setPosPwd($virtualPos->getPosPwd()); + + $this->requestMerchInfoWSResponse->setMpiUrl($virtualPos->getMpiUrl()); + $this->requestMerchInfoWSResponse->setMpiUid($virtualPos->getMpiUid()); + $this->requestMerchInfoWSResponse->setMpiPwd($virtualPos->getMpiPwd()); + $this->requestMerchInfoWSResponse->setS3Dauth($virtualPos->getIs3ds()); + $this->requestMerchInfoWSResponse->setMd($virtualPos->getMd()); + $this->requestMerchInfoWSResponse->setXid($virtualPos->getXid()); + + $this->requestMerchInfoWSResponse->setS3DFDec($virtualPos->getIs3dsFDec()); + $this->requestMerchInfoWSResponse->setCIp($virtualPos->getCIp()); + $this->requestMerchInfoWSResponse->setExtra($virtualPos->getExtra()); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoServer.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoServer.php new file mode 100644 index 0000000..21d9183 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoServer.php @@ -0,0 +1,67 @@ + 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfo', + 'requestMerchInfoWSRequest' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoWSRequest', + 'requestMerchInfoResponse' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoResponse', + 'requestMerchInfoWSResponse' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoWSResponse', + 'requestMerchInfoServiceImpl' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoServer', + 'result' => 'Travijuu\BkmExpress\Common\Result', + ); + + public function __construct($publicKeyPath, $privateKeyPath, $virtualPosList, $callback) + { + $this->publicKeyPath = $publicKeyPath; + $this->privateKeyPath = $privateKeyPath; + $this->callback = $callback; + $this->virtualPosList = $virtualPosList; + } + + /** + * @param RequestMerchInfo $requestMerchInfo + * @return RequestMerchInfoResponse + */ + public function requestMerchInfo($requestMerchInfo) + { + $response = new RequestMerchInfoResponse(); + $response->getWSResponse()->setToken($requestMerchInfo->getWSRequest()->getToken()); + + $requestInfoAction = new RequestMerchInfoAction(); + $virtualPos = $requestInfoAction->getVirtualPos($requestMerchInfo->getWSRequest()->getBankId(), $this->virtualPosList); + + if (is_null($virtualPos)) { + + $response->getWSResponse()->setResult(Result::build('UNKNOWN_ERROR')); + + return $response; + } + + if ($requestInfoAction->verifyRequest($requestMerchInfo->getWSRequest(), $this->publicKeyPath)) { + + $response->getWSResponse()->setResult(Result::build('MAC_VERIFICATION_FAILED')); + + return $response; + } + + if (is_callable($this->callback)) call_user_func($this->callback, $requestMerchInfo->getWSRequest()); + + $response->setVirtualPos($virtualPos); + $response->getWSResponse()->setResult(Result::build('SUCCESS')); + $response->getWSResponse()->setTimestamp(date("Ymd-H:i:s")); + $signature = $requestInfoAction->signResponse($response->getWSResponse(), $this->privateKeyPath); + $response->getWSResponse()->setSignature($signature); + + return $response; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoSoapClient.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoSoapClient.php new file mode 100644 index 0000000..2aafe00 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoSoapClient.php @@ -0,0 +1,87 @@ +php + * @access private + * @var array + */ + private static $classmap = array( + 'requestMerchInfo' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfo', + 'requestMerchInfoWSRequest' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoWSRequest', + 'requestMerchInfoResponse' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoResponse', + 'requestMerchInfoWSResponse' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoWSResponse', + 'requestMerchInfoServiceImpl' => 'Travijuu\BkmExpress\Payment\RequestMerchInfo\RequestMerchInfoServer', + 'result' => 'Travijuu\BkmExpress\Common\Result', + ); + + /** + * Constructor using wsdl location and options array + * @param string $wsdl WSDL location for this service + * @param array $options Options for the SoapClient + */ + public function __construct($wsdl, $options = []) { + + foreach(self::$classmap as $wsdlClassName => $phpClassName) { + + if(!isset($options['classmap'][$wsdlClassName])) { + + $options['classmap'][$wsdlClassName] = $phpClassName; + } + } + + parent::__construct($wsdl, $options); + } + + /** + * Checks if an argument list matches against a valid argument type list + * @param array $arguments The argument list to check + * @param array $validParameters A list of valid argument types + * @return boolean true if arguments match against validParameters + * @throws Exception invalid function signature message + */ + public function _checkArguments($arguments, $validParameters) { + $variables = ""; + foreach ($arguments as $arg) { + $type = gettype($arg); + if ($type == "object") { + $type = get_class($arg); + } + $variables .= "(".$type.")"; + } + if (!in_array($variables, $validParameters)) { + throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables)); + } + return true; + } + + public function setParams(RequestMerchInfo $requestMerchInfo) + { + $this->requestMerchInfo = $requestMerchInfo; + } + + /** + * Service Call: requestMerchInfo + * Parameter options: + * (requestMerchInfo) parameters + * @param mixed,... See function description for parameter options + * @return RequestMerchInfoResponse + * @throws Exception invalid function signature message + */ + public function requestMerchInfo($mixed = null) { + $validParameters = array( + "(requestMerchInfo)", + ); + $args = [$this->requestMerchInfo]; + //$this->_checkArguments($args, $validParameters); + return $this->__soapCall("requestMerchInfo", $args); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSRequest.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSRequest.php new file mode 100644 index 0000000..6d4b087 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSRequest.php @@ -0,0 +1,183 @@ +t; + } + + /** + * @param string $token + * + * @return self + */ + public function setToken($token) + { + $this->t = $token; + + return $this; + } + + /** + * @return string + */ + public function getBankId() + { + return $this->bid; + } + + /** + * @param string $bankId + * + * @return self + */ + public function setBankId($bankId) + { + $this->bid = $bankId; + + return $this; + } + + /** + * @return string + */ + public function getBankName() + { + return $this->bName; + } + + /** + * @param string $bankName + * + * @return self + */ + public function setBankName($bankName) + { + $this->bName = $bankName; + + return $this; + } + + /** + * @return string + */ + public function getCardBin() + { + return $this->cBin; + } + + /** + * @param string $cardBin + * + * @return self + */ + public function setCardBin($cardBin) + { + $this->cBin = $cardBin; + + return $this; + } + + /** + * @return int + */ + public function getInstallment() + { + return $this->nofInst; + } + + /** + * @param int $installment + * + * @return self + */ + public function setInstallment($installment) + { + $this->nofInst = $installment; + + return $this; + } + + /** + * @return string + */ + public function getTimestamp() + { + return $this->ts; + } + + /** + * @param string $timestamp + * + * @return self + */ + public function setTimestamp($timestamp) + { + $this->ts = $timestamp; + + return $this; + } + + /** + * @return string + */ + public function getSignature() + { + return $this->s; + } + + /** + * @param string $signature + * + * @return self + */ + public function setSignature($signature) + { + $this->s = $signature; + + return $this; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSResponse.php b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSResponse.php new file mode 100644 index 0000000..2da1433 --- /dev/null +++ b/src/Travijuu/BkmExpress/Payment/RequestMerchInfo/RequestMerchInfoWSResponse.php @@ -0,0 +1,324 @@ +t; + } + + /** + * @param string $t + */ + public function setToken($t) + { + $this->t = $t; + } + + /** + * @return string + */ + public function getPosUrl() + { + return $this->posUrl; + } + + /** + * @param string $posUrl + */ + public function setPosUrl($posUrl) + { + $this->posUrl = $posUrl; + } + + /** + * @return string + */ + public function getPosUid() + { + return $this->posUid; + } + + /** + * @param string $posUid + */ + public function setPosUid($posUid) + { + $this->posUid = $posUid; + } + + /** + * @return string + */ + public function getPosPwd() + { + return $this->posPwd; + } + + /** + * @param string $posPwd + */ + public function setPosPwd($posPwd) + { + $this->posPwd = $posPwd; + } + + /** + * @return boolean + */ + public function isS3Dauth() + { + return $this->s3Dauth; + } + + /** + * @param boolean $s3Dauth + */ + public function setS3Dauth($s3Dauth) + { + $this->s3Dauth = $s3Dauth; + } + + /** + * @return string + */ + public function getMpiUrl() + { + return $this->mpiUrl; + } + + /** + * @param string $mpiUrl + */ + public function setMpiUrl($mpiUrl) + { + $this->mpiUrl = $mpiUrl; + } + + /** + * @return string + */ + public function getMpiUid() + { + return $this->mpiUid; + } + + /** + * @param string $mpiUid + */ + public function setMpiUid($mpiUid) + { + $this->mpiUid = $mpiUid; + } + + /** + * @return string + */ + public function getMpiPwd() + { + return $this->mpiPwd; + } + + /** + * @param string $mpiPwd + */ + public function setMpiPwd($mpiPwd) + { + $this->mpiPwd = $mpiPwd; + } + + /** + * @return string + */ + public function getMd() + { + return $this->md; + } + + /** + * @param string $md + */ + public function setMd($md) + { + $this->md = $md; + } + + /** + * @return string + */ + public function getXid() + { + return $this->xid; + } + + /** + * @param string $xid + */ + public function setXid($xid) + { + $this->xid = $xid; + } + + /** + * @return boolean + */ + public function isS3DFDec() + { + return $this->s3DFDec; + } + + /** + * @param boolean $s3DFDec + */ + public function setS3DFDec($s3DFDec) + { + $this->s3DFDec = $s3DFDec; + } + + /** + * @return string + */ + public function getCIp() + { + return $this->cIp; + } + + /** + * @param string $cIp + */ + public function setCIp($cIp) + { + $this->cIp = $cIp; + } + + /** + * @return string + */ + public function getExtra() + { + return $this->extra; + } + + /** + * @param string $extra + */ + public function setExtra($extra) + { + $this->extra = $extra; + } + + /** + * @return string + */ + public function getTimestamp() + { + return $this->ts; + } + + /** + * @param string $ts + */ + public function setTimestamp($ts) + { + $this->ts = $ts; + } + + /** + * @return string + */ + public function getSignature() + { + return $this->s; + } + + /** + * @param string $s + */ + public function setSignature($s) + { + $this->s = $s; + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/PosResponse/AbstractPosResponse.php b/src/Travijuu/BkmExpress/PosResponse/AbstractPosResponse.php new file mode 100644 index 0000000..cb8cb64 --- /dev/null +++ b/src/Travijuu/BkmExpress/PosResponse/AbstractPosResponse.php @@ -0,0 +1,192 @@ +setRawResponse($rawResponse); + + $this->build(); + } + + /** + * @return boolean + */ + public function isSuccess() + { + return $this->success; + } + + /** + * @param boolean $success + * + * @return $this + */ + public function setIsSuccess($success) + { + $this->success = $success; + + return $this; + } + + /** + * @return string + */ + public function getOrderId() + { + return $this->orderId; + } + + /** + * @param string $orderId + * + * @return $this + */ + public function setOrderId($orderId) + { + $this->orderId = $orderId; + + return $this; + } + + /** + * @return string + */ + public function getAuthCode() + { + return $this->authCode; + } + + /** + * @param string $authCode + * + * @return $this + */ + public function setAuthCode($authCode) + { + $this->authCode = $authCode; + + return $this; + } + + /** + * @return string + */ + public function getResponseCode() + { + return $this->responseCode; + } + + /** + * @param string $responseCode + * + * @return $this + */ + public function setResponseCode($responseCode) + { + $this->responseCode = $responseCode; + + return $this; + } + + /** + * @return string + */ + public function getResponseMessage() + { + return $this->responseMessage; + } + + /** + * @param string $responseMessage + * + * @return $this + */ + public function setResponseMessage($responseMessage) + { + $this->responseMessage = $responseMessage; + + return $this; + } + + /** + * @return string + */ + public function getTransactionId() + { + return $this->transactionId; + } + + /** + * @param string $transactionId + * + * @return $this + */ + public function setTransactionId($transactionId) + { + $this->transactionId = $transactionId; + + return $this; + } + + /** + * @return string + */ + public function getRawResponse() + { + return $this->rawResponse; + } + + /** + * @param string $rawResponse + * + * @return $this + */ + public function setRawResponse($rawResponse) + { + $this->rawResponse = htmlspecialchars_decode($rawResponse); + + return $this; + } + + public abstract function build(); +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/PosResponse/PosResponseInterface.php b/src/Travijuu/BkmExpress/PosResponse/PosResponseInterface.php new file mode 100644 index 0000000..4407bca --- /dev/null +++ b/src/Travijuu/BkmExpress/PosResponse/PosResponseInterface.php @@ -0,0 +1,36 @@ +getRawResponse()); + + $this->setIsSuccess($response->transaction->response->message == 'Approved') + ->setOrderId($response->order->orderId) + ->setResponseCode($response->transaction->response->code) + ->setResponseMessage($response->transaction->response->errorMsg . $response->transaction->response->sysErrorMsg) + ->setAuthCode($response->authCode); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/PosResponse/ResponseNestPay.php b/src/Travijuu/BkmExpress/PosResponse/ResponseNestPay.php new file mode 100644 index 0000000..ab4795e --- /dev/null +++ b/src/Travijuu/BkmExpress/PosResponse/ResponseNestPay.php @@ -0,0 +1,25 @@ +getRawResponse()); + + $this->setIsSuccess($response->response == 'Approved') + ->setOrderId($response->orderId) + ->setTransactionId($response->transId) + ->setResponseCode($response->extra->errorCode) + ->setResponseMessage($response->errMsg) + ->setAuthCode($response->authCode); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/PosResponse/ResponsePosnet.php b/src/Travijuu/BkmExpress/PosResponse/ResponsePosnet.php new file mode 100644 index 0000000..7af7980 --- /dev/null +++ b/src/Travijuu/BkmExpress/PosResponse/ResponsePosnet.php @@ -0,0 +1,28 @@ +getRawResponse()); + + $this->setIsSuccess($response->approved) + ->setResponseCode($response->respCode) + ->setResponseMessage($response->respText) + ->setAuthCode($response->authCode); + + // TODO: implement + //$this->setOrderId(); + //$this->setTransactionId(); + } +} + diff --git a/src/Travijuu/BkmExpress/Utility/Calculate.php b/src/Travijuu/BkmExpress/Utility/Calculate.php new file mode 100644 index 0000000..6ec0dad --- /dev/null +++ b/src/Travijuu/BkmExpress/Utility/Calculate.php @@ -0,0 +1,17 @@ +diff($now); + + return abs($diff->days * 24 * 60 * 60 + $diff->h * 60 * 60 + $diff->i * 60 + $diff->s); + } +} \ No newline at end of file diff --git a/src/Travijuu/BkmExpress/Utility/Certificate.php b/src/Travijuu/BkmExpress/Utility/Certificate.php new file mode 100644 index 0000000..de94c01 --- /dev/null +++ b/src/Travijuu/BkmExpress/Utility/Certificate.php @@ -0,0 +1,35 @@ +