/** * Creates the security hash from a number of fields and the shared secret. * * @param string $secret * * @return HppRequest */ public function hash($secret) { //check for any null values and set them to empty string for hashing $timeStamp = null == $this->timeStamp ? "" : $this->timeStamp; $merchantId = null == $this->merchantId ? "" : $this->merchantId; $orderId = null == $this->orderId ? "" : $this->orderId; $amount = null == $this->amount ? "" : $this->amount; $currency = null == $this->currency ? "" : $this->currency; $payerReference = null == $this->payerReference ? "" : $this->payerReference; $paymentReference = null == $this->paymentReference ? "" : $this->paymentReference; $hppSelectStoredCard = null == $this->hppSelectStoredCard ? "" : $this->hppSelectStoredCard; // Override payerRef with hppSelectStoredCard if present. $payRefORStoredCard = empty($hppSelectStoredCard) ? $payerReference : $hppSelectStoredCard; //create String to hash if ($this->cardStorageEnable) { $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $amount . "." . $currency . "." . $payerReference . "." . $paymentReference; } else { if ($payRefORStoredCard && empty($paymentReference)) { $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $amount . "." . $currency . "." . $payRefORStoredCard . "."; } else { if ($payRefORStoredCard && !empty($paymentReference)) { $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $amount . "." . $currency . "." . $payRefORStoredCard . "." . $paymentReference; } else { $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $amount . "." . $currency; } } } $this->hash = GenerationUtils::generateHash($toHash, $secret); return $this; }
/** * Creates the security hash from a number of fields and the shared secret. * * @param string $secret * * @return HppRequest */ public function hash($secret) { //check for any null values and set them to empty string for hashing $timeStamp = null == $this->timeStamp ? "" : $this->timeStamp; $merchantId = null == $this->merchantId ? "" : $this->merchantId; $orderId = null == $this->orderId ? "" : $this->orderId; $amount = null == $this->amount ? "" : $this->amount; $currency = null == $this->currency ? "" : $this->currency; $payerReference = null == $this->payerReference ? "" : $this->payerReference; $paymentReference = null == $this->paymentReference ? "" : $this->paymentReference; //create String to hash if ($this->cardStorageEnable) { $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $amount . "." . $currency . "." . $payerReference . "." . $paymentReference; } else { $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $amount . "." . $currency; } $this->hash = GenerationUtils::generateHash($toHash, $secret); return $this; }
/** * Creates the security hash from a number of fields and the shared secret. * * @param string $secret * * @return String */ public function generateHash($secret) { //check for any null values and set them to empty string for hashing $timeStamp = null == $this->timeStamp ? "" : $this->timeStamp; $merchantId = null == $this->merchantId ? "" : $this->merchantId; $orderId = null == $this->orderId ? "" : $this->orderId; $result = null == $this->result ? "" : $this->result; $message = null == $this->message ? "" : $this->message; $pasRef = null == $this->pasRef ? "" : $this->pasRef; $authCode = null == $this->authCode ? "" : $this->authCode; //create $to hash $toHash = $timeStamp . "." . $merchantId . "." . $orderId . "." . $result . "." . $message . "." . $pasRef . "." . $authCode; return GenerationUtils::generateHash($toHash, $secret); }