/**
  * Test if the full response is successful.
  */
 public function testIsSuccess()
 {
     $response = new PaymentResponse();
     // test success
     $response->setResult(iResponse::RESULT_CODE_SUCCESS);
     $this->assertTrue(ResponseUtils::isSuccess($response));
     // test failure
     $response->setResult("101");
     $this->assertFalse(ResponseUtils::isSuccess($response));
 }
 private function tss_is_empty(PaymentResponse $response)
 {
     return $response->getTssResult()->getResult() == null && $response->getTssResult()->getChecks() == null;
 }
 /**
  * Tests conversion of {@link PaymentResponse} to and from XML.
  */
 public function testPaymentResponseXmlAndDeserializeOverallResults()
 {
     $response = new PaymentResponse();
     $response->setAccount(SampleXmlValidationUtils::ACCOUNT);
     $response->setAcquirerResponse(SampleXmlValidationUtils::ACQUIRER_RESPONSE);
     $response->setAuthCode(SampleXmlValidationUtils::AUTH_CODE);
     $response->setAuthTimeTaken(SampleXmlValidationUtils::AUTH_TIME_TAKEN);
     $response->setBatchId(SampleXmlValidationUtils::BATCH_ID);
     $cardIssuer = new CardIssuer();
     $cardIssuer->setBank(SampleXmlValidationUtils::BANK);
     $cardIssuer->setCountry(SampleXmlValidationUtils::COUNTRY);
     $cardIssuer->setCountryCode(SampleXmlValidationUtils::COUNTRY_CODE);
     $cardIssuer->setRegion(SampleXmlValidationUtils::REGION);
     $response->setCardIssuer($cardIssuer);
     $response->setCvnResult(SampleXmlValidationUtils::CVN_RESULT);
     $response->setMerchantId(SampleXmlValidationUtils::MERCHANT_ID);
     $response->setMessage(SampleXmlValidationUtils::MESSAGE);
     $response->setOrderId(SampleXmlValidationUtils::ORDER_ID);
     $response->setPaymentsReference(SampleXmlValidationUtils::PASREF);
     $response->setResult(SampleXmlValidationUtils::RESULT_SUCCESS);
     $response->setHash(SampleXmlValidationUtils::RESPONSE_HASH);
     $response->setTimeStamp(SampleXmlValidationUtils::TIMESTAMP_RESPONSE);
     $response->setTimeTaken(SampleXmlValidationUtils::TIME_TAKEN);
     $tssResult = new TssResult();
     $tssResult->setResult(SampleXmlValidationUtils::TSS_RESULT);
     $response->setTssResult($tssResult);
     $response->setAvsAddressResponse(SampleXmlValidationUtils::AVS_ADDRESS);
     $response->setAvsPostcodeResponse(SampleXmlValidationUtils::AVS_POSTCODE);
     //marshal to XML
     $xml = $response->toXml();
     //unmarshal back to response
     /* @var PaymentResponse $fromXmlResponse */
     $fromXmlResponse = new PaymentResponse();
     $fromXmlResponse = $fromXmlResponse->fromXml($xml);
     SampleXmlValidationUtils::checkUnmarshalledPaymentResponse($fromXmlResponse, $this, true);
 }
 private function fraudfilter_is_empty(PaymentResponse $response)
 {
     return $response->getFraudFilter()->getResult() == null && $response->getFraudFilter()->getRules() == null;
 }
 private static function getClassName($xml, MessageType $messageType)
 {
     switch ($messageType) {
         case MessageType::PAYMENT:
             if (self::IsRequest($xml)) {
                 return PaymentRequest::GetClassName();
             }
             return PaymentResponse::GetClassName();
         case MessageType::THREE_D_SECURE:
             if (self::IsRequest($xml)) {
                 return ThreeDSecureRequest::GetClassName();
             }
             return ThreeDSecureResponse::GetClassName();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function responseFromXml($xml)
 {
     $paymentResponse = new PaymentResponse();
     return $paymentResponse->fromXML($xml);
 }
 /**
  *  Check all fields match expected values.
  *
  * @param PaymentResponse $fromXmlResponse
  * @param PHPUnit_Framework_TestCase $testCase
  */
 public static function checkUnmarshalledPaymentResponseWithFraudFilterNoRules(PaymentResponse $fromXmlResponse, PHPUnit_Framework_TestCase $testCase, $ignoreTssChecks = false)
 {
     $fraudFilter = $fromXmlResponse->getFraudFilter();
     $testCase->assertEquals(FraudFilterMode::ACTIVE, $fraudFilter->getMode());
     $testCase->assertEquals(FraudFilterResult::NOT_EXECUTED, $fraudFilter->getResult());
     $testCase->assertEmpty($fraudFilter->getRules());
     $testCase->assertEquals(self::FRAUD_FILTER_TIMESTAMP, $fromXmlResponse->getTimeStamp());
     $testCase->assertEquals(self::FRAUD_FILTER_MERCHANT_ID, $fromXmlResponse->getMerchantId());
     $testCase->assertEquals(self::FRAUD_FILTER_ACCOUNT, $fromXmlResponse->getAccount());
     $testCase->assertEquals(self::FRAUD_FILTER_ORDER_ID, $fromXmlResponse->getOrderId());
     $testCase->assertEquals(self::FRAUD_FILTER_AUTH_CODE, $fromXmlResponse->getAuthCode());
     $testCase->assertEquals(self::FRAUD_FILTER_RESULTT, $fromXmlResponse->getResult());
     $testCase->assertEquals(self::FRAUD_FILTER_CVN_RESULT, $fromXmlResponse->getCvnResult());
     $testCase->assertEquals(self::FRAUD_FILTER_AVS_POST, $fromXmlResponse->getAvsPostcodeResponse());
     $testCase->assertEquals(self::FRAUD_FILTER_AVS_ADD, $fromXmlResponse->getAvsAddressResponse());
     $testCase->assertEquals(self::FRAUD_FILTER_BATCH_ID, $fromXmlResponse->getBatchId());
     $testCase->assertEquals(self::FRAUD_FILTER_MESSAGE, $fromXmlResponse->getMessage());
     $testCase->assertEquals(self::FRAUD_FILTER_PAS_REF, $fromXmlResponse->getPaymentsReference());
     $testCase->assertEquals(self::FRAUD_FILTER_TIME_TAKEN, $fromXmlResponse->getTimeTaken());
     $testCase->assertEquals(self::FRAUD_FILTER_AUTH_TIME, $fromXmlResponse->getAuthTimeTaken());
     $testCase->assertEquals(self::FRAUD_FILTER_HASH, $fromXmlResponse->getHash());
 }
 /**
  * Check all fields match expected values.
  *
  * @param PaymentResponse $response
  * @param PHPUnit_Framework_TestCase $testCase
  */
 public static function checkFullResponseError(PaymentResponse $response, PHPUnit_Framework_TestCase $testCase)
 {
     $testCase->assertEquals(self::ACCOUNT, $response->getAccount());
     $testCase->assertEquals(self::ACQUIRER_RESPONSE, $response->getAcquirerResponse());
     $testCase->assertEquals(self::AUTH_CODE, $response->getAuthCode());
     $testCase->assertEquals(self::AUTH_TIME_TAKEN, $response->getAuthTimeTaken());
     $testCase->assertEquals(self::BATCH_ID, $response->getBatchId());
     $testCase->assertEquals(self::BANK, $response->getCardIssuer()->getBank());
     $testCase->assertEquals(self::COUNTRY, $response->getCardIssuer()->getCountry());
     $testCase->assertEquals(self::COUNTRY_CODE, $response->getCardIssuer()->getCountryCode());
     $testCase->assertEquals(self::REGION, $response->getCardIssuer()->getRegion());
     $testCase->assertEquals(self::CVN_RESULT, $response->getCvnResult());
     $testCase->assertEquals(self::MERCHANT_ID, $response->getMerchantId());
     $testCase->assertEquals(self::MESSAGE_FULL_ERROR, $response->getMessage());
     $testCase->assertEquals(self::ORDER_ID, $response->getOrderId());
     $testCase->assertEquals(self::PASREF, $response->getPaymentsReference());
     $testCase->assertEquals(self::RESULT_FULL_ERROR, $response->getResult());
     $testCase->assertEquals(self::RESPONSE_FULL_ERROR_HASH, $response->getHash());
     $testCase->assertEquals(self::TIMESTAMP, $response->getTimeStamp());
     $testCase->assertEquals(self::TIME_TAKEN, $response->getTimeTaken());
     $testCase->assertEquals(self::TSS_RESULT, $response->getTssResult()->getResult());
     $checks = $response->getTssResult()->getChecks();
     $testCase->assertEquals(self::TSS_RESULT_CHECK1_ID, $checks[0]->getId());
     $testCase->assertEquals(self::TSS_RESULT_CHECK1_VALUE, $checks[0]->getValue());
     $testCase->assertEquals(self::TSS_RESULT_CHECK2_ID, $checks[1]->getId());
     $testCase->assertEquals(self::TSS_RESULT_CHECK2_VALUE, $checks[1]->getValue());
     $testCase->assertFalse($response->isSuccess());
 }