/** * 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 == DccInfo::GetClassName()) { return true; } return false; }
private function denormaliseDccInfo($array) { return $this->serializer->denormalize($array['dccinfo'], DccInfo::GetClassName(), $this->format, $this->context); }
/** * Tests the hash calculation for a card-update transaction. */ public function testDccStoredCard() { // add dccinfo. Note that the type is not set as it is already defaulted to 1 $dccInfo = new DccInfo(); $dccInfo->addDccProcessor(SampleXmlValidationUtils::STORED_CARD_DCC_RATE_DCC_CCP); $request = new PaymentRequest(); $request->addType(PaymentType::STORED_CARD_DCC_RATE)->addTimeStamp(SampleXmlValidationUtils::STORED_CARD_DCC_RATE_TIMESTAMP)->addMerchantId(SampleXmlValidationUtils::STORED_CARD_DCC_RATE_MERCHANT_ID)->addAmount(SampleXmlValidationUtils::STORED_CARD_DCC_RATE_AMOUNT)->addCurrency(SampleXmlValidationUtils::STORED_CARD_DCC_RATE_CURRENCY)->addOrderId(SampleXmlValidationUtils::STORED_CARD_DCC_RATE_ORDER_ID)->addDccInfo($dccInfo); $this->assertEquals(SampleXmlValidationUtils::STORED_CARD_DCC_RATE, $request->getType()); }
/** * Tests conversion of {@link PaymentRequest} to and from XML using setters for DCCInfo. */ public function testPaymentRequestXmlDCCAuthSetters() { $request = new PaymentRequest(); $request->setAccount(SampleXmlValidationUtils::DCC_AUTH_ACCOUNT); $request->setMerchantId(SampleXmlValidationUtils::DCC_AUTH_MERCHANT_ID); $card = new Card(); $card->setExpiryDate(SampleXmlValidationUtils::DCC_AUTH_CARD_EXPIRY_DATE); $card->setNumber(SampleXmlValidationUtils::DCC_AUTH_CARD_NUMBER); $card->setType(SampleXmlValidationUtils::DCC_AUTH_CARD_TYPE); $card->setCardHolderName(SampleXmlValidationUtils::DCC_AUTH_CARD_HOLDER_NAME); $request->setCard($card); $dccAmount = new Amount(); $dccAmount->setAmount(SampleXmlValidationUtils::DCC_AUTH_CH_AMOUNT); $dccAmount->setCurrency(SampleXmlValidationUtils::DCC_AUTH_CH_CURRENCY); $dccInfo = new DccInfo(); $dccInfo->setDccProcessor(SampleXmlValidationUtils::DCC_AUTH_CCP); $dccInfo->setRate(SampleXmlValidationUtils::DCC_AUTH_RATE); $dccInfo->setAmount($dccAmount); $request->setDccInfo($dccInfo); $amount = new Amount(); $amount->setAmount(SampleXmlValidationUtils::DCC_AUTH_AMOUNT); $amount->setCurrency(SampleXmlValidationUtils::DCC_AUTH_CURRENCY); $request->setAmount($amount); $autoSettle = new AutoSettle(); $autoSettle->setFlag(SampleXmlValidationUtils::$AUTO_SETTLE_FLAG->getFlag()); $request->setAutoSettle($autoSettle); $request->setTimeStamp(SampleXmlValidationUtils::DCC_AUTH_TIMESTAMP); $request->setOrderId(SampleXmlValidationUtils::DCC_AUTH_ORDER_ID); $request->setHash(SampleXmlValidationUtils::DCC_AUTH_REQUEST_HASH); // convert to XML $xml = $request->toXml(); // Convert from XML back to PaymentRequest /* @var PaymentRequest $fromXmlRequest */ $fromXmlRequest = new PaymentRequest(); $fromXmlRequest = $fromXmlRequest->fromXml($xml); SampleXmlValidationUtils::checkUnmarshalledDccAuthLookUpPaymentRequest($fromXmlRequest, $this); }