コード例 #1
0
        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"
            }));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private static bool TotalCapturedIs5(GetPaymentResponse obj)
 {
     return(obj.Balances.TotalCaptured == 5);
 }
コード例 #4
0
 private static bool TotalVoidedIs10(GetPaymentResponse obj)
 {
     return(obj.Balances.TotalVoided == 10);
 }
コード例 #5
0
 private static bool PaymentIsCaptured(GetPaymentResponse obj)
 {
     return(obj.Status == PaymentStatus.Captured);
 }