/** * 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 == Cvn::GetClassName()) { return true; } return false; }
/** * 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); }
private function denormaliseCVN($data) { return $this->serializer->denormalize($data['cvn'], Cvn::GetClassName(), $this->format, $this->context); }