public void ThreeDSecureRequestSigXmlFromFileTest() { //Convert from XML back to PaymentRequest ThreeDSecureRequest fromXmlRequest = new ThreeDSecureRequest().FromXml(Resources._3ds_verify_sig_request_sample); sx.checkUnmarshalledVerifySigRequest(fromXmlRequest); }
public void ThreeDSecureRequestXmlHelpersNoEnumsTest() { Card card = new Card() .AddExpiryDate(sx.CARD_EXPIRY_DATE) .AddNumber(sx.CARD_NUMBER) .AddType(CardType.VISA) .AddCardHolderName(sx.CARD_HOLDER_NAME) .AddIssueNumber(sx.CARD_ISSUE_NUMBER) .AddCvn(sx.CARD_CVN_NUMBER) .AddCvnPresenceIndicator(sx.CARD_CVN_PRESENCE); ThreeDSecureRequest request = new ThreeDSecureRequest() .AddAccount(sx.ACCOUNT) .AddMerchantId(sx.MERCHANT_ID) .AddType(ThreeDSecureType.VERIFY_ENROLLED) .AddAmount(sx.AMOUNT) .AddCurrency(sx.CURRENCY) .AddCard(card) .AddTimestamp(sx.TIMESTAMP) .AddOrderId(sx.ORDER_ID) .AddHash(sx.THREE_D_SECURE_VERIFY_ENROLLED_REQUEST_HASH); //convert to XML string xml = request.ToXml(); //Convert from XML back to PaymentRequest ThreeDSecureRequest fromXmlRequest = new ThreeDSecureRequest().FromXml(xml); sx.checkUnmarshalledVerifyEnrolledRequest(fromXmlRequest); }
public void SendThreeDSecureInvalidResponseHashTest() { //get sample response XML ThreeDSecureResponse fromXmlResponse = new ThreeDSecureResponse().FromXml(Resources._3ds_verify_enrolled_response_sample); fromXmlResponse.Hash = "invalid hash"; //mock HttpResponse _handler.AddFakeResponse(HttpConfiguration.DEFAULT_ENDPOINT, new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(fromXmlResponse.ToXml()) }); //create empty request ThreeDSecureRequest request = new ThreeDSecureRequest(); //create configuration HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.OnlyAllowHttps = false; //mock HttpClient instance HttpClient httpClientMock = new HttpClient(_handler); //execute send on client RealexClient realexClient = new RealexClient(SampleXmlValidationUtils.SECRET, httpConfiguration, httpClientMock); realexClient.Send(request); //shouldn't get this far Assert.Fail("RealexException should have been thrown before this point."); }
public void SendThreeDSecureVerifyEnrolledTest() { //get sample response XML ThreeDSecureResponse fromXmlResponse = new ThreeDSecureResponse().FromXml(Resources._3ds_verify_enrolled_response_sample); //mock HttpResponse _handler.AddFakeResponse(HttpConfiguration.DEFAULT_ENDPOINT, new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(fromXmlResponse.ToXml()) }); //create empty request ThreeDSecureRequest request = new ThreeDSecureRequest(); //create configuration HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.OnlyAllowHttps = false; //mock HttpClient instance HttpClient httpClientMock = new HttpClient(_handler); //execute send on client RealexClient realexClient = new RealexClient(SampleXmlValidationUtils.SECRET, httpConfiguration, httpClientMock); ThreeDSecureResponse response = realexClient.Send(request); //validate response SampleXmlValidationUtils.checkUnmarshalledThreeDSecureEnrolledResponse(response); }
/** * Check all fields match expected values. * * @param fromXmlRequest */ public static void checkUnmarshalledVerifyEnrolledRequest(ThreeDSecureRequest fromXmlRequest) { Assert.IsNotNull(fromXmlRequest); Assert.AreEqual(CARD_NUMBER, fromXmlRequest.Card.Number); Assert.AreEqual(CARD_TYPE, fromXmlRequest.Card.Type); Assert.AreEqual(CARD_HOLDER_NAME, fromXmlRequest.Card.CardHolderName); Assert.AreEqual(CARD_EXPIRY_DATE, fromXmlRequest.Card.ExpiryDate); Assert.AreEqual(ACCOUNT, fromXmlRequest.Account); Assert.AreEqual(MERCHANT_ID, fromXmlRequest.MerchantId); Assert.AreEqual(ThreeDSecureType.VERIFY_ENROLLED, fromXmlRequest.Type); Assert.AreEqual(AMOUNT, fromXmlRequest.Amount.Amount); Assert.AreEqual(CURRENCY, fromXmlRequest.Amount.Currency); Assert.AreEqual(TIMESTAMP, fromXmlRequest.Timestamp); Assert.AreEqual(ORDER_ID, fromXmlRequest.OrderId); Assert.AreEqual(THREE_D_SECURE_VERIFY_ENROLLED_REQUEST_HASH, fromXmlRequest.Hash); }
public void ThreeDSecureSigRequestXmlWithSettersTest() { Card card = new Card(); card.ExpiryDate = sx.CARD_EXPIRY_DATE; card.Number = sx.CARD_NUMBER; card.Type = CardType.VISA; card.CardHolderName = sx.CARD_HOLDER_NAME; card.IssueNumber = sx.CARD_ISSUE_NUMBER; Cvn cvn = new Cvn(); cvn.Number = sx.CARD_CVN_NUMBER; cvn.PresenceIndicator = sx.CARD_CVN_PRESENCE; card.Cvn = cvn; ThreeDSecureRequest request = new ThreeDSecureRequest(); request.Account = sx.ACCOUNT; request.MerchantId = sx.MERCHANT_ID; RxpAmount amount = new RxpAmount(); amount.Amount = sx.AMOUNT; amount.Currency = sx.CURRENCY; request.Amount = amount; request.Card = card; request.Timestamp = sx.TIMESTAMP; request.OrderId = sx.ORDER_ID; request.Pares = sx.THREE_D_SECURE_PARES; request.Hash = sx.THREE_D_SECURE_VERIFY_SIG_REQUEST_HASH; request.Type = ThreeDSecureType.VERIFY_SIG; //convert to XML string xml = request.ToXml(); //Convert from XML back to PaymentRequest ThreeDSecureRequest fromXmlRequest = new ThreeDSecureRequest().FromXml(xml); sx.checkUnmarshalledVerifySigRequest(fromXmlRequest); }