public function initPayment($wsdl, $sAmount, $cAmount, $banks) { $bkmClient = new InitializePaymentSoapClient($wsdl, ['trace' => 1, 'cache_wsdl' => WSDL_CACHE_NONE]); $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 cannot be verified!"); } if ($response->success()) { return new RedirectRequest($response, $this->privateKeyPath); } return null; }
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)); }
/** * @param $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)); }
/** * @param $bkmPublicKeyPath * @return boolean */ public function verify($bkmPublicKeyPath) { $dataToBeVerified = $this->t . $this->posRef . $this->xid . $this->md . $this->ts; $decodedSignature = base64_decode($this->s); return Certificate::verify($decodedSignature, $dataToBeVerified, $bkmPublicKeyPath); }
/** * @param $bkmPublicKeyPath * @return boolean */ 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); }