/**
  * 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 == FraudFilter::GetClassName()) {
         return true;
     }
     return false;
 }
 private function denormaliseFraudFilter(\ArrayAccess $array)
 {
     $fraudFilterData = $array['fraudresponse'];
     if (!isset($fraudFilterData) || !is_array($fraudFilterData)) {
         return null;
     }
     $data = new SafeArrayAccess($fraudFilterData);
     $ffr = new FraudFilter();
     $ffr->setMode($data['@mode']);
     $ffr->setResult($data['result']);
     $rules = $data['rules'];
     $ffrRules = new FraudFilterRuleCollection();
     if (!empty($rules)) {
         foreach ($rules as $currentRule) {
             // Ensure that $rules is an array of results
             if (isset($currentRule['@id'])) {
                 $currentRule = array(0 => $currentRule);
             }
             foreach ($currentRule as $ffrRule) {
                 $ffrRule = new SafeArrayAccess($ffrRule);
                 $tmpRule = new FraudFilterRule();
                 $tmpRule->setId($ffrRule['@id']);
                 $tmpRule->setName($ffrRule['@name']);
                 $tmpRule->setAction($ffrRule['action']);
                 $ffrRules->add($tmpRule);
             }
         }
         $ffr->setRules($ffrRules);
     }
     return $ffr;
 }
 private function denormaliseFraudFilter(\ArrayAccess $array)
 {
     return $this->serializer->denormalize($array['fraudfilter'], FraudFilter::GetClassName(), $this->format, $this->context);
 }
 /**
  * Tests and invalid currency value (null)
  */
 public function testNullValueOnCurrency()
 {
     $card = new Card();
     $card->addExpiryDate(SampleXmlValidationUtils::CARD_EXPIRY_DATE)->addNumber(SampleXmlValidationUtils::CARD_NUMBER)->addCardType(new CardType(CardType::VISA))->addCardHolderName(SampleXmlValidationUtils::CARD_HOLDER_NAME)->addCvn(SampleXmlValidationUtils::CARD_CVN_NUMBER)->addCvnPresenceIndicator(SampleXmlValidationUtils::$CARD_CVN_PRESENCE)->addIssueNumber(SampleXmlValidationUtils::CARD_ISSUE_NUMBER);
     $tssInfo = new TssInfo();
     $businessAddress = new Address();
     $businessAddress->addType(SampleXmlValidationUtils::$ADDRESS_TYPE_BUSINESS)->addCode(SampleXmlValidationUtils::ADDRESS_CODE_BUSINESS)->addCountry(SampleXmlValidationUtils::ADDRESS_COUNTRY_BUSINESS);
     $shippingAddress = new Address();
     $shippingAddress->addType(SampleXmlValidationUtils::$ADDRESS_TYPE_SHIPPING)->addCode(SampleXmlValidationUtils::ADDRESS_CODE_SHIPPING)->addCountry(SampleXmlValidationUtils::ADDRESS_COUNTRY_SHIPPING);
     $tssInfo->addCustomerNumber(SampleXmlValidationUtils::CUSTOMER_NUMBER)->addProductId(SampleXmlValidationUtils::PRODUCT_ID)->addVariableReference(SampleXmlValidationUtils::VARIABLE_REFERENCE)->addCustomerIpAddress(SampleXmlValidationUtils::CUSTOMER_IP)->addAddress($businessAddress)->addAddress($shippingAddress);
     $autoSettle = new AutoSettle();
     $autoSettle = $autoSettle->addFlag(SampleXmlValidationUtils::$AUTO_SETTLE_FLAG);
     $mpi = new Mpi();
     $mpi->addCavv(SampleXmlValidationUtils::THREE_D_SECURE_CAVV)->addXid(SampleXmlValidationUtils::THREE_D_SECURE_XID)->addEci(SampleXmlValidationUtils::THREE_D_SECURE_ECI);
     $recurring = new Recurring();
     $recurring->addFlag(SampleXmlValidationUtils::$RECURRING_FLAG)->addSequence(SampleXmlValidationUtils::$RECURRING_SEQUENCE)->addType(SampleXmlValidationUtils::$RECURRING_TYPE);
     $fraudFilter = new FraudFilter();
     $fraudFilter->addMode(SampleXmlValidationUtils::$FRAUD_FILTER);
     $expectedCurrency = null;
     $request = new PaymentRequest();
     $request->addAccount(SampleXmlValidationUtils::ACCOUNT)->addMerchantId(SampleXmlValidationUtils::MERCHANT_ID)->addType(PaymentType::AUTH)->addAmount(SampleXmlValidationUtils::AMOUNT)->addCurrency($expectedCurrency)->addCard($card)->addAutoSettle($autoSettle)->addTimestamp(SampleXmlValidationUtils::TIMESTAMP)->addChannel(SampleXmlValidationUtils::CHANNEL)->addOrderId(SampleXmlValidationUtils::ORDER_ID)->addHash(SampleXmlValidationUtils::REQUEST_HASH)->addComment(SampleXmlValidationUtils::COMMENT1)->addComment(SampleXmlValidationUtils::COMMENT2)->addPaymentsReference(SampleXmlValidationUtils::PASREF)->addAuthCode(SampleXmlValidationUtils::AUTH_CODE)->addRefundHash(SampleXmlValidationUtils::REFUND_HASH)->addFraudFilter($fraudFilter)->addRecurring($recurring)->addTssInfo($tssInfo)->addMpi($mpi);
     // convert to XML
     $xml = $request->toXml();
     // Convert from XML back to PaymentRequest
     /* @var PaymentRequest $fromXmlRequest */
     $fromXmlRequest = new PaymentRequest();
     $fromXmlRequest = $fromXmlRequest->fromXml($xml);
     $this->assertEquals($expectedCurrency, $fromXmlRequest->getAmount()->getCurrency());
 }