Result


<' . $functionName . 'Response performedDatetime="' . $performedDatetime . '" code="' . $result_code . '" ' . ($message != null ? 'message="' . $message . '"' : "") . ' invoiceId="' . $invoiceId . '" shopId="' . $this->settings->SHOP_ID . '"/>';
return $response;
} catch (\Exception $e) {
$this->log($e);
}
return null;
}
/**
* Checking for sign when XML/PKCS#7 scheme is used.
* @return array if request is successful, returns key-value array of request params, null otherwise.
*/
private function verifySign() {
$descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
$certificate = 'yamoney.pem';
$process = proc_open('openssl smime -verify -inform PEM -nointern -certfile ' . $certificate . ' -CAfile ' . $certificate,
$descriptorspec, $pipes);
if (is_resource($process)) {
// Getting data from request body.
$data = file_get_contents($this->settings->request_source); // "php://input"
fwrite($pipes[0], $data);
fclose($pipes[0]);
$content = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$resCode = proc_close($process);
if ($resCode != 0) {
return null;
} else {
$this->log("Row xml: " . $content);
$xml = simplexml_load_string($content);
$array = json_decode(json_encode($xml), TRUE);
return $array["@attributes"];
}
}
return null;
}
private function log($str) {
$this->log->info($str);
}
private function sendResponse($responseBody) {
$this->log("Response: " . $responseBody);
header("HTTP/1.0 200");
header("Content-Type: application/xml");
echo $responseBody;
exit;
}
}
?>