public void Should_ReturnSuccess_ForValidReference(EPaymentReferenceValidation referenceValidation, string reference) { // Arrange var paymentSubmission = new PaymentSubmission { Amount = 10.00m, Payment = new ProcessedPayment("paymentTitle", "paymentSlug", "paymentTeaser", "paymentDescription", "paymentDetailsText", "paymentReference", "fund", "glCodeCostCentreNumber", new List <Crumb>(), referenceValidation, "metaDescription", "returnUrl", "catalogueId", "accountReference", "paymentDescription", new List <Alert>()), Reference = reference }; var context = new ValidationContext(paymentSubmission); var results = new List <ValidationResult>(); // Act var result = Validator.TryValidateObject(paymentSubmission, context, results, true); // Assert result.Should().BeTrue(); }
public async Task GetSubmission() { player.Play("GetSubmission"); var payment1 = Payments.Payment1; var submission1 = Payments.Submission1; Payment created = await CreatePayment(payment1); PaymentSubmission gotten = await client.GetPaymentSubmissionAsync(created.Id); Assert.AreEqual(gotten, submission1); }
public async Task <IActionResult> Detail(string slug, string error, string serviceprocessed) { var response = await _repository.Get <Payment>(slug); if (!response.IsSuccessful()) { return(response); } var payment = response.Content as ProcessedPayment; var paymentSubmission = new PaymentSubmission { Payment = payment }; if (!string.IsNullOrEmpty(error) && !string.IsNullOrEmpty(serviceprocessed) && serviceprocessed.ToUpper().Equals("FALSE")) { ModelState.AddModelError(nameof(PaymentSubmission.Reference), error); } return(View(paymentSubmission)); }
public async Task <IActionResult> Detail(string slug, PaymentSubmission paymentSubmission) { var response = await _repository.Get <Payment>(slug); if (!response.IsSuccessful()) { return(response); } var payment = response.Content as ProcessedPayment; paymentSubmission.Payment = payment; TryValidateModel(paymentSubmission); if (!ModelState.IsValid) { return(View(paymentSubmission)); } var transactionReference = Guid.NewGuid().ToString(); var immediateBasketResponse = new CreateImmediateBasketRequest { CallingAppIdentifier = _configuration.GetValue <string>("CivicaPayCallingAppIdentifier"), CustomerID = _configuration.GetValue <string>("CivicaPayCustomerID"), ApiPassword = _configuration.GetValue <string>("CivicaPayApiPassword"), ReturnURL = !string.IsNullOrEmpty(payment.ReturnUrl) ? payment.ReturnUrl : $"{Request.Scheme}://{Request.Host}/payment/{slug}/result", NotifyURL = string.Empty, CallingAppTranReference = transactionReference, PaymentItems = new System.Collections.Generic.List <PaymentItem> { new PaymentItem { PaymentDetails = new PaymentDetail { CatalogueID = payment.CatalogueId, AccountReference = !string.IsNullOrEmpty(payment.AccountReference) ? payment.AccountReference : paymentSubmission.Reference, PaymentAmount = paymentSubmission.Amount.ToString(), PaymentNarrative = $"{payment.PaymentDescription} - {paymentSubmission.Reference}", CallingAppTranReference = transactionReference, Quantity = "1" }, AddressDetails = new AddressDetail() } } }; var civicaResponse = await _civicaPayGateway.CreateImmediateBasketAsync(immediateBasketResponse); if (civicaResponse.StatusCode == HttpStatusCode.BadRequest) { if (civicaResponse.ResponseContent.ResponseCode == "00001") { ModelState.AddModelError("Reference", $"Check {payment.ReferenceLabel.ToLower()} and try again."); return(View(paymentSubmission)); } return(View("Error", response)); } return(Redirect(_civicaPayGateway.GetPaymentUrl(civicaResponse.ResponseContent.BasketReference, civicaResponse.ResponseContent.BasketToken, transactionReference))); }
public async Task <PaymentSubmissionResponse> Pay(int paymentRequestId, PaymentSubmission submission) { return(await Client.Post <PaymentSubmission, PaymentSubmissionResponse>($"paymentrequest/{paymentRequestId}/pay", submission)); }