Exemplo n.º 1
0
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/YandexMoney3/Utils/Array2XML.php';
//require_once($_SERVER['DOCUMENT_ROOT'] . '/classes/YandexMoney3/YandexMoney3.php');
//------------------------------------------------------------------------------
$results = array();
//$profiler = new profiler();
//------------------------------------------------------------------------------
//use YandexMoney3\Request\DepositionRequest;
//use YandexMoney3\Request\BalanceRequest;
//use YandexMoney3\YandexMoney3;
use YandexMoney3\Utils\Array2XML;
//------------------------------------------------------------------------------
$params = array('@attributes' => array('agentId' => 200385, 'clientOrderId' => 272517, 'requestDT' => date('c'), 'dstAccount' => '25700130535186', 'amount' => '249.00', 'currency' => 10643, 'contract' => ''), 'identification' => array('@attributes' => array('docType' => "21", 'docNumber' => "4004 123987", 'issueDate' => "1976-01-01", 'authorityName' => "25 о/м Приморского р-на г. Санкт-Петербурга", 'authorityCode' => "780-025", 'residence' => "г.Санкт-Петербург, 3-я улица Строителей, д.25, кв.12")), 'paymentParams' => array('skr_destinationCardSynonim' => '79052075556', 'pdr_firstName' => 'Владимир', 'pof_offerAccepted' => 1, 'pdr_secondName' => 'Владимирович', 'pdr_lastName' => 'Владимиров', 'cps_phoneNumber' => 79052075556, 'pdr_docType' => 21, 'pdr_docNum' => 4002109067, 'pdr_postcode' => 194044, 'pdr_country' => 'Санкт-Петербург', 'pdr_city' => '', 'pdr_address' => 'Большой пр, ПС, д.12'));
$converter = new Array2XML();
$converter->setConvertFromEncoding('windows-1251');
$converter->setTopNodeName('test');
$converter->importArray($params);
$data = $converter->saveXml();
print_r($data);
exit;
//------------------------------------------------------------------------------
//$profiler->start('fill_frl_mem');
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//$profiler->stop('fill_frl_mem');
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
array_walk($results, function (&$value, $key) {
    $value = sprintf('%s = %s' . PHP_EOL, $key, $value);
});
print_r(implode('', $results));
exit;
Exemplo n.º 2
0
if (empty($bodyRaw)) {
    exit;
}
$xml = simplexml_load_string($bodyRaw);
$json = json_encode($xml);
$decodedArray = json_decode($json, true);
$is_fail = false;
$clientOrderId = @$decodedArray['@attributes']['clientOrderId'];
if (!$clientOrderId) {
    $is_fail = true;
}
$converter = new Array2XML();
$converter->setConvertFromEncoding('windows-1251');
$converter->setTopNodeName($method . 'Response');
if ($is_fail) {
    $converter->importArray(array('clientOrderId' => $clientOrderId, 'status' => 3, 'error' => 41, 'processedDT' => date('c')));
    echo $converter->saveXml();
}
switch ($method) {
    case 'testDeposition':
        /*
         * <?xml version="1.0" encoding="UTF-8"?>
         * <testDepositionResponse clientOrderId="12345" status="0" processedDT="2011-07-01T20:38:01.000Z"/>
         */
        $converter->importArray(array('@attributes' => array('clientOrderId' => $clientOrderId, 'status' => 0, 'processedDT' => date('c'))));
        break;
    case 'makeDeposition':
        /*
         * <?xml version="1.0" encoding="UTF-8"?>
         * <makeDepositionResponse clientOrderId="12345" status="0" processedDT="2011-07-01T20:38:01.000Z" balance="1000.00"/>
         */
Exemplo n.º 3
0
 /**
  * @param string $uri
  * @param string $params
  * @return OriginalServerResponse
  */
 private function makePostCurlRequest($uri, $params)
 {
     $cmd = key($params);
     $params = current($params);
     $converter = new Array2XML();
     $converter->setConvertFromEncoding('windows-1251');
     $converter->setTopNodeName($cmd);
     $converter->importArray($params);
     $data = $converter->saveXml();
     $crypt = $this->getCryptOption();
     if ($crypt) {
         $cryptBlock = new CryptBlock($crypt);
         $encryptData = $cryptBlock->encrypt($data);
     } else {
         $encryptData = $data;
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/log.php";
     $log = new \log('reserves_payout/' . SERVER . '-%d%m%Y.log');
     $log->writeln(PHP_EOL . PHP_EOL);
     $log->writeln('[' . date('d.m.Y H:i:s') . ']');
     $log->writeln($data);
     $headers = $this->prepareRequestHeaders();
     $curl = curl_init($uri);
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     if ($crypt) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
         curl_setopt($curl, CURLOPT_SSLCERT, $crypt['encrypt_cert_path']);
         curl_setopt($curl, CURLOPT_SSLKEY, $crypt['private_key_path']);
         curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $crypt['passphrase']);
     }
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
     curl_setopt($curl, CURLOPT_TIMEOUT, 80);
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $encryptData);
     //$this->writeMessageToLogFile($this->prepareLogMessage($uri, $params));
     $responseRaw = curl_exec($curl);
     $errorCode = curl_errno($curl);
     $errorMessage = curl_error($curl);
     $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     $responseHeaderSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
     $responseHeadersRaw = trim(substr($responseRaw, 0, $responseHeaderSize));
     $responseBodyRaw = trim(substr($responseRaw, $responseHeaderSize));
     curl_close($curl);
     if ($responseCode == 200) {
         if ($crypt && $cryptBlock->isReqDecrypt()) {
             $responseBodyRaw = $cryptBlock->decrypt($responseBodyRaw);
         }
         $log->writeln($responseBodyRaw);
     }
     /*
     $this->writeMessageToLogFile(
         $this->prepareLogMessageExtended($uri, $params, $responseCode, $errorCode, $errorMessage)
     );
     */
     $this->originalServerResponse = new OriginalServerResponse();
     $this->originalServerResponse->setCode($responseCode);
     $this->originalServerResponse->setHeadersRaw($responseHeadersRaw);
     $this->originalServerResponse->setBodyRaw($responseBodyRaw);
     $this->originalServerResponse->setErrorCode($errorCode);
     $this->originalServerResponse->setErrorMessage($errorMessage);
 }