public async Task <IActionResult> InsertWalletHistory([FromBody] WalletHistoryDto walletHistoryDto) { try { if (walletHistoryDto.isExistingCard.Value) { Checkout.Payments.PaymentResponse paymentResponse = walletHistoryDto.PaymentResponseSource; walletHistoryDto.Transaction = paymentResponse.Payment.Id; walletHistoryDto.TransactionDescription = ((Checkout.Payments.CardSourceResponse)paymentResponse.Payment.Source).Scheme + "****" + ((Checkout.Payments.CardSourceResponse)paymentResponse.Payment.Source).Last4; } else { if (walletHistoryDto.SourceId != null) { Checkout.Payments.GetPaymentResponse payment = walletHistoryDto.SourceId; if (walletHistoryDto.SaveCard) { var customerID = await _UsersService.getCustomerID(walletHistoryDto.CustomerID); List <GetPaymentCardsDto> paymentCards = _paymentCardsService.GetPaymentByCustomer(walletHistoryDto.CustomerID); var itemExists = paymentCards.Find(p => p.CardType == ((Checkout.Payments.CardSourceResponse)payment.Source).Scheme && p.Expyear == Convert.ToInt32(((Checkout.Payments.CardSourceResponse)payment.Source).ExpiryYear) && p.Expmonth == Convert.ToInt32(((Checkout.Payments.CardSourceResponse)payment.Source).ExpiryMonth) && p.last4digits == Convert.ToInt32(((Checkout.Payments.CardSourceResponse)payment.Source).Last4) ); if (itemExists == null) { await _paymentCardsService.InsertPaymentCards( new PaymentCardsDto { CardCustomerId = ((Checkout.Payments.CustomerResponse)payment.Customer).Id, CardSourceId = ((Checkout.Payments.CardSourceResponse)payment.Source).Id, CardType = ((Checkout.Payments.CardSourceResponse)payment.Source).Scheme, CustomerId = customerID, Expyear = Convert.ToInt32(((Checkout.Payments.CardSourceResponse)payment.Source).ExpiryYear), Expmonth = Convert.ToInt32(((Checkout.Payments.CardSourceResponse)payment.Source).ExpiryMonth), last4digits = Convert.ToInt32(((Checkout.Payments.CardSourceResponse)payment.Source).Last4) } ); } } walletHistoryDto.Transaction = payment.Id; walletHistoryDto.TransactionDescription = ((Checkout.Payments.CardSourceResponse)payment.Source).Scheme + "****" + ((Checkout.Payments.CardSourceResponse)payment.Source).Last4; } } await _WalletHistoryService.InsertWalletHistory(walletHistoryDto); } catch (Exception err) { return(BadRequest(new GenericResultDto <string> { Result = err.Message })); } return(Ok(new GenericResultDto <string> { Result = "Insert successfully" })); }
private async Task ShouldGetPaymentDetails() { var paymentResponse = new GetPaymentResponse(); _apiClient.Setup(apiClient => apiClient.Get <GetPaymentResponse>(PaymentsPath + "/payment_id", _authorization, CancellationToken.None)) .ReturnsAsync(() => paymentResponse); IPaymentsClient paymentsClient = new PaymentsClient(_apiClient.Object, _configuration.Object); var response = await paymentsClient.GetPaymentDetails("payment_id", CancellationToken.None); response.ShouldNotBeNull(); response.ShouldBeSameAs(paymentResponse); }
private static bool TotalCapturedIs5(GetPaymentResponse obj) { return(obj.Balances.TotalCaptured == 5); }
private static bool TotalVoidedIs10(GetPaymentResponse obj) { return(obj.Balances.TotalVoided == 10); }
private static bool PaymentIsCaptured(GetPaymentResponse obj) { return(obj.Status == PaymentStatus.Captured); }