/** * Returns TRUE if payment is declared fraud by Gopay * * @return bool */ public function isFraud() { try { GopayHelper::checkPaymentIdentity((double) $this->valuesToBeVerified['targetGoId'], (double) $this->valuesToBeVerified['paymentSessionId'], null, $this->valuesToBeVerified['orderNumber'], $this->valuesToBeVerified['encryptedSignature'], (double) $this->gopayId, $this->getVariable(), $this->gopaySecretKey); return FALSE; } catch (\Exception $e) { return TRUE; } }
/** * Castecne vraceni platby * * @param float $paymentSessionId - identifikator platby * @param float $amount - castka na vraceni * @param String $currency - mena * @param String $description - popis vraceni platby * @param float $targetGoId - identifikator prijemnce - GoId * @param string $secureKey - kryptovaci klic prideleny GoPay */ public function refundPaymentPartially($paymentSessionId, $amount, $currency, $description, $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::concatRefundRequest((double) $targetGoId, (double) $paymentSessionId, $amount, $currency, $description, $secureKey)), $secureKey); $refundRequest = array("targetGoId" => (double) $targetGoId, "paymentSessionId" => (double) $paymentSessionId, "amount" => $amount, "currency" => $currency, "description" => $description, "encryptedSignature" => $sessionEncryptedSignature); $paymentResult = $go_client->__call("partiallyRefundPayment", array("refundRequest" => $refundRequest)); 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"); } }
/** * Pretypovani datoveho typu boolean pro webovou sluzbu * * @param boolean $boolean * * @return integer (0|1), v pripade nevalidniho zadani se vraci "" */ public static function castBooleanForWS($boolean) { $boolean = GopayHelper::castString2Boolean($boolean); if ($boolean === FALSE) { return 0; } else { if ($boolean === TRUE) { return 1; } else { return ""; } } }
/** * 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()); }
/** * 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); }