/**
  * Checks whether the given class is supported for denormalization by this normalizer.
  *
  * @param mixed $data Data to denormalize from.
  * @param string $type The class to which the data should be denormalized.
  * @param string $format The format being deserialized from.
  *
  * @return bool
  */
 public function supportsDenormalization($data, $type, $format = null)
 {
     if ($format == "xml" && $type == DccInfoResult::GetClassName()) {
         return true;
     }
     return false;
 }
 /**
  * Denormalizes data back into an object of the given class.
  *
  * @param mixed $data data to restore
  * @param string $class the expected class to instantiate
  * @param string $format format the given data was extracted from
  * @param array $context options available to the denormalizer
  *
  * @return object
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     $response = new PaymentResponse();
     $array = new SafeArrayAccess($data);
     $response->setTimeStamp($array['@timestamp']);
     $response->setMerchantId($array['merchantid']);
     $response->setAccount($array['account']);
     $response->setOrderId($array['orderid']);
     $response->setResult($array['result']);
     $response->setAuthCode($array['authcode']);
     $response->setMessage($array['message']);
     $response->setPaymentsReference($array['pasref']);
     $response->setCvnResult($array['cvnresult']);
     $response->setTimeTaken($array['timetaken']);
     $response->setAuthTimeTaken($array['authtimetaken']);
     $response->setAcquirerResponse($array['acquirerresponse']);
     $response->setBatchId($array['batchid']);
     $response->setHash($array['sha1hash']);
     $response->setAvsPostcodeResponse($array['avspostcoderesponse']);
     $response->setAvsAddressResponse($array['avsaddressresponse']);
     $response->setTssResult($this->denormaliseTss($array));
     $response->setCardIssuer($this->denormaliseCardIssuer($array));
     $response->setDccInfoResult($this->serializer->denormalize($array['dccinfo'], DccInfoResult::GetClassName(), $format, $context));
     $response->setFraudFilter($this->denormaliseFraudFilter($array));
     return $response;
 }
 /**
  * Tests conversion of {@link PaymentResponse} to and from XML.
  */
 public function testPaymentResponseDccInfoXml()
 {
     $response = new PaymentResponse();
     $response->setAccount(SampleXmlValidationUtils::DCC_RATE_ACCOUNT_RESPONSE);
     $response->setResult(SampleXmlValidationUtils::DCC_RATE_RESULT_RESPONSE);
     $response->setCvnResult(SampleXmlValidationUtils::DCC_RATE_CVN_RESULT_RESPONSE);
     $response->setMerchantId(SampleXmlValidationUtils::DCC_RATE_MERCHANT_ID_RESPONSE);
     $response->setOrderId(SampleXmlValidationUtils::DCC_RATE_ORDER_ID_RESPONSE);
     $response->setPaymentsReference(SampleXmlValidationUtils::DCC_RATE_PASREF_RESPONSE);
     $response->setHash(SampleXmlValidationUtils::DCC_RATE_REQUEST_HASH_RESPONSE);
     $response->setTimeStamp(SampleXmlValidationUtils::DCC_RATE_TIMESTAMP_RESPONSE);
     $dccInfoResult = new DccInfoResult();
     $dccInfoResult->setCardHolderAmount(SampleXmlValidationUtils::DCC_RATE_CH_AMOUNT_RESPONSE);
     $dccInfoResult->setCardHolderCurrency(SampleXmlValidationUtils::DCC_RATE_CH_CURRENCY_RESPONSE);
     $dccInfoResult->setCardHolderRate(SampleXmlValidationUtils::DCC_RATE_CH_RATE_RESPONSE);
     $dccInfoResult->setMerchantAmount(SampleXmlValidationUtils::DCC_RATE_MERCHANT_AMOUNT_RESPONSE);
     $dccInfoResult->setMerchantCurrency(SampleXmlValidationUtils::DCC_RATE_MERCHANT_CURRENCY_RESPONSE);
     $response->setDccInfoResult($dccInfoResult);
     // convert to XML
     $xml = $response->toXml();
     // Convert from XML back to PaymentResponse
     /* @var PaymentResponse $fromXmlResponse */
     $fromXmlResponse = new PaymentResponse();
     $fromXmlResponse = $fromXmlResponse->fromXml($xml);
     SampleXmlValidationUtils::checkUnmarshalledDCCPaymentResponse($fromXmlResponse, $this);
 }