/**
  * 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} verify sig to and from XML using setters.
  */
 public function testThreeDSecureSigRequestXmlWithSetters()
 {
     $card = new Card();
     $card->setExpiryDate(SampleXmlValidationUtils::CARD_EXPIRY_DATE);
     $card->setNumber(SampleXmlValidationUtils::CARD_NUMBER);
     $card->setType(SampleXmlValidationUtils::$CARD_TYPE->getType());
     $card->setCardHolderName(SampleXmlValidationUtils::CARD_HOLDER_NAME);
     $card->setIssueNumber(SampleXmlValidationUtils::CARD_ISSUE_NUMBER);
     $cvn = new Cvn();
     $cvn->setNumber(SampleXmlValidationUtils::CARD_CVN_NUMBER);
     $cvn->setPresenceIndicator(SampleXmlValidationUtils::$CARD_CVN_PRESENCE->getIndicator());
     $card->setCvn($cvn);
     $request = new ThreeDSecureRequest();
     $request->setAccount(SampleXmlValidationUtils::ACCOUNT);
     $request->setMerchantId(SampleXmlValidationUtils::MERCHANT_ID);
     $amount = new Amount();
     $amount->setAmount(SampleXmlValidationUtils::AMOUNT);
     $amount->setCurrency(SampleXmlValidationUtils::CURRENCY);
     $request->setAmount($amount);
     $request->setCard($card);
     $request->setTimeStamp(SampleXmlValidationUtils::TIMESTAMP);
     $request->setOrderId(SampleXmlValidationUtils::ORDER_ID);
     $request->setPares(SampleXmlValidationUtils::THREE_D_SECURE_PARES);
     $request->setHash(SampleXmlValidationUtils::THREE_D_SECURE_VERIFY_SIG_REQUEST_HASH);
     $request->setType(ThreeDSecureType::VERIFY_SIG);
     //convert to XML
     $xml = $request->toXml();
     // Convert from XML back to PaymentRequest
     /* @var ThreeDSecureRequest $fromXmlRequest */
     $fromXmlRequest = new ThreeDSecureRequest();
     $fromXmlRequest = $fromXmlRequest->fromXml($xml);
     SampleXmlValidationUtils::checkUnmarshalledVerifySigRequest($fromXmlRequest, $this);
 }