Exemplo n.º 1
0
 /**
  * @param Hypercharge\IUrl $url
  * @param Hypercharge\IRequest $request
  * @return Hypercharge\IResponse
  * @throws Hypercharge\Error
  */
 public function call(IUrl $url, IRequest $request)
 {
     $curl = Config::getFactory()->createHttpsClient(Config::getUser(), Config::getPassword());
     $serializer = new XmlSerializer();
     $responseStr = $curl->xmlPost($url->get(), $serializer->toXml($request));
     $responseDom = new \SimpleXMLElement($responseStr);
     return $request->createResponse(XmlSerializer::dom2hash($responseDom));
 }
    function test_dom2hash_attributes_in_multiple_nodes()
    {
        $xml = '<?xml version="1.0" encoding="UTF-8"?>
<root>
	<one a="2.1 attribute">
		<two>2.1</two>
	</one>
	<one a="2.2 attribute">
		<two>2.2</two>
	</one>
</root>
';
        $dom = new \SimpleXMLElement($xml);
        $h = XmlSerializer::dom2hash($dom);
        $this->assertEqual($h, array('root' => array('one' => array(array('two' => '2.1', '__attributes' => array('a' => '2.1 attribute')), array('two' => '2.2', '__attributes' => array('a' => '2.2 attribute'))))), '%s' . print_r($h, true));
    }
Exemplo n.º 3
0
 /**
  * @private
  * @param string $action
  * @param string $channelToken
  * @param string $unique_id
  * @return Hypercharge\Transaction
  */
 static function request($action, $channelToken, $unique_id)
 {
     $url = new TransactionUrl(Config::ENV_SANDBOX, $channelToken, $action);
     $url = $url->get() . '/' . $unique_id;
     $curl = new Curl(Config::getUser(), Config::getPassword());
     $responseStr = $curl->xmlPost($url, '');
     $responseDom = new \SimpleXMLElement($responseStr);
     // dummy
     $request = new TransactionRequest(array('transaction_type' => 'sale'));
     return $request->createResponse(XmlSerializer::dom2hash($responseDom));
 }
 function parseResponseFixture($xmlFile)
 {
     $dom = new \SimpleXMLElement($this->fixture($xmlFile));
     return XmlSerializer::dom2hash($dom);
 }