public IActionResult CreditCard(string id) { if (string.IsNullOrWhiteSpace(id)) { return(View()); } var temporaryTransaction = _paymentService.GetTemporaryTransaction(id); if (temporaryTransaction == null) { _logger.LogError($"Can not find payment request by Id = {id}"); Response.StatusCode = 404; return(View("NotFound")); } CardPaymentModel model = new CardPaymentModel(); model.Id = id; model.Amount = temporaryTransaction.Amount.Value; model.Currency = temporaryTransaction.Amount.Currency; model.Logo = temporaryTransaction.MerchantProfile.Logo; //"/merchantlogos/acropaqlogo.png"; model.Description = temporaryTransaction.Description; model.Merchant = temporaryTransaction.MerchantProfile.Name; model.IsTestMode = temporaryTransaction.MerchantProfile.Mode == APIMode.Test; return(View(model)); }
public void ValidateCardPaymentWithoutErrors() { var payment = new CardPaymentModel { Amount = 2.0m, CardAddress = new CardAddressModel { Line1 = "Test Street", Line2 = "Test Street", Line3 = "Test Street", PostCode = "W40 9AU", Town = "Town" }, CardNumber = "348417606737499", ConsumerLocation = new ConsumerLocationModel { Latitude = 40m, Longitude = 14m }, CV2 = "420", EmailAddress = "*****@*****.**", ExpiryDate = "120615", JudoId = "12356", MobileNumber = "07745352515", YourConsumerReference = "User10", YourPaymentReference = "Pay1234" }; var validator = new CardPaymentValidator(); var result = validator.Validate(payment); Assert.IsNotNull(result); Assert.IsTrue(result.IsValid); }
public void ExtraHeadersAreSent(CardPaymentModel payment, 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); payment.HttpHeaders.Add(EXTRA_HEADER_NAME, "some random value"); IResult <ITransactionResult> paymentReceiptResult = judo.RegisterCards.Create(payment).Result; Assert.NotNull(paymentReceiptResult); Assert.IsFalse(paymentReceiptResult.HasError); Assert.NotNull(paymentReceiptResult.Response); Assert.That(paymentReceiptResult.Response.ReceiptId, Is.EqualTo(134567)); }
public void ADeclinedValidationOnCardPreAuth() { var judo = JudoPaymentsFactory.Create(Configuration.Token, Configuration.Secret, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = Configuration.Judoid, YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4221690000004963", CV2 = "125", ExpiryDate = "12/15", CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" } }; var response = judo.PreAuths.Validate(paymentWithCard).Result; Assert.IsNotNull(response); Assert.IsFalse(response.HasError); Assert.AreEqual("Your good to go!", response.Response.ErrorMessage); Assert.AreEqual(JudoApiError.Validation_Passed, response.Response.ErrorType); }
public void ASimplePreAuth() { var judo = JudoPaymentsFactory.Create(Configuration.Token, Configuration.Secret, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = Configuration.Judoid, YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976000000003436", CV2 = "452", ExpiryDate = "12/15", CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" } }; var response = judo.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); }
public void ValidateMakeCardPaymentTestFailed() { Options options = new Options(); var unitOfWorkMock = new Mock <IUnitOfWork>(); List <CardPayment> cardPaymentList = new List <CardPayment>(); var cardpaymentModel = new CardPayment(); cardpaymentModel.Cvvnumber = "123"; cardpaymentModel.CardHolderName = "test"; cardpaymentModel.Amount = 60; var cardPaymentModelList = new List <CardPaymentModel>(); var cardpayment = new CardPaymentModel(); //cardpayment.CardNumber = "123456777889"; cardpayment.Cvvnumber = "123"; cardpayment.CardHolderName = "test"; cardpayment.Amount = 20; cardPaymentList.Add(cardpaymentModel); unitOfWorkMock.Setup(m => m.CardPaymentRepository.Query(null, null, 1, 0, null)).Returns(cardPaymentList); _paymentService = new PaymentService(unitOfWorkMock.Object, options); var paymentController = new PaymentController(_paymentService); try { var result = paymentController.MakeCardPayment(null); } catch (BusinessException ex) { Assert.Equal("CardPayment details is null", ex.Message); } }
public void ValidateCardPaymentWithErrorOnPaymentValidation() { var payment = new CardPaymentModel { Amount = 2.0m, CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" }, CardNumber = "348417606737499", ConsumerLocation = new ConsumerLocationModel { Latitude = 40m, Longitude = 14m }, CV2 = "420", EmailAddress = "*****@*****.**", ExpiryDate = "120615", MobileNumber = "07745352515", YourConsumerReference = "User10", YourPaymentReference = "Pay1234" }; var validator = new CardPaymentValidator(); validator.ShouldHaveValidationErrorFor(model => model.JudoId, payment); }
public void MakeCardPaymentTestIsSucessFully() { //Arrange Options options = new Options(); var unitOfWorkMock = new Mock <IUnitOfWork>(); List <CardPayment> cardPaymentList = new List <CardPayment>(); var cardpaymentModel = new CardPayment(); cardpaymentModel.CardNumber = "123456777889"; cardpaymentModel.Cvvnumber = "123"; cardpaymentModel.CardHolderName = "test"; cardpaymentModel.Amount = 60; var cardPaymentModelList = new List <CardPaymentModel>(); var cardpayment = new CardPaymentModel(); cardpayment.CardNumber = "123456777889"; cardpayment.Cvvnumber = "123"; cardpayment.CardHolderName = "test"; cardpayment.Amount = 60; cardPaymentList.Add(cardpaymentModel); unitOfWorkMock.Setup(m => m.CardPaymentRepository.Query(null, null, 1, 0, null)).Returns(cardPaymentList); _paymentService = new PaymentService(unitOfWorkMock.Object, options); //Act var paymentController = new PaymentController(_paymentService); var result = paymentController.MakeCardPayment(cardpayment); //Assert Assert.True(result.Status); }
/// <summary> /// The validates card payment model /// </summary> /// <param name="cardPaymentModel"></param> public static void ValidateCardPayment(CardPaymentModel cardPaymentModel) { //Validates card payment model if (!(cardPaymentModel != null)) { throw new BusinessException(Constants.CardPaymentModel); } //Validate the Card number if (string.IsNullOrEmpty(cardPaymentModel.CardNumber)) { throw new BusinessException(Constants.CardNumber); } //Validate Cvv number if (string.IsNullOrEmpty(cardPaymentModel.Cvvnumber)) { throw new BusinessException(Constants.CvvNumber); } //Validater card holder name if (string.IsNullOrEmpty(cardPaymentModel.CardHolderName)) { throw new BusinessException(Constants.CardHolderName); } }
public async Task <IResult <ITransactionResult> > PreAuthoriseCard(PaymentViewModel authorisation, IClientService clientService) { JudoConfiguration.Instance.Validate(); CardPaymentModel payment = new CardPaymentModel { JudoId = (String.IsNullOrWhiteSpace(authorisation.JudoID) ? JudoConfiguration.Instance.JudoId : authorisation.JudoID), YourPaymentReference = authorisation.PaymentReference, YourConsumerReference = authorisation.ConsumerReference, Amount = authorisation.Amount, CardNumber = authorisation.Card.CardNumber, CV2 = authorisation.Card.CV2, ExpiryDate = authorisation.Card.ExpireDate, CardAddress = new CardAddressModel() { PostCode = authorisation.Card.PostCode, CountryCode = (int)authorisation.Card.CountryCode }, StartDate = authorisation.Card.StartDate, IssueNumber = authorisation.Card.IssueNumber, YourPaymentMetaData = authorisation.YourPaymentMetaData, ClientDetails = clientService.GetClientDetails(), UserAgent = clientService.GetSDKVersion(), Currency = authorisation.Currency }; Task <IResult <ITransactionResult> > task = _judoAPI.PreAuths.Create(payment); return(await task); }
/// <summary> /// This method complete card payment /// </summary> /// <param name="cardPaymentModel"></param> /// <param name="cardPayment"></param> /// <returns></returns> private PaymentStatus CompleteCardPament(CardPaymentModel cardPaymentModel, CardPayment cardPayment) { PaymentStatus paymentStatus = new PaymentStatus(); if (cardPayment != null) { if (cardPayment.Amount > cardPaymentModel.Amount) { cardPayment.Amount = (cardPayment.Amount - cardPaymentModel.Amount); this.cardPaymentRepository.Update(cardPayment); unitOfWork.Save(); paymentStatus.Status = true; } else { paymentStatus.Error = InsufficientFunds; } } else { paymentStatus.Error = CardErrorMessage; } return(paymentStatus); }
public void RegisterCardWithError(CardPaymentModel registerCard, string responseData, JudoApiError errorType) { 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); IResult <ITransactionResult> paymentReceiptResult = null; // ReSharper disable CanBeReplacedWithTryCastAndCheckForNull paymentReceiptResult = judo.RegisterCards.Create(registerCard).Result; // ReSharper restore CanBeReplacedWithTryCastAndCheckForNull Assert.NotNull(paymentReceiptResult); Assert.IsTrue(paymentReceiptResult.HasError); Assert.IsNull(paymentReceiptResult.Response); Assert.IsNotNull(paymentReceiptResult.Error); Assert.AreEqual((int)errorType, paymentReceiptResult.Error.Code); }
public void ValidateCardPaymentWithErrorOnSpecificCardPaymentInformation() { var payment = new CardPaymentModel(); var validator = new CardPaymentValidator(); validator.ShouldHaveValidationErrorFor(model => model.CardNumber, payment); }
public async Task <IResult <ITransactionResult> > HandlePKPayment(PKPayment payment, string customerRef, NSDecimalNumber amount, ApplePaymentType type, JudoFailureCallback failure) { try { CardPaymentModel paymentmodel = new CardPaymentModel { JudoId = JudoConfiguration.Instance.JudoId, ClientDetails = _clientService.GetClientDetails(), UserAgent = _clientService.GetSDKVersion() }; var test = payment.Token.PaymentData.ToString(NSStringEncoding.UTF8); JObject jo = JObject.Parse(test.ToString()); PKPaymentModel pkModel = new PKPaymentModel() { JudoId = JudoConfiguration.Instance.JudoId, YourPaymentReference = "paymentRef12343", YourConsumerReference = customerRef, Amount = amount.ToDecimal(), ClientDetails = _clientService.GetClientDetails(), UserAgent = _clientService.GetSDKVersion(), PkPayment = new PKPaymentInnerModel() { Token = new PKPaymentTokenModel() { PaymentData = jo, PaymentInstrumentName = payment.Token.PaymentInstrumentName, PaymentNetwork = payment.Token.PaymentNetwork } } }; Task <IResult <ITransactionResult> > task = null; if (type == ApplePaymentType.Payment) { task = _judoAPI.Payments.Create(pkModel); } else if (type == ApplePaymentType.PreAuth) { task = _judoAPI.PreAuths.Create(pkModel); } if (task == null) { var judoError = new JudoError() { Exception = new Exception("Judo server did not return response. Please contact customer support") }; failure(judoError); } return(await task); } catch (Exception e) { Console.WriteLine(e.InnerException.ToString()); var judoError = new JudoError() { Exception = e }; failure(judoError); return(null); } }
public void GetRefundsTransactions() { var judo = JudoPaymentsFactory.Create(Configuration.Token, Configuration.Secret, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = Configuration.Judoid, YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976000000003436", CV2 = "452", ExpiryDate = "12/15", CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" } }; var paymentResponse = judo.Payments.Create(paymentWithCard).Result; Assert.IsNotNull(paymentResponse); Assert.IsFalse(paymentResponse.HasError); Assert.AreEqual("Success", paymentResponse.Response.Result); var refund = new RefundModel { Amount = 25, ReceiptId = int.Parse(paymentResponse.Response.ReceiptId), YourPaymentReference = "578543" }; var response = judo.Refunds.Create(refund).Result; Assert.IsNotNull(response); Assert.IsFalse(response.HasError); Assert.AreEqual("Success", response.Response.Result); var paymentReceipt = response.Response as PaymentReceiptModel; Assert.IsNotNull(paymentReceipt); var transactions = judo.Consumers.GetRefunds(paymentReceipt.Consumer.ConsumerToken).Result; Assert.IsNotNull(transactions); Assert.IsFalse(transactions.HasError); Assert.IsNotEmpty(transactions.Response.Results); // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(Configuration.Judoid, transactions.Response.Results.FirstOrDefault().JudoId.ToString(CultureInfo.InvariantCulture)); // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(paymentReceipt.ReceiptId, transactions.Response.Results.FirstOrDefault().ReceiptId); }
public void AFailedSimplePreAuthAndValidateCollection() { var judo = JudoPaymentsFactory.Create(Configuration.Token, Configuration.Secret, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = Configuration.Judoid, YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976000000003436", CV2 = "452", ExpiryDate = "12/15", CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" } }; var response = judo.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 collection = new CollectionModel { Amount = 30, ReceiptId = int.Parse(response.Response.ReceiptId), YourPaymentReference = "578543" }; var validateResponse = judo.Collections.Validate(collection).Result; Assert.IsNotNull(validateResponse); Assert.IsTrue(validateResponse.HasError); Assert.AreEqual("Unable to process collection as total amount collected would exceed value of" + " original PreAuth transaction.", validateResponse.Error.ErrorMessage); Assert.AreEqual(JudoApiError.Payment_Failed, validateResponse.Error.ErrorType); }
public IActionResult PayWithCard(CardPaymentModel model) { var temporaryTransaction = _paymentService.GetTemporaryTransaction(model.Id); if (temporaryTransaction == null) { _logger.LogError($"Can not find payment request by Id = {model.Id}"); Response.StatusCode = 404; return(View("NotFound")); } //in live mode we get payment status from bank and set if (model.PaymentStatus == PaymentStatus.Paid) { Core.Models.Payment.CardTransaction cardTransaction = new Core.Models.Payment.CardTransaction() { Amount = temporaryTransaction.Amount, CardNumber = model.CardNumber, CCV = model.CCV, ExpMonth = Convert.ToInt32(model.ExpMonth), ExpYear = Convert.ToInt32(model.ExpYear), InsertDate = DateTime.Now, TransactionDate = DateTime.Now, TransctionCode = temporaryTransaction.TransctionCode, //PaymentStatus = model.PaymentStatus, MerchantProfile = temporaryTransaction.MerchantProfile, BillingAddress = model.BillingAddress, HolderName = model.CardName, TemporaryTransaction = temporaryTransaction }; _paymentService.AddTransaction(cardTransaction); } else { _paymentService.UpdateTemporaryTransactionPaymentStatus(temporaryTransaction.Id, model.PaymentStatus); } Dictionary <string, object> objData = new Dictionary <string, object>(); objData.Add("Id", temporaryTransaction.TransctionCode); objData.Add("PaymentStatus", model.PaymentStatus); return(this.RedirectAndPost(temporaryTransaction.RedirectUrl, objData)); }
/// <summary> /// This method represents Make card payment /// </summary> /// <param name="cardPaymentModel"></param> /// <returns></returns> public PaymentStatus MakeCardPayment(CardPaymentModel cardPaymentModel) { PaymentValidation.ValidateCardPayment(cardPaymentModel); var unEncryptedCardNumber = cardPaymentModel.CardNumber; var suffixCardNumber = unEncryptedCardNumber.Substring(unEncryptedCardNumber.Length - 4, 4); var preFixCard = unEncryptedCardNumber.Substring(0, unEncryptedCardNumber.Length - 4); var encryptedCardNumber = AesOperation.EncryptString(this._appSettings.Key, suffixCardNumber); var encryptedCvvNumber = AesOperation.EncryptString(this._appSettings.Key, cardPaymentModel.Cvvnumber); string errorMessage; var cardDetailsList = this.cardPaymentRepository.Query(); var cardPayment = (from cardDetail in cardDetailsList where cardDetail.CardNumber == (encryptedCardNumber + suffixCardNumber) && cardDetail.Cvvnumber == encryptedCvvNumber && cardDetail.ExpiryDate == cardPaymentModel.ExpiryDate select cardDetail).FirstOrDefault(); return(CompleteCardPament(cardPaymentModel, cardPayment)); }
public async Task ExplicitUserAgentSendsExplicitValue() { var httpClient = Substitute.For <IHttpClient>(); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent((@"{ results : [{ 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.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var responseTask = new TaskCompletionSource <HttpResponseMessage>(); responseTask.SetResult(response); httpClient.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(responseTask.Task); var connection = new Connection(httpClient, DotNetLoggerFactory.Create, "http://test.com"); var paymentModel = new CardPaymentModel { UserAgent = "SomeText" }; await connection.Send(HttpMethod.Post, "http://foo", null, null, paymentModel); await httpClient.Received().SendAsync(Arg.Is <HttpRequestMessage>(r => r.Headers.UserAgent.First().Product.Name == paymentModel.UserAgent)); }
/// <summary> /// Сохранить плату картой /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sbCardPay_Click(object sender, EventArgs e) { if (!cardValidationProvider.Validate()) { return; } var cardPayment = new CardPaymentModel() { Guid = Guid.NewGuid(), Amount = GetValue(teCardAmount.EditValue), CardNumber = teCardNumber.Text, Manual = ceCardManual.Checked, PaymentDate = DateTime.Now, RNN = teCardNumber.Text, }; AddBindingPays(cardPayment, cardPayment.Manual); }
public void ARefundValidate() { var judo = JudoPaymentsFactory.Create(Configuration.Token, Configuration.Secret, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = Configuration.Judoid, YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976000000003436", CV2 = "452", ExpiryDate = "12/15", CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" } }; var response = judo.Payments.Create(paymentWithCard).Result; Assert.IsNotNull(response); Assert.IsFalse(response.HasError); Assert.AreEqual("Success", response.Response.Result); var refund = new RefundModel { Amount = 25, ReceiptId = int.Parse(response.Response.ReceiptId), YourPaymentReference = "578543" }; var validateResponse = judo.Refunds.Validate(refund).Result; Assert.IsNotNull(validateResponse); Assert.IsFalse(validateResponse.HasError); Assert.AreEqual("Your good to go!", validateResponse.Response.ErrorMessage); Assert.AreEqual(JudoApiError.Validation_Passed, validateResponse.Response.ErrorType); }
public void PaymentWithThreedSecure() { var judo = JudoPaymentsFactory.Create(Configuration.ElevatedPrivilegesSecret, Configuration.ElevatedPrivilegesToken, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = "100016", YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976350000006891", CardAddress = new CardAddressModel { Line1 = "242 Acklam Road", Line2 = "Westbourne Park", Line3 = "", Town = "London", PostCode = "W105JJ" }, CV2 = "341", ExpiryDate = "12/15", MobileNumber = "07123456789", EmailAddress = "*****@*****.**", UserAgent = "Mozilla/5.0,(Windows NT 6.1; WOW64),AppleWebKit/537.36,(KHTML, like Gecko),Chrome/33.0.1750.154,Safari/537.36", AcceptHeaders = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", DeviceCategory = "Mobile" }; var response = judo.Payments.Create(paymentWithCard).Result; Assert.IsNotNull(response); Assert.IsFalse(response.HasError); var receipt = response.Response as PaymentRequiresThreeDSecureModel; Assert.IsNotNull(receipt); Assert.AreEqual("Requires 3D Secure", receipt.Result); Assert.IsNotEmpty(receipt.Md); }
/// <summary> /// The Bind card payment model /// </summary> /// <param name="cardDetailsList">The card payment list</param> /// <returns></returns> private List <CardPaymentModel> BindCardPaymentModel(List <CardPayment> cardDetailsList) { List <CardPaymentModel> paymentModelList = new List <CardPaymentModel>(); foreach (var cardDetails in cardDetailsList) { var cardPayment = new CardPaymentModel { Amount = cardDetails.Amount, CardHolderName = cardDetails.CardHolderName, CardNumber = cardDetails.CardNumber, Cvvnumber = cardDetails.Cvvnumber, DateModified = DateTime.Now, ExpiryDate = cardDetails.ExpiryDate, Id = cardDetails.Id }; paymentModelList.Add(cardPayment); } return(paymentModelList); }
public void GetPaymentTransactions() { var judo = JudoPaymentsFactory.Create(Configuration.Token, Configuration.Secret, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = Configuration.Judoid, YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976000000003436", CV2 = "452", ExpiryDate = "12/15", CardAddress = new CardAddressModel { Line1 = "Test Street", PostCode = "W40 9AU", Town = "Town" } }; var response = judo.Payments.Create(paymentWithCard).Result; Assert.IsNotNull(response); Assert.IsFalse(response.HasError); Assert.AreEqual("Success", response.Response.Result); var transaction = judo.Transactions.Get(TransactionType.PAYMENT).Result; Assert.IsNotNull(transaction); Assert.IsFalse(transaction.HasError); Assert.IsNotEmpty(transaction.Response.Results); Assert.AreEqual("Success", transaction.Response.Results.First().Result); Assert.AreEqual(response.Response.ReceiptId, transaction.Response.Results.First().ReceiptId); }
/// <summary> /// This method to add card details /// </summary> /// <param name="cardPaymentModel">The cardPaymentModel</param> /// <returns>returns cardPaymentModel</returns> public bool AddCardPaymentDetails(CardPaymentModel cardPaymentModel) { var unEncryptedCardNumber = cardPaymentModel.CardNumber; var suffixCardNumber = unEncryptedCardNumber.Substring(unEncryptedCardNumber.Length - 4, 4); var preFixCard = unEncryptedCardNumber.Substring(0, unEncryptedCardNumber.Length - 4); var encryptedCardNumber = AesOperation.EncryptString(this._appSettings.Key, suffixCardNumber); var encryptedCvvNumber = AesOperation.EncryptString(this._appSettings.Key, cardPaymentModel.Cvvnumber); CardPayment cardPayment = new CardPayment { Amount = cardPaymentModel.Amount, CardHolderName = cardPaymentModel.CardHolderName, CardNumber = encryptedCardNumber + suffixCardNumber, Cvvnumber = encryptedCvvNumber, DateModified = DateTime.Now, ExpiryDate = cardPaymentModel.ExpiryDate, Id = cardPaymentModel.Id == null?Guid.NewGuid().ToString() : cardPaymentModel.Id }; //Insert card details this.CardPaymentRepository.Insert(cardPayment); unitOfWork.Save(); return(true); }
public void FullPaymentWithThreedSecure() { var judo = JudoPaymentsFactory.Create(Configuration.ElevatedPrivilegesSecret, Configuration.ElevatedPrivilegesToken, Configuration.Baseaddress); var paymentWithCard = new CardPaymentModel { JudoId = "100016", YourPaymentReference = "578543", YourConsumerReference = "432438862", Amount = 25, CardNumber = "4976350000006891", CardAddress = new CardAddressModel { Line1 = "242 Acklam Road", Line2 = "Westbourne Park", Line3 = "", Town = "London", PostCode = "W105JJ" }, CV2 = "341", ExpiryDate = "12/15", MobileNumber = "07123456789", EmailAddress = "*****@*****.**", UserAgent = "Mozilla/5.0,(Windows NT 6.1; WOW64),AppleWebKit/537.36,(KHTML, like Gecko),Chrome/33.0.1750.154,Safari/537.36", AcceptHeaders = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", DeviceCategory = "Mobile" }; var response = judo.Payments.Create(paymentWithCard).Result; Assert.IsNotNull(response); Assert.IsFalse(response.HasError); var receipt = response.Response as PaymentRequiresThreeDSecureModel; Assert.IsNotNull(receipt); Assert.AreEqual("Requires 3D Secure", receipt.Result); Assert.IsNotEmpty(receipt.Md); var httpClient = new HttpClient(); var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("MD", receipt.Md), new KeyValuePair <string, string>("PaReq", receipt.PaReq), new KeyValuePair <string, string>("TermUrl", "https://pay.judopay.com/") }); var taskSendMDandPaReqToAcsServer = httpClient.PostAsync(receipt.AcsUrl, formContent).ContinueWith(authResponse => { var resultBody = authResponse.Result.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); var formField = doc.DocumentNode.SelectSingleNode("//input[@name='PaRes']"); var paResValue = formField.GetAttributeValue("value", ""); Assert.That(paResValue, Is.Not.Empty); var threeDResult = judo.ThreeDs.Complete3DSecure(receipt.ReceiptId, new ThreeDResultModel { PaRes = paResValue }).Result; Assert.IsNotNull(threeDResult); Assert.IsFalse(threeDResult.HasError); Assert.AreEqual("Success", threeDResult.Response.Result); }); taskSendMDandPaReqToAcsServer.Wait(); }
public Task <IResult <ITransactionResult> > Create(CardPaymentModel registerCard) { var validationError = Validate <CardPaymentModel, ITransactionResult>(RegisterCardValidator, registerCard); return(validationError ?? PostInternal <CardPaymentModel, ITransactionResult>(REGISTER_CARD_ADDRESS, registerCard)); }
public Task <IResult <ITransactionResult> > Create(CardPaymentModel cardPreAuth) { var validationError = Validate <CardPaymentModel, ITransactionResult>(CardPaymentValidator, cardPreAuth); return(validationError ?? PostInternal <CardPaymentModel, ITransactionResult>(CREATE_PREAUTH_ADDRESS, cardPreAuth)); }
public Task <IResult <JudoApiErrorModel> > Validate(CardPaymentModel cardPreAuth) { var validationError = Validate <CardPaymentModel, JudoApiErrorModel>(CardPaymentValidator, cardPreAuth); return(validationError ?? PostInternal <CardPaymentModel, JudoApiErrorModel>(_validatePreAuthAddress, cardPreAuth)); }
public bool AddCardDetails([FromBody] CardPaymentModel cardPaymentModel) { return(cardPaymentWeb.AddCardPaymentDetails(cardPaymentModel)); }