Example #1
0
        public void VoidWithSuccess(VoidModel voids, string responseData, string receiptId)
        {
            var httpClient = Substitute.For <IHttpClient>();
            var response   = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(responseData)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource <HttpResponseMessage>();

            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient, DotNetLoggerFactory.Create, "http://something.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            var paymentReceiptResult = judo.Voids.Create(voids).Result;

            Assert.NotNull(paymentReceiptResult);
            Assert.IsFalse(paymentReceiptResult.HasError);
            Assert.NotNull(paymentReceiptResult.Response);
            Assert.That(paymentReceiptResult.Response.ReceiptId, Is.EqualTo(134567));
        }
Example #2
0
        public void CollectionWithError(VoidModel voids, string responseData, JudoApiError error)
        {
            var httpClient = Substitute.For <IHttpClient>();
            var response   = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(responseData)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource <HttpResponseMessage>();

            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient, DotNetLoggerFactory.Create, "http://something.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            var paymentReceiptResult = judo.Voids.Create(voids).Result;

            Assert.NotNull(paymentReceiptResult);
            Assert.IsTrue(paymentReceiptResult.HasError);
            Assert.IsNull(paymentReceiptResult.Response);
            Assert.IsNotNull(paymentReceiptResult.Error);
            Assert.AreEqual((int)error, paymentReceiptResult.Error.Code);
        }
Example #3
0
        public void ExtraHeadersAreSent(VoidModel voids, string responseData, string receiptId)
        {
            const string EXTRA_HEADER_NAME = "X-Extra-Request-Header";

            var httpClient = Substitute.For <IHttpClient>();
            var response   = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(responseData)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource <HttpResponseMessage>();

            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Is <HttpRequestMessage>(r => r.Headers.Contains(EXTRA_HEADER_NAME))).Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient, DotNetLoggerFactory.Create, "http://something.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            voids.HttpHeaders.Add(EXTRA_HEADER_NAME, "some random value");

            IResult <ITransactionResult> refundReceipt = judo.Voids.Create(voids).Result;

            Assert.NotNull(refundReceipt);
            Assert.IsFalse(refundReceipt.HasError);
            Assert.NotNull(refundReceipt.Response);
            Assert.That(refundReceipt.Response.ReceiptId, Is.EqualTo(134567));
        }
Example #4
0
        private void btnVoidSale_MouseClick(object sender, MouseEventArgs e)
        {
            if (Environment.GetEnvironmentVariable("BAES", EnvironmentVariableTarget.User) == null)
            {
                MessageBox.Show("Admin Password is not yet setup. Please setup an Admin Password to Void Sales and try again.", "Void Sale", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }

            if (txtPassword.Text == Environment.GetEnvironmentVariable("BAES", EnvironmentVariableTarget.User))
            {
                VoidModel voidModel = new VoidModel
                {
                    SeriesNumber = lblSeriesNumber.Text,
                    Void         = "TRUE"
                };

                DatabaseClass.UpdateVoidSaleRecord(voidModel);
                MessageBox.Show("Series Number '" + lblSeriesNumber.Text + " is successfully voided.", "Void Sale", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Incorrect Admin Password.", "Void Sale", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void ASimplePreAuthAndVoid()
        {
            var paymentWithCard = GetCardPaymentModel();

            var response = JudoPayApi.PreAuths.Create(paymentWithCard).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);

            var receipt = response.Response as PaymentReceiptModel;

            Assert.IsNotNull(receipt);

            Assert.AreEqual("Success", receipt.Result);
            Assert.AreEqual("PreAuth", receipt.Type);

            var voidPreAuth = new VoidModel
            {
                Amount    = 25,
                ReceiptId = response.Response.ReceiptId,
            };

            response = JudoPayApi.Voids.Create(voidPreAuth).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);

            receipt = response.Response as PaymentReceiptModel;

            Assert.IsNotNull(receipt);

            Assert.AreEqual("Success", receipt.Result);
            Assert.AreEqual("VOID", receipt.Type);
        }
Example #6
0
        public Task <IResult <ITransactionResult> > Create(VoidModel voidTransaction)
        {
            var validationError = Validate <VoidModel, ITransactionResult>(voidValidator, voidTransaction);

            return(validationError ?? PostInternal <VoidModel, ITransactionResult>(CREATE_ADDRESS, voidTransaction));
        }