/** * Creates encrypted signature for given given payment session id * * @param int $paymentSessionId * @return string */ protected function createSignature($paymentSessionId) { return GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession($this->gopay->config->getGopayId(), (double) $paymentSessionId, $this->gopay->config->getGopaySecretKey())), $this->gopay->config->getGopaySecretKey()); }
/** * Vraceni platby * * @param float $paymentSessionId - identifikator platby * @param float $targetGoId - identifikator prijemnce - GoId * @param string $secureKey - kryptovaci klic prideleny GoPay */ public function refundPayment($paymentSessionId, $targetGoId, $secureKey) { try { //inicializace WS ini_set("soap.wsdl_cache_enabled", "0"); $go_client = new SoapClient(GopayConfig::ws(), array()); $sessionEncryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession((double) $targetGoId, (double) $paymentSessionId, $secureKey)), $secureKey); $paymentSession = array("targetGoId" => (double) $targetGoId, "paymentSessionId" => (double) $paymentSessionId, "encryptedSignature" => $sessionEncryptedSignature); $paymentResult = $go_client->__call('refundPayment', array('sessionInfo' => $paymentSession)); if ($paymentResult->result == GopayHelper::CALL_RESULT_FAILED) { throw new Exception("payment not refunded [" . $paymentResult->resultDescription . "]"); } else { if ($paymentResult->result == GopayHelper::CALL_RESULT_ACCEPTED) { //vraceni platby bylo zarazeno ke zpracovani throw new Exception(GopayHelper::CALL_RESULT_ACCEPTED); } } return $paymentResult->paymentSessionId; } catch (SoapFault $f) { /* * Chyba v komunikaci s GoPay serverem */ throw new Exception("SOAP error"); } }
/** * Creates encrypted signature for given given payment session id * * @param int * @return string */ private function createSignature($paymentSessionId) { return GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession((double) $this->gopayId, (double) $paymentSessionId, $this->gopaySecretKey)), $this->gopaySecretKey); }