Example #1
0
        protected override async Task Handle(SaveCardCommand command)
        {
            var user = _userRepository.GetByAltId(command.UserAltId);

            if (user != null)
            {
                var _cardDetail = new UserCardDetail
                {
                    UserId      = user.Id,
                    AltId       = Guid.NewGuid(),
                    NameOnCard  = command.NameOnCard,
                    CardNumber  = command.CardNumber,
                    ExpiryMonth = command.ExpiryMonth,
                    ExpiryYear  = command.ExpiryYear,
                    CardTypeId  = command.CardTypeId,
                    ModifiedBy  = command.ModifiedBy,
                    IsEnabled   = true
                };

                _userCardDetailRepository.Save(_cardDetail);
            }
        }
Example #2
0
        public async Task <ASIBookingResponse> saveASIData(ASIBooking aSIBooking)
        {
            var            transactionData    = _transactionRepository.Get(aSIBooking.TransactionId);
            var            transactionDetails = _transactionDetailRepository.GetByTransactionId(aSIBooking.TransactionId);
            List <Visitor> visitors           = new List <Visitor>();
            List <ASIHash> aSIHashes          = new List <ASIHash>();
            RootObject     rootObject         = new RootObject();

            foreach (FIL.Contracts.DataModels.TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var clientETAData = aSIBooking.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId && (TicketType)currentTransactionDetail.TicketTypeId == s.TicketType).FirstOrDefault();
                if (clientETAData != null)
                {
                    foreach (FIL.Contracts.Commands.Transaction.GuestUserDetail currentGuestDetail in clientETAData.GuestDetails)
                    {
                        _saveGuestUserProvider.SaveGuestUsers(currentGuestDetail, currentTransactionDetail);
                    }

                    _aSITransactionDetailTimeSlotIdMappingRepository.Save(new FIL.Contracts.DataModels.ASI.ASITransactionDetailTimeSlotIdMapping
                    {
                        EventTimeSlotMappingId = (long)clientETAData.VisitTimeId,
                        TransactionDetailId    = currentTransactionDetail.Id,
                        IsEnabled  = true,
                        CreatedUtc = DateTime.UtcNow,
                        UpdatedUtc = DateTime.UtcNow
                    });

                    _transactionDeliveryDetailRepository.Save(new TransactionDeliveryDetail
                    {
                        TransactionDetailId = currentTransactionDetail.Id,
                        DeliveryTypeId      = DeliveryTypes.PrintAtHome,
                        PickupBy            = 1,
                        SecondaryName       = "Zoonga",
                        SecondaryContact    = "Zoonga",
                        SecondaryEmail      = transactionData.EmailId,
                        PickUpAddress       = "Zoonga"
                    });
                }
            }
            // This is separate loop for API request payload..... I don't think we need to manage data from above loop... Better to keep it separate
            foreach (FIL.Contracts.DataModels.TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var guestData          = _guestDetailRepository.GetByTransactionDetailId(currentTransactionDetail.Id);
                var asiTicketAttribute = aSIBooking.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId).FirstOrDefault();
                if (guestData.Any())
                {
                    var currentETA        = _eventTicketAttributeRepository.Get(currentTransactionDetail.EventTicketAttributeId);
                    var currentETD        = _eventTicketDetailRepository.Get(currentETA.EventTicketDetailId);
                    var currentTc         = _ticketCategoryRepository.Get((int)currentETD.TicketCategoryId);
                    var currentED         = _eventDetailRepository.Get(currentETD.EventDetailId);
                    var currentE          = _eventRepository.Get(currentED.EventId);
                    var asiETableMapping  = _aSIMonumentEventTableMappingRepository.GetByEventId(currentE.Id);
                    var asiMonument       = _aSIMonumentRepository.Get(asiETableMapping.ASIMonumentId);
                    var asiMonumentDetail = _aSIMonumentDetailRepository.GetByNameAndMonumentId(currentED.Name, asiMonument.Id);
                    var asiTimeSlot       = _aSITransactionDetailTimeSlotIdMappingRepository.GetByTransactionDetailId(currentTransactionDetail.Id);
                    var eventTimeSlot     = _eventTimeSlotMappingRepository.Get(asiTimeSlot.EventTimeSlotMappingId);
                    //api.key |[monument.code | optional | date | age | country | amount] |[monument.code | optional | date | age | country | amount] | api.salt
                    foreach (FIL.Contracts.DataModels.GuestDetail currentGuestDetail in guestData)
                    {
                        Visitor     visitor     = new Visitor();
                        ASIHash     aSIHash     = new ASIHash();
                        Identity    indentity   = new Identity();
                        Monument    monument    = new Monument();
                        Nationality nationality = new Nationality();
                        Timeslot    timeslot    = new Timeslot();
                        visitor.Identity          = indentity;
                        visitor.Monument          = monument;
                        visitor.Monument.Timeslot = timeslot;
                        visitor.Nationality       = nationality;
                        var custerDocType = _customerDocumentTypeRepository.Get(currentGuestDetail.CustomerDocumentTypeId);
                        visitor.Age                  = Convert.ToInt32(currentGuestDetail.Age);
                        visitor.VisitorId            = currentGuestDetail.Id.ToString();
                        visitor.Amount               = currentTransactionDetail.PricePerTicket;
                        visitor.Gender               = currentGuestDetail.GenderId.ToString();
                        visitor.Name                 = currentGuestDetail.FirstName + " " + currentGuestDetail.LastName;
                        visitor.Date                 = ((System.DateTime)currentTransactionDetail.VisitDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
                        visitor.Identity.Type        = custerDocType.DocumentType;
                        visitor.Identity.No          = currentGuestDetail.DocumentNumber;
                        visitor.Monument.Code        = "TAJ";
                        visitor.Monument.Optional    = asiMonumentDetail.IsOptional;
                        visitor.Monument.Main        = true;
                        visitor.Monument.Timeslot.Id = eventTimeSlot.TimeSlotId;
                        visitor.Nationality.Group    = currentTc.Name;
                        visitor.Nationality.Country  = asiTicketAttribute == null ? "India" : asiTicketAttribute.ASIUserSelectedCountry;
                        visitors.Add(visitor);

                        aSIHash.Code           = asiMonument.Code;
                        aSIHash.IsOptional     = asiMonumentDetail.IsOptional;
                        aSIHash.Date           = (System.DateTime)currentTransactionDetail.VisitDate;
                        aSIHash.Nationality    = currentTc.Name;
                        aSIHash.Age            = Convert.ToInt32(currentGuestDetail.Age);
                        aSIHash.Amount         = currentTransactionDetail.PricePerTicket;
                        aSIHash.IdentityType   = "Passport";
                        aSIHash.IdentityNumber = "SADFG";
                        aSIHash.VisitorId      = currentGuestDetail.Id.ToString();
                        aSIHashes.Add(aSIHash);
                    }
                }
            }

            var ticketHash = "";

            foreach (FIL.Contracts.Models.ASI.ASIHash currentHash in aSIHashes)
            {
                TimeZoneInfo INDIAN_ZONE;
                try
                {
                    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                }
                catch (Exception e)
                {
                    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("Asia/Kolkata");
                }
                DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(currentHash.Date, INDIAN_ZONE);
                var      time       = indianTime.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
                ticketHash = ticketHash + "[" + currentHash.Code + "|" + (!currentHash.IsOptional).ToString().ToLower() + "|" + currentHash.IsOptional.ToString().ToLower() + "|" + indianTime.ToString("yyyy-MM-dd") + "|" + currentHash.Age + "|" + currentHash.Nationality + "|" + currentHash.Amount.ToString("0.00") + "]" + "|";
                //ticketHash = ticketHash + "[" + "TAJ" + "|" + time + "|" + currentHash.IdentityType + "|" + currentHash.IdentityNumber + "|" + currentHash.Age + "|" + currentHash.Nationality + "|" + currentHash.Amount.ToString("0.00") + "|" + currentHash.VisitorId + "]" + "|";
            }
            var bookingHashRequestData = _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APIKey) + "|" + ticketHash + _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APISalt);
            var bookingHash            = GenerateSHA512Hash(bookingHashRequestData);

            rootObject.TransactionId = aSIBooking.TransactionId.ToString();
            rootObject.Hash          = bookingHash.ToLower();
            rootObject.Visitors      = visitors;
            rootObject.Email         = transactionData.EmailId == "*****@*****.**" ? transactionData.PhoneNumber : transactionData.EmailId;
            UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(string.Empty, aSIBooking.UserId);

            if (userCardDetail == null)
            {
                UserCardDetail obj = new UserCardDetail
                {
                    UserId      = aSIBooking.UserId,
                    AltId       = new Guid(),
                    NameOnCard  = string.Empty,
                    CardNumber  = string.Empty,
                    ExpiryMonth = 12,
                    ExpiryYear  = 2020,
                    CardTypeId  = CardType.None
                };
                userCardDetail = _userCardDetailRepository.Save(obj);
            }

            _transactionPaymentDetailRepository.Save(new TransactionPaymentDetail // Create transaction payment request before calling booking POST API request...
            {
                TransactionId    = aSIBooking.TransactionId,
                PaymentOptionId  = PaymentOptions.None,
                PaymentGatewayId = PaymentGateway.Payu,
                UserCardDetailId = userCardDetail.Id,
                RequestType      = "Charge Posting",
                Amount           = transactionData.NetTicketAmount.ToString(),
                PayConfNumber    = "",
                PaymentDetail    = "{\"Request\":" + Newtonsoft.Json.JsonConvert.SerializeObject(rootObject) + "{\"hashparameter\":" + bookingHashRequestData + "}}",
            });
            var baseAddress = _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.IntegrationRoot).ToString() + "" + _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APIKey).ToString();

            return(new ASIBookingResponse
            {
                RootObject = rootObject,
                ReturnUrl = baseAddress
            });
        }
Example #3
0
        protected override async Task <ICommandResult> Handle(PaymentCommand query)
        {
            var  transaction = _transactionRepository.Get(query.TransactionId);
            var  currency    = _currencyTypeRepository.Get(transaction.CurrencyId);
            User user        = _userRepository.GetByEmail(transaction.EmailId);

            UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(query.PaymentCard.CardNumber, user.Id);

            if (userCardDetail == null)
            {
                UserCardDetail obj = new UserCardDetail
                {
                    UserId      = user.Id,
                    AltId       = new Guid(),
                    NameOnCard  = query.PaymentCard.NameOnCard ?? string.Empty,
                    CardNumber  = query.PaymentCard.CardNumber ?? string.Empty,
                    ExpiryMonth = query.PaymentCard.ExpiryMonth,
                    ExpiryYear  = query.PaymentCard.ExpiryYear,
                    CardTypeId  = query.PaymentCard.CardType
                };
                userCardDetail = _userCardDetailRepository.Save(obj);
            }

            try
            {
                if (query.BillingAddress != null)
                {
                    if (query.BillingAddress.Zipcode == null)
                    {
                        query.BillingAddress.Zipcode = "110016";
                    }

                    var zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString());
                    if (zipcode == null)
                    {
                        var city    = _cityRepository.GetByName(query.BillingAddress.City);
                        var zipCode = new Zipcode
                        {
                            AltId      = Guid.NewGuid(),
                            Postalcode = query.BillingAddress.Zipcode.ToString(),
                            CityId     = city != null ? city.Id : 0,
                            IsEnabled  = true
                        };

                        _zipcodeRepository.Save(zipCode);

                        zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString());
                    }
                    if (user != null && zipcode != null)
                    {
                        var addressDetail = new UserAddressDetail
                        {
                            UserId        = user.Id,
                            AltId         = Guid.NewGuid(),
                            FirstName     = user.FirstName,
                            LastName      = user.LastName,
                            PhoneCode     = user.PhoneCode,
                            PhoneNumber   = user.PhoneNumber,
                            AddressLine1  = query.BillingAddress.Address,
                            Zipcode       = zipcode.Id,
                            AddressTypeId = AddressTypes.Billing,
                            IsEnabled     = true
                        };

                        _userAddressDetailRepository.Save(addressDetail);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
            }

            if (query.PaymentGateway != null)
            {
                List <FIL.Contracts.DataModels.TransactionDetail> transactionDetails = _transactionDetailRepository.GetByTransactionId(transaction.Id).ToList();
                if (transactionDetails.Any())
                {
                    List <FIL.Contracts.DataModels.TransactionSeatDetail> transactionSeatDetails = _transactionSeatDetailRepository.GetByTransactionDetailIds(transactionDetails.Select(s => s.Id)).ToList();
                    if (transactionSeatDetails != null)
                    {
                        var matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByMatchSeatTicketDetailIds(transactionSeatDetails.Select(s => s.MatchSeatTicketDetailId)).ToList();

                        if (matchSeatTicketDetail != null && matchSeatTicketDetail.Any())
                        {
                            return(new PaymentCommandResult
                            {
                                TransactionAltId = transaction.AltId,
                                PaymentResponse = new PaymentResponse
                                {
                                    Success = false,
                                    PaymentGatewayError = PaymentGatewayError.Unknown
                                }
                            });
                        }
                    }
                }
            }

            if (query.PaymentGateway == PaymentGateway.Stripe)
            {
                bool isIntentConfirm = false;
                if (query.PaymentCard.NameOnCard != null)
                {
                    isIntentConfirm = query.PaymentCard.NameOnCard.Equals("intent", StringComparison.InvariantCultureIgnoreCase);
                }
                var paymentResponse = await _stripeCharger.Charge(new StripeCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    Token            = query.Token,
                    ChannelId        = query.ChannelId,
                    IsIntentConfirm  = isIntentConfirm
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentResponse = paymentResponse
                });
            }

            if (query.PaymentGateway != null && query.PaymentGateway == PaymentGateway.NabTransact)
            {
                var paymentHtmlPostResponse = await _nabTransactCharger.Charge(new NabTransactCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    },
                    BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress
                    {
                        FirstName    = user.FirstName,
                        LastName     = user.LastName,
                        PhoneCode    = user.PhoneCode,
                        PhoneNumber  = user.PhoneNumber,
                        Email        = user.Email,
                        AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga",
                        Zipcode      = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "3032",
                        City         = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi",
                        State        = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi",
                        Country      = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India"
                    },
                    PaymentOption = PaymentOptions.CreditCard,
                    User          = new FIL.Contracts.Models.User
                    {
                        Email = user.Email
                    },
                    //IPAddress = ipDetail.IPAddress
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentHtmlPostResponse = paymentHtmlPostResponse
                });
            }

            if (PaymentOptions.CreditCard == query.PaymentOption || PaymentOptions.DebitCard == query.PaymentOption)
            {
                IHdfcEnrollmentResponse hdfcEnrollmentResponse = _hdfcChargerResolver.HdfcEnrollmentVerification(new HdfcCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    }
                });

                if (hdfcEnrollmentResponse.PaymentGatewayError == PaymentGatewayError.None)
                {
                    if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "ENROLLED")
                    {
                        var paymentHtmlPostResponse = await _hdfcPaymentHtmlPostCharger.Charge(hdfcEnrollmentResponse.HdfcEnrolledCharge);

                        return(new PaymentCommandResult
                        {
                            TransactionAltId = transaction.AltId,
                            PaymentHtmlPostResponse = paymentHtmlPostResponse
                        });
                    }

                    if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "NOT ENROLLED")
                    {
                        var paymentResponse = await _hdfcCharger.Charge(new HdfcCharge
                        {
                            TransactionId    = transaction.Id,
                            Currency         = currency.Code,
                            Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                            UserCardDetailId = userCardDetail.Id,
                            PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                            {
                                CardNumber  = query.PaymentCard.CardNumber,
                                NameOnCard  = query.PaymentCard.NameOnCard,
                                Cvv         = query.PaymentCard.Cvv,
                                ExpiryMonth = query.PaymentCard.ExpiryMonth,
                                ExpiryYear  = query.PaymentCard.ExpiryYear,
                                CardType    = query.PaymentCard.CardType
                            }
                        });

                        return(new PaymentCommandResult
                        {
                            TransactionAltId = transaction.AltId,
                            PaymentResponse = paymentResponse
                        });
                    }
                }

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentResponse = new PaymentResponse
                    {
                        Success = false,
                        PaymentGatewayError = hdfcEnrollmentResponse.PaymentGatewayError
                    }
                });
            }

            if (PaymentOptions.NetBanking == query.PaymentOption || PaymentOptions.CashCard == query.PaymentOption)
            {
                var paymentHtmlPostResponse = await _ccavenuePaymentHtmlPostCharger.Charge(new CcavenueCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    },
                    PaymentOption  = (PaymentOptions)query.PaymentOption,
                    BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress
                    {
                        FirstName   = !string.IsNullOrWhiteSpace(transaction.FirstName) ? transaction.FirstName : "Zoonga",
                        LastName    = !string.IsNullOrWhiteSpace(transaction.LastName) ? transaction.LastName : "Zoonga",
                        PhoneCode   = !string.IsNullOrWhiteSpace(transaction.PhoneCode) ? transaction.PhoneCode : "91",
                        PhoneNumber = !string.IsNullOrWhiteSpace(transaction.PhoneNumber) ? transaction.PhoneNumber : "9899704772",
                        Email       = !string.IsNullOrWhiteSpace(transaction.EmailId) ? transaction.EmailId : "*****@*****.**",
                        //FirstName = "Gaurav",
                        //LastName = "Bhardwaj",
                        //PhoneCode = "91",
                        //PhoneNumber = "9899704772",
                        //Email = "*****@*****.**",
                        AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga",
                        Zipcode      = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "110016",
                        City         = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi",
                        State        = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi",
                        Country      = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India"
                    },
                    BankAltId = query.BankAltId,
                    CardAltId = query.CardAltId,
                    ChannelId = query.ChannelId,
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentHtmlPostResponse = paymentHtmlPostResponse
                });
            }

            return(new PaymentCommandResult
            {
                TransactionAltId = transaction.AltId,
                PaymentResponse = new PaymentResponse
                {
                    Success = false,
                    PaymentGatewayError = PaymentGatewayError.Unknown
                }
            });
        }