Exemplo n.º 1
0
        protected Task <IResult <WebPaymentRequestModel> > Update(WebPaymentRequestModel model, string transactionType)
        {
            var validationError = Validate <WebPaymentRequestModel, WebPaymentRequestModel>(_webPaymentValidator, model);

            var address = string.Format("{0}/{1}", Baseaddress, transactionType);

            return(validationError ?? PutInternal <WebPaymentRequestModel, WebPaymentRequestModel>(address, model));
        }
Exemplo n.º 2
0
        public void PaymentUpdate()
        {
            var judo = JudoPaymentsFactory.Create(Configuration.Token,
                                                  Configuration.Secret,
                                                  Configuration.Baseaddress);

            var request = new WebPaymentRequestModel
            {
                Amount      = 10,
                CardAddress = new WebPaymentCardAddress
                {
                    CardHolderName = "Test User",
                    Line1          = "Test Street",
                    Line2          = "Test Street",
                    Line3          = "Test Street",
                    Town           = "London",
                    PostCode       = "W31 4HS",
                    Country        = "England"
                },
                ClientIpAddress       = "127.0.0.1",
                CompanyName           = "Test",
                Currency              = "GBP",
                ExpiryDate            = DateTimeOffset.Now,
                JudoId                = Configuration.Judoid,
                PartnerServiceFee     = 10,
                PaymentCancelUrl      = "http://test.com",
                PaymentSuccessUrl     = "http://test.com",
                Reference             = "42421",
                Status                = WebPaymentStatus.Open,
                TransactionType       = TransactionType.PAYMENT,
                YourConsumerReference = "4235325",
                YourPaymentReference  = "42355"
            };

            var result = judo.WebPayments.Payments.Create(request).Result;

            Assert.NotNull(result);
            Assert.IsFalse(result.HasError);
            Assert.NotNull(result.Response);
            Assert.NotNull(result.Response.Reference);
            Assert.NotNull(result.Response.PostUrl);

            request.Status    = WebPaymentStatus.Paid;
            request.Reference = result.Response.Reference;

            var resultUpdate = judo.WebPayments.Payments.Update(request).Result;

            Assert.NotNull(resultUpdate);
            Assert.IsFalse(resultUpdate.HasError);
            Assert.NotNull(resultUpdate.Response);
            Assert.NotNull(resultUpdate.Response.Reference);
            Assert.AreEqual(result.Response.Reference, resultUpdate.Response.Reference);
            Assert.AreEqual(resultUpdate.Response.Status, resultUpdate.Response.Status);
        }
Exemplo n.º 3
0
        public void CreatePreAuth()
        {
            var httpClient = Substitute.For <IHttpClient>();
            var request    = new WebPaymentRequestModel
            {
                Amount      = 10,
                CardAddress = new WebPaymentCardAddress
                {
                    CardHolderName = "Test User",
                    Line1          = "Test Street",
                    Line2          = "Test Street",
                    Line3          = "Test Street",
                    Town           = "London",
                    PostCode       = "W31 4HS",
                    Country        = "England"
                },
                ClientIpAddress       = "127.0.0.1",
                CompanyName           = "Test",
                Currency              = "GBP",
                ExpiryDate            = DateTimeOffset.Now,
                JudoId                = "1254634",
                PartnerServiceFee     = 10,
                PaymentCancelUrl      = "http://test.com",
                PaymentSuccessUrl     = "http://test.com",
                Reference             = "42421",
                Status                = WebPaymentStatus.Open,
                TransactionType       = TransactionType.PAYMENT,
                YourConsumerReference = "4235325",

                Receipt = new PaymentReceiptModel
                {
                    ReceiptId      = 134567,
                    Type           = "Create",
                    JudoId         = 12456,
                    OriginalAmount = 20,
                    Amount         = 20,
                    NetAmount      = 20,
                    CardDetails    = new CardDetails
                    {
                        CardLastfour = "1345",
                        EndDate      = "1214",
                        CardToken    = "ASb345AE",
                        CardType     = CardType.VISA
                    },
                    Currency = "GBP",
                    Consumer = new Consumer
                    {
                        ConsumerToken         = "B245SEB",
                        YourConsumerReference = "Consumer1"
                    }
                }
            };
            var response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(@"{
		                                             postUrl : 'http://test.com',
		                                             reference : '1342423'   
                                                }")
            };

            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.WebPayments.PreAuths.Create(request).Result;

            Assert.NotNull(paymentReceiptResult);
            Assert.IsFalse(paymentReceiptResult.HasError);
            Assert.NotNull(paymentReceiptResult.Response);
            Assert.AreEqual("1342423", paymentReceiptResult.Response.Reference);
            Assert.NotNull(paymentReceiptResult.Response.PostUrl);
        }
