public PaymentResult CreatePaymentResultFromFile(string fileName)
        {
            var client         = CreateMockTestClientRequest(fileName);
            var payment        = new Payment(client);
            var paymentRequest = MockPaymentDataRequest.CreateFullPaymentRequest();

            var paymentResult = payment.Authorise(paymentRequest);

            return(GetAdditionaData(paymentResult));
        }
Beispiel #2
0
        public void TestAuthorise3DSuccessMocked()
        {
            var client         = CreateMockTestClientRequest("Mocks/authorise3d-success.json");
            var payment        = new Payment(client);
            var paymentRequest = MockPaymentDataRequest.CreateFullPaymentRequest3D();
            var paymentResult  = payment.Authorise3D(paymentRequest);

            Assert.AreEqual(paymentResult.ResultCode, ResultCodeEnum.Authorised);
            Assert.IsNotNull(paymentResult.PspReference);
        }
        public void TestCancelReceivedMocked()
        {
            var paymentResultPspReference = MockPaymentDataRequest.GetTestPspReferenceMocked();
            //Call authorization test
            var client        = base.CreateMockTestClientRequest("Mocks/cancel-received.json");
            var modification  = new Modification(client);
            var cancelRequest = base.CreateCancelTestRequest(pspReference: paymentResultPspReference);
            var refundResult  = modification.Cancel(cancelRequest);

            Assert.AreEqual(refundResult.Response, Adyen.EcommLibrary.Model.Enum.ResponseEnum.CancelReceived);
        }
Beispiel #4
0
        public void TestAuthoriseSuccess3DMocked()
        {
            var client         = CreateMockTestClientRequest("Mocks/authorise-success-3d.json");
            var payment        = new Payment(client);
            var paymentRequest = MockPaymentDataRequest.CreateFullPaymentRequest();
            var paymentResult  = payment.Authorise(paymentRequest);

            Assert.IsNotNull(paymentResult.Md);
            Assert.IsNotNull(paymentResult.IssuerUrl);
            Assert.IsNotNull(paymentResult.PaRequest);
        }
        public void TestCaptureMockedSuccess()
        {
            var paymentResultPspReference = MockPaymentDataRequest.GetTestPspReferenceMocked();
            //Call authorization test
            var client       = base.CreateMockTestClientRequest("Mocks/capture-success.json");
            var modification = new Modification(client);
            //Send capture call with psp refernce
            var captureRequest = base.CreateCaptureTestRequest(paymentResultPspReference);
            var captureResult  = modification.Capture(captureRequest);

            Assert.AreEqual(captureResult.Response, Adyen.EcommLibrary.Model.Enum.ResponseEnum.CaptureReceived);
        }
        public void TestCaptureError167()
        {
            var paymentResultPspReference = MockPaymentDataRequest.GetTestPspReferenceMocked();
            //Call authorization test
            var client         = base.CreateMockTestClientRequest("Mocks/capture-error-167.json");
            var modification   = new Modification(client);
            var captureRequest = base.CreateCaptureTestRequest(paymentResultPspReference);
            var captureResult  = modification.Capture(captureRequest);

            Assert.AreEqual(captureResult.Status, "422");
            Assert.AreEqual(captureResult.ErrorCode, "167");
        }
        /// <summary>
        /// Creates mock test client
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        protected Client CreateMockTestClientRequest(string fileName)
        {
            var mockPath = GetMockFilePath(fileName);
            var response = MockFileToString(mockPath);
            //Create a mock interface
            var clientInterfaceMock = new Mock <IClient>();
            var confMock            = MockPaymentDataRequest.CreateConfingMock();

            clientInterfaceMock.Setup(x => x.Request(It.IsAny <string>(),
                                                     It.IsAny <string>(), confMock)).Returns(response);
            var clientMock = new Client(It.IsAny <Config>())
            {
                HttpClient = clientInterfaceMock.Object,
                Config     = confMock
            };

            return(clientMock);
        }
        /// <summary>
        /// Creates mock test client errors
        /// </summary>
        /// <param name="status"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        protected Client CreateMockTestClientForErrors(int status, string fileName)
        {
            var mockPath = GetMockFilePath(fileName);
            var response = MockFileToString(mockPath);
            //Create a mock interface
            var clientInterfaceMock = new Mock <IClient>();
            var confMock            = MockPaymentDataRequest.CreateConfingMock();
            var httpClientException = new HttpClientException(status, "An error occured", new Dictionary <string, List <string> >(), response);

            clientInterfaceMock.Setup(x => x.Request(It.IsAny <string>(),
                                                     It.IsAny <string>(), confMock)).Throws(httpClientException);

            var clientMock = new Client(It.IsAny <Config>())
            {
                HttpClient = clientInterfaceMock.Object,
                Config     = confMock
            };

            return(clientMock);
        }