Exemple #1
0
 public HttpResponseMessage ConfirmOrderFromManufacturer(PaymentConfirmDto paymentConfirmDto)
 {
     return(Request.ExecuteProtectedAndWrapResult <PaymentConfirmDto, SellModel>(
                dto => TradeService.ConfirmManufacturerTradePromise(dto),
                ModelState, paymentConfirmDto
                ));
 }
Exemple #2
0
        public async Task <PendingPayment> HandlePaymentCallback(PaymentConfirmDto dto)
        {
            SignedPaymentInfo signed = new SignedPaymentInfo(dto.data, dto.signature);
            string            id     = LiqPay.GetOrderId(signed);

            if (!PendingPayments.ContainsKey(id))
            {
                throw new NotFoundException("payment with such id");
            }

            if (!LiqPay.IsSucceed(signed))
            {
                throw new ValidationException();
            }

            PendingPayment payment = PendingPayments[id];

            if (!LiqPay.IsPaymentAuthorized(signed, payment.PaymentInfo))
            {
                throw new UnauthorizedAccessException();
            }

            foreach (OrderEntity order in payment.PaidOrders)
            {
                await OrderRepo.MarkPaid(order.Id);
            }

            return(payment);
        }
        public SellModel ConfirmManufacturerTradePromise(PaymentConfirmDto dto)
        {
            return(ProtectedExecute <PaymentConfirmDto, SellModel>(paymentConfirmDto =>
            {
                PaymentInfo payment = Mapper.Map <PaymentConfirmDto, PaymentInfo>(paymentConfirmDto);
                string orderId = PaymentService.GetOrderId(payment);

                if (!PendingOrders.ContainsKey(orderId))
                {
                    throw new NotFoundException("pending order");
                }

                bool autorizedPayment = PaymentService.IsPaymentAuthorized(payment, PendingOrders[orderId].PaymentInfo);
                if (!autorizedPayment)
                {
                    throw new UnauthorizedException();
                }

                Sell sell = PendingOrders[orderId];

                if (!PaymentService.IsSucceed(payment))
                {
                    RemoveReservation(orderId);
                    throw new NotFoundException("order");
                }

                sell.SellModel.SellDate = DateTime.Now;

                UpdateSellPositionsSellDates(sell.SellModel);
                AttachAccountExtension(sell.SellModel);

                SellModel createdSell = ManufacturerSellRepo.Create(sell.SellModel);
                CreateOwnerships(createdSell);

                RemoveReservation(orderId);

                return createdSell;
            }, dto));
        }
Exemple #4
0
 public async Task <HttpResponseMessage> HandlePaymentCallback(PaymentConfirmDto dto)
 {
     return(await Execute(async() => await PayService.HandlePaymentCallback(dto)));
 }