Exemplo n.º 4
0
        public void UpdatePreAuth()
        {
            var httpClient = Substitute.For <IHttpClient>();
            var request    = new WebPaymentRequestModel
            {
                Amount      = 10,
                CardAddress = new WebPaymentCardAddress
                {
                    CardHolderName = "Test User",
                    Line1          = "Test Street",
                    Line2          = "Test Street",
                    Line3          = "Test Street",
                    Town           = "London",
                    PostCode       = "W31 4HS",
                    Country        = "England"
                },
                ClientIpAddress       = "127.0.0.1",
                CompanyName           = "Test",
                Currency              = "GBP",
                ExpiryDate            = DateTimeOffset.Now,
                JudoId                = "1254634",
                PartnerServiceFee     = 10,
                PaymentCancelUrl      = "http://test.com",
                PaymentSuccessUrl     = "http://test.com",
                Reference             = "42421",
                Status                = WebPaymentStatus.Open,
                TransactionType       = TransactionType.PAYMENT,
                YourConsumerReference = "4235325",

                Receipt = new PaymentReceiptModel
                {
                    ReceiptId      = 134567,
                    Type           = "Create",
                    JudoId         = 12456,
                    OriginalAmount = 20,
                    Amount         = 20,
                    NetAmount      = 20,
                    CardDetails    = new CardDetails
                    {
                        CardLastfour = "1345",
                        EndDate      = "1214",
                        CardToken    = "ASb345AE",
                        CardType     = CardType.VISA
                    },
                    Currency = "GBP",
                    Consumer = new Consumer
                    {
                        ConsumerToken         = "B245SEB",
                        YourConsumerReference = "Consumer1"
                    }
                }
            };
            var response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(@"{
                                                    amount : 10,
                                                    cardAddress : 
                                                    {
                                                        cardHolderName : 'Test User',
                                                        line1 : 'Test Street',
                                                        line2 : 'Test Street',
                                                        line3 : 'Test Street',
                                                        town : 'London',
                                                        postCode : 'W31 4HS',
                                                        country : 'England'
                                                    },
                                                    clientIpAddress : '128.0.0.1',
                                                    clientUserAgent : 'Chrome',
                                                    companyName : 'Test',
                                                    currency : 'GBP',
                                                    expiryDate : '2012-07-19T14:30:00+09:30',
                                                    judoId : '1254634',
		                                            partnerRecId : '243532',
		                                            partnerServiceFee : 10,
		                                            paymentCancelUrl : 'http://test.com',
		                                            paymentSuccessUrl : 'http://test.com',
		                                            reference : '1342423',
		                                            status : 'Open',
		                                            transactionType : 'SALE',
		                                            yourConsumerReference : '4235325',
		                                            yourPaymentReference : '42355',
		                                            receipt:
		                                            {
	                                                    receiptId : '134567',
	                                                    type : 'Create',
	                                                    judoId : '12456',
	                                                    originalAmount : 20,
	                                                    amount : 20,
	                                                    netAmount : 20,
	                                                    cardDetails :
	                                                        {
	                                                            cardLastfour : '1345',
	                                                            endDate : '1214',
	                                                            cardToken : 'ASb345AE',
	                                                            cardType : 'VISA'
	                                                        },
	                                                    currency : 'GBP',
	                                                    consumer : 
	                                                        {
	                                                            consumerToken : 'B245SEB',
	                                                            yourConsumerReference : 'Consumer1'
	                                                        }
		                                            },
                                                    response: 
                                                    {
		                                                 postUrl : 'http://test.com',
		                                                 reference : '1342423'   
                                                    }
                                                }")
            };

            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.WebPayments.PreAuths.Update(request).Result;

            Assert.NotNull(paymentReceiptResult);
            Assert.IsFalse(paymentReceiptResult.HasError);
            Assert.NotNull(paymentReceiptResult.Response);
            Assert.AreEqual("1342423", paymentReceiptResult.Response.Reference);
            Assert.AreEqual("1342423", paymentReceiptResult.Response.Response.Reference);
            Assert.NotNull(paymentReceiptResult.Response.Response.PostUrl);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Updates the webpayment payment.  Used in conjunction with 3D secure
 /// </summary>
 /// <param name="model">The updated information of webpayment payment</param>
 /// <returns>The webpayment payment updated</returns>
 public Task <IResult <WebPaymentRequestModel> > Update(WebPaymentRequestModel model)
 {
     return(Update(model, Transactiontype));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates the webpayment payment.
 /// </summary>
 /// <param name="model">The webpayment payment.</param>
 /// <returns>The information required to finalize the webpayment payment</returns>
 public Task <IResult <WebPaymentResponseModel> > Create(WebPaymentRequestModel model)
 {
     return(Create(model, Transactiontype));
 }
Exemplo n.º 7
0
        public void TransactionsGetByReceiptId()
        {
            // WebPaymentRequest - Do a web payment
            var judo = JudoPaymentsFactory.Create(Configuration.Token,
                                                  Configuration.Secret,
                                                  Configuration.Baseaddress);

            var request = new WebPaymentRequestModel
            {
                Amount      = 10,
                CardAddress = new WebPaymentCardAddress
                {
                    CardHolderName = "Test User",
                    Line1          = "Test Street",
                    Line2          = "Test Street",
                    Line3          = "Test Street",
                    Town           = "London",
                    PostCode       = "W31 4HS",
                    Country        = "England"
                },
                ClientIpAddress       = "127.0.0.1",
                CompanyName           = "Test",
                Currency              = "GBP",
                ExpiryDate            = DateTimeOffset.Now,
                JudoId                = Configuration.Judoid,
                PartnerServiceFee     = 10,
                PaymentCancelUrl      = "http://test.com",
                PaymentSuccessUrl     = "http://test.com",
                Reference             = "42421",
                Status                = WebPaymentStatus.Open,
                TransactionType       = TransactionType.PAYMENT,
                YourConsumerReference = "4235325",
                YourPaymentReference  = "42355"
            };

            var result = judo.WebPayments.Payments.Create(request).Result;

            var reference = result.Response.Reference;

            // Forms - Post a form with credentials to post url from the webpayment response passing form parameter Reference

            var httpClient  = new HttpClient();
            var formContent = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("Reference", reference)
            });

            var formRequest = CreateJudoApiRequest(result.Response.PostUrl, HttpMethod.Post, "3.2.0.0", Configuration.Token,
                                                   Configuration.Secret);

            formContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
            formRequest.Content             = formContent;

            var paymentPage = httpClient.SendAsync(formRequest).Result;

            var resultBody = paymentPage.Content.ReadAsStringAsync().Result;

            /* ok this next bit is a hack. I know on Iridium's ACS simulator the PaRes value is lurking in the HTML (It's a simulator after all!) */
            var doc = new HtmlDocument();

            doc.LoadHtml(resultBody);

            // Forms - Post a form with credentials and cookie and form following variables:
            // url= /v1/Pay variables: CardNumber, ExpiryDate, Cv2, form variable: __RequestVerificationToken

            var formField = doc.DocumentNode.SelectSingleNode("//input[@name='__RequestVerificationToken']");

            var requestVerificationToken = formField.GetAttributeValue("value", "");

            //            CardNumber = "4976000000003436",
            //CV2 = "452",
            //ExpiryDate = "12/15",

            formContent = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("__RequestVerificationToken", requestVerificationToken),
                new KeyValuePair <string, string>("CardNumber", "4976000000003436"),
                new KeyValuePair <string, string>("Cv2", "452"),
                new KeyValuePair <string, string>("ExpiryDate", "12/15"),
                new KeyValuePair <string, string>("Reference", reference)
            });

            formRequest = CreateJudoApiRequest("http://127.0.0.1/webpayments/v1/Pay", HttpMethod.Post, "3.2.0.0", Configuration.Token,
                                               Configuration.Secret);

            formContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
            formRequest.Content             = formContent;

            var resultPage = httpClient.SendAsync(formRequest).Result;

            resultBody = resultPage.Content.ReadAsStringAsync().Result;

            // Retrieve from the response the receipt id

            doc = new HtmlDocument();
            doc.LoadHtml(resultBody);

            formField = doc.DocumentNode.SelectSingleNode("//input[@name='ReceiptId']");

            var receiptId = formField.GetAttributeValue("value", "");

            var webRequest = judo.WebPayments.Transactions.GetByReceipt(receiptId).Result;

            Assert.NotNull(webRequest);
            Assert.IsFalse(webRequest.HasError);
            Assert.NotNull(webRequest.Response);
            Assert.NotNull(webRequest.Response.Reference);
            Assert.AreEqual(request.JudoId, webRequest.Response.JudoId);
        }