/**
  * Tests the hash calculation for a verify card transaction.
  */
 public function testVerifyCardEnrolledHashGeneration()
 {
     $request = new ThreeDSecureRequest();
     $request->addType(ThreeDSecureType::VERIFY_STORED_CARD_ENROLLED)->addTimeStamp(SampleXmlValidationUtils::CARD_VERIFY_TIMESTAMP)->addMerchantId(SampleXmlValidationUtils::CARD_VERIFY_MERCHANT_ID)->addOrderId(SampleXmlValidationUtils::CARD_VERIFY_ORDER_ID)->addAmount(SampleXmlValidationUtils::CARD_VERIFY_AMOUNT)->addCurrency(SampleXmlValidationUtils::CARD_VERIFY_CURRENCY)->addPayerReference(SampleXmlValidationUtils::CARD_VERIFY_PAYER_REF);
     $request->hash(SampleXmlValidationUtils::SECRET);
     $this->assertEquals(SampleXmlValidationUtils::CARD_VERIFY_REQUEST_HASH, $request->getHash());
 }
 /**
  * Tests the hash calculation for an auth payment.
  */
 public function testVerifySigHashGeneration()
 {
     $card = new Card();
     $request = new ThreeDSecureRequest();
     $request->addType(ThreeDSecureType::VERIFY_SIG)->addTimeStamp(SampleXmlValidationUtils::TIMESTAMP)->addMerchantId(SampleXmlValidationUtils::MERCHANT_ID)->addOrderId(SampleXmlValidationUtils::ORDER_ID)->addAmount(SampleXmlValidationUtils::AMOUNT)->addCurrency(SampleXmlValidationUtils::CURRENCY)->addCard($card->addNumber(SampleXmlValidationUtils::CARD_NUMBER));
     $request->hash(SampleXmlValidationUtils::SECRET);
     $this->assertEquals(SampleXmlValidationUtils::REQUEST_HASH, $request->getHash());
 }
 /**
  * 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 normaliseCard(ThreeDSecureRequest $request)
 {
     $card = $request->getCard();
     if (is_null($card)) {
         return array();
     }
     return array_filter(array('number' => $card->getNumber(), 'expdate' => $card->getExpiryDate(), 'chname' => $card->getCardHolderName(), 'type' => $card->getType(), 'issueno' => $card->getIssueNumber(), 'cvn' => $this->normaliseCVN($card)));
 }
예제 #5
0
 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();
     }
 }
 /**
  * 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 == ThreeDSecureRequest::GetClassName()) {
         return true;
     }
     return false;
 }
 /**
  * Tests conversion of {@link ThreeDSecureRequest} card enrolled to and from XML using setters.
  */
 public function testThreeDSecureCardEnrolledRequestXmlWithSetters()
 {
     $request = new ThreeDSecureRequest();
     $request->setAccount(SampleXmlValidationUtils::CARD_VERIFY_ACCOUNT);
     $request->setMerchantId(SampleXmlValidationUtils::CARD_VERIFY_MERCHANT_ID);
     $paymentData = new PaymentData();
     $paymentData->addCvnNumber(SampleXmlValidationUtils::CARD_PAYMENT_DATA_CVN);
     $request->setPaymentData($paymentData);
     $amount = new Amount();
     $amount->setAmount(SampleXmlValidationUtils::CARD_VERIFY_AMOUNT);
     $amount->setCurrency(SampleXmlValidationUtils::CARD_VERIFY_CURRENCY);
     $request->setAmount($amount);
     $request->setTimeStamp(SampleXmlValidationUtils::CARD_VERIFY_TIMESTAMP);
     $request->setOrderId(SampleXmlValidationUtils::CARD_VERIFY_ORDER_ID);
     $request->setPaymentMethod(SampleXmlValidationUtils::CARD_VERIFY_REF);
     $request->setPayerRef(SampleXmlValidationUtils::CARD_VERIFY_PAYER_REF);
     $request->setHash(SampleXmlValidationUtils::CARD_VERIFY_REQUEST_HASH);
     $request->setType(ThreeDSecureType::VERIFY_STORED_CARD_ENROLLED);
     $autoSettle = new AutoSettle();
     $autoSettle->setFlag(SampleXmlValidationUtils::$CARD_VERIFY_AUTO_SETTLE_FLAG->getFlag());
     $request->setAutoSettle($autoSettle);
     // convert to XML
     $xml = $request->toXml();
     // Convert from XML back to PaymentRequest
     /* @var ThreeDSecureRequest $fromXmlRequest */
     $fromXmlRequest = new ThreeDSecureRequest();
     $fromXmlRequest = $fromXmlRequest->fromXml($xml);
     SampleXmlValidationUtils::checkUnmarshalledVerifyCardEnrolledPaymentRequest($fromXmlRequest, $this);
 }