Ejemplo n.º 1
0
        public async Task <IActionResult> PostProjectDonation([FromQuery] LiqPayCheckoutInfoViewModel info, [FromForm] LiqPayCheckoutViewModel checkoutViewModel)
        {
            var mapper = new MapperConfiguration(mapOpts =>
                                                 mapOpts.CreateMap <LiqPayCheckoutViewModel, LiqPayCheckoutDto>()
                                                 .ForMember(dto => dto.ProjectId, opts => opts.MapFrom(vm => info.ProjectId))
                                                 .ForMember(dto => dto.SocietyId, opts => opts.MapFrom(vm => info.SocietyId))
                                                 .ForMember(dto => dto.DonatorId, opts => opts.MapFrom(vm => info.DonatorId))
                                                 ).CreateMapper();

            var liqPayDto = mapper.Map <LiqPayCheckoutDto>(checkoutViewModel);

            await _donationService.AddDonation(liqPayDto);

            return(Ok());
        }
Ejemplo n.º 2
0
        public IActionResult AddDonation(AddDonationRequest donation)
        {
            var validationResult = _validation.Validate(donation.Amount);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.ErrorList));
            }
            var id = _donationService.AddDonation(new Data.Donation()
            {
                Amount   = donation.Amount,
                Fullname = donation.Fullname,
                Postcode = donation.Postcode
            });

            return(Ok(new AddDonationResponse()
            {
                Id = id,
                GiftAidAmount = _calculator.CalculateGiftAid(donation.Amount)
            }));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Post(string donationId, int?projectId, [FromForm] string data, [FromForm] string signature)
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new ArgumentException($"{nameof(data)} can not be null");
            }
            if (string.IsNullOrEmpty(signature))
            {
                throw new ArgumentException($"{nameof(signature)} can not be null");
            }

            string mySignature = LiqPayHelper.GetLiqPaySignature(data);

            if (mySignature != signature)
            {
                throw new Exception($"Error, while checking LiqPay response signature, the {nameof(signature)} was not authenticated ");
            }

            await _donationService.AddDonation(projectId, donationId, data, signature);

            return(Ok());
        }