/**
  * 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())
 {
     $this->format = $format;
     $this->context = $context;
     $request = new ThreeDSecureRequest();
     $array = new SafeArrayAccess($data);
     $request->addTimestamp($array['@timestamp'])->addType($array['@type'])->addMerchantId($array['merchantid'])->addAccount($array['account'])->addOrderId($array['orderid'])->addHash($array['sha1hash'])->addPares($array['pares'])->addPayerReference($array['payerref'])->addPaymentMethod($array['paymentmethod']);
     $request->setCard($this->denormaliseCard($array));
     $request->setPaymentData($this->denormalisePaymentData($array));
     $request->setAutoSettle($this->denormaliseAutoSettle($array));
     $request->setAmount($this->denormaliseAmount($array));
     $request->setComments($this->denormaliseComments($array));
     return $request;
 }
 /**
  * Tests conversion of {@link ThreeDSecureRequest} card enrolled to and from XML using setters.
  */
 public function testThreeDSecureCardEnrolledRequestXmlWithSetters()
 {
     $request = new ThreeDSecureRequest();
     $request->setAccount(SampleXmlValidationUtils::CARD_VERIFY_ACCOUNT);
     $request->setMerchantId(SampleXmlValidationUtils::CARD_VERIFY_MERCHANT_ID);
     $paymentData = new PaymentData();
     $paymentData->addCvnNumber(SampleXmlValidationUtils::CARD_PAYMENT_DATA_CVN);
     $request->setPaymentData($paymentData);
     $amount = new Amount();
     $amount->setAmount(SampleXmlValidationUtils::CARD_VERIFY_AMOUNT);
     $amount->setCurrency(SampleXmlValidationUtils::CARD_VERIFY_CURRENCY);
     $request->setAmount($amount);
     $request->setTimeStamp(SampleXmlValidationUtils::CARD_VERIFY_TIMESTAMP);
     $request->setOrderId(SampleXmlValidationUtils::CARD_VERIFY_ORDER_ID);
     $request->setPaymentMethod(SampleXmlValidationUtils::CARD_VERIFY_REF);
     $request->setPayerRef(SampleXmlValidationUtils::CARD_VERIFY_PAYER_REF);
     $request->setHash(SampleXmlValidationUtils::CARD_VERIFY_REQUEST_HASH);
     $request->setType(ThreeDSecureType::VERIFY_STORED_CARD_ENROLLED);
     $autoSettle = new AutoSettle();
     $autoSettle->setFlag(SampleXmlValidationUtils::$CARD_VERIFY_AUTO_SETTLE_FLAG->getFlag());
     $request->setAutoSettle($autoSettle);
     // convert to XML
     $xml = $request->toXml();
     // Convert from XML back to PaymentRequest
     /* @var ThreeDSecureRequest $fromXmlRequest */
     $fromXmlRequest = new ThreeDSecureRequest();
     $fromXmlRequest = $fromXmlRequest->fromXml($xml);
     SampleXmlValidationUtils::checkUnmarshalledVerifyCardEnrolledPaymentRequest($fromXmlRequest, $this);
 }