protected virtual void SetBuyerDetails(BuyDataModel buyDataModel)
 {
     buyDataModel.EmailAddress = this.EmailAddress;
     buyDataModel.Firstname    = this.Firstname;
     buyDataModel.Lastname     = this.Lastname;
     buyDataModel.UserId       = this.UserId.Value;
 }
Beispiel #2
0
        public IActionResult OnceOffPayment(BuyDataModel buyDataModel)
        {
            SetBuyerDetails(buyDataModel);

            var response = paymentService.GetOnceOffPaymentUrl(buyDataModel, payFastSettings);

            return(Ok(response));
        }
 public PaymentDetail MapToPaymentDetail(BuyDataModel buyDataModel)
 {
     return(new PaymentDetail()
     {
         PaymentId = Guid.NewGuid(),
         Amount = buyDataModel.Amount,
         CurrencyId = buyDataModel.CurrencyId,
         CreateUserId = buyDataModel.UserId,
         IsPaymentSuccessful = false,
         CreateDate = DateTime.Now
     });
 }
 public TopUpForSubUserRequest MapToRequest(BuyDataModel buyDataModel)
 {
     return(new TopUpForSubUserRequest()
     {
         StreamNo = configuration.UCloudLinkBusinessPartnerStreamNo(),
         PartnerCode = configuration.UCloudLinkBusinessPartnerPartnerCode(),
         LoginCustomerId = cache.LoginCustomerId(),
         LangType = UCloudLinkConstants.DEFAULT_LANGUAGE,
         UserCode = buyDataModel.EmailAddress,
         OperateType = "1",
         Amount = buyDataModel.Amount
     });
 }
Beispiel #5
0
        /// <summary>
        /// Execute convert output.
        /// </summary>
        /// <param name="resultObject">DataModel</param>
        /// <returns>ResponseModel</returns>
        private BuyResponseModel Convert(BuyDataModel resultObject)
        {
            // Local variable declaration
            BuyResponseModel responseModel = null;

            // Variable initialize
            responseModel = new BuyResponseModel();

            // Set value
            responseModel.Cart = resultObject.Cart;

            // Return value
            return(responseModel);
        }
Beispiel #6
0
        /// <summary>
        /// Check processing
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>ResultModel</returns>
        private void Check(BuyDataModel inputObject)
        {
            // Local variable declaration
            ClientIndexDao clientIndexDao = null;

            // Variable initialize
            clientIndexDao = new ClientIndexDao();

            // Check valid
            if (!clientIndexDao.IsExistItem(inputObject.ItemCd))
            {
                throw new DataNotExistException(string.Format("Sản phẩm ({0})", inputObject.ItemCd));
            }
        }
Beispiel #7
0
        public OnceOffPaymentResponse GetOnceOffPaymentUrl(BuyDataModel buyDataModel, PayFastSettings payFastSettings)
        {
            var paymentDetail = paymentDetailMapper.MapToPaymentDetail(buyDataModel);

            unitOfWork.PaymentDetail.Insert(paymentDetail);
            unitOfWork.Save();

            var onceOffPaymentModel = onceOffPaymentMapper.MapToOnceOffPaymentModel(paymentDetail, buyDataModel, payFastSettings);

            return(new OnceOffPaymentResponse
            {
                Url = payFastService.CreateOncePaymentUrl(onceOffPaymentModel),
                PaymentId = paymentDetail.PaymentId
            });
        }
Beispiel #8
0
        /// <summary>
        /// Execute convert input.
        /// </summary>
        /// <param name="request">RequestModel</param>
        /// <returns>DataModel</returns>
        private BuyDataModel Convert(BuyRequestModel request)
        {
            // Local variable declaration
            BuyDataModel inputObject = null;

            // Variable initialize
            inputObject = new BuyDataModel();

            // Convert data input
            DataHelper.ConvertInput(request, inputObject);
            // Convert cart
            inputObject.Cart = DataHelper.ConvertInputCart(request.Cart);

            // Return value
            return(inputObject);
        }
Beispiel #9
0
        /// <summary>
        /// Check processing
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>ResultModel</returns>
        private void Check(BuyDataModel inputObject)
        {
            // Local variable declaration
            ClientItemDetailsDao clientItemDetailsDao = null;

            // Variable initialize
            clientItemDetailsDao = new ClientItemDetailsDao();

            // Check valid
            if (!clientItemDetailsDao.IsExistItem(inputObject.ItemCd))
                throw new DataNotExistException(string.Format("Sản phẩm ({0})", inputObject.ItemCd));
            if (DataCheckHelper.IsNull(inputObject.ItemQtty))
                throw new ExecuteException("E_MSG_00001", "Số lượng");
            if (inputObject.ItemQtty <= decimal.Zero)
                throw new ExecuteException("E_MSG_00011", "Số lượng");
        }
Beispiel #10
0
        public async Task <IActionResult> TopUpDevice(BuyDataModel buyDataModel)
        {
            SetBuyerDetails(buyDataModel);

            try
            {
                var deviceInformation = await deviceService.TopUpDevice(buyDataModel);

                return(Ok(deviceInformation));
            }
            catch (UCloudlinkInvalidResponseException ex)
            {
                paymentService.FailOnceOffPayment(buyDataModel.PaymentId);
                throw;
            }

            //return Ok();
        }
Beispiel #11
0
        /// <summary>
        /// Add item to cart
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private BuyDataModel AddInfo(BuyDataModel inputObject)
        {
            // Local variable declaration
            BuyDataModel getResult = null;
            CartCom cartCom = null;

            // Variable initialize
            getResult = new BuyDataModel();
            cartCom = new CartCom(inputObject.Cart);

            // Get data
            var cartItem = new CartItem();
            cartItem.ItemCd = inputObject.ItemCd;
            cartItem.Quantity = inputObject.ItemQtty.Value;
            cartCom.AddItem(cartItem);

            // Set value
            getResult.Cart = cartCom.Items;

            // Return value
            return getResult;
        }
Beispiel #12
0
        /// <summary>
        /// Check processing
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>ResultModel</returns>
        private void Check(BuyDataModel inputObject)
        {
            // Local variable declaration
            ClientItemDetailsDao clientItemDetailsDao = null;

            // Variable initialize
            clientItemDetailsDao = new ClientItemDetailsDao();

            // Check valid
            if (!clientItemDetailsDao.IsExistItem(inputObject.ItemCd))
            {
                throw new DataNotExistException(string.Format("Sản phẩm ({0})", inputObject.ItemCd));
            }
            if (DataCheckHelper.IsNull(inputObject.ItemQtty))
            {
                throw new ExecuteException("E_MSG_00001", "Số lượng");
            }
            if (inputObject.ItemQtty <= decimal.Zero)
            {
                throw new ExecuteException("E_MSG_00011", "Số lượng");
            }
        }
Beispiel #13
0
        /// <summary>
        /// Add item to cart
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private BuyDataModel AddInfo(BuyDataModel inputObject)
        {
            // Local variable declaration
            BuyDataModel getResult = null;
            CartCom      cartCom   = null;

            // Variable initialize
            getResult = new BuyDataModel();
            cartCom   = new CartCom(inputObject.Cart);

            // Get data
            var cartItem = new CartItem();

            cartItem.ItemCd   = inputObject.ItemCd;
            cartItem.Quantity = inputObject.ItemQtty.Value;
            cartCom.AddItem(cartItem);

            // Set value
            getResult.Cart = cartCom.Items;

            // Return value
            return(getResult);
        }
Beispiel #14
0
        /// <summary>
        /// Execute processing.
        /// </summary>
        /// <param name="request">RequestModel</param>
        /// <returns>ResponseModel</returns>
        private BuyResponseModel Execute(BuyRequestModel request)
        {
            // Local variable declaration
            BuyResponseModel responseModel = null;
            BuyDataModel     inputObject   = null;
            BuyDataModel     resultObject  = null;

            // Variable initialize
            responseModel = new BuyResponseModel();

            // Execute convert input.
            inputObject = Convert(request);

            // Check infomation
            Check(inputObject);

            // Get infomation
            resultObject = AddInfo(inputObject);

            // Execute convert ouput.
            responseModel = Convert(resultObject);

            return(responseModel);
        }
Beispiel #15
0
        /// <summary>
        /// Execute convert input.
        /// </summary>
        /// <param name="request">RequestModel</param>
        /// <returns>DataModel</returns>
        private BuyDataModel Convert(BuyRequestModel request)
        {
            // Local variable declaration
            BuyDataModel inputObject = null;

            // Variable initialize
            inputObject = new BuyDataModel();

            // Convert data input
            DataHelper.ConvertInput(request, inputObject);
            // Convert cart
            inputObject.Cart = DataHelper.ConvertInputCart(request.Cart);

            // Return value
            return inputObject;
        }
Beispiel #16
0
        public async Task <DeviceDetailModel> TopUpDevice(BuyDataModel buyDataModel)
        {
            var topUpForSubUserResponse = await subUserClient.TopUpSubUser(topUpForSubUserRequestMapper.MapToRequest(buyDataModel), cache.AccessToken());

            return(await GetDevice(buyDataModel.EmailAddress));
        }
 public OnceOffPaymentModel MapToOnceOffPaymentModel(PaymentDetail paymentDetail, BuyDataModel buyDataModel, PayFastSettings payFastSettings)
 {
     return(new OnceOffPaymentModel()
     {
         Merchant = payFastSettings,
         Buyer = new BuyerDetail
         {
             Firstname = buyDataModel.Firstname,
             Lastname = buyDataModel.Lastname,
             EmailAddress = buyDataModel.EmailAddress
         },
         Transaction = new TransactionDetail
         {
             PaymentId = paymentDetail.PaymentId.ToString(),
             Amount = decimal.ToDouble(buyDataModel.Amount),
             Item = "Airtime Top Up",
             Description = $"Airtime Top Up For {buyDataModel.Firstname} { buyDataModel.Lastname}",
             ConfirmationAddress = buyDataModel.EmailAddress,
             IsConfirmationEmailProvided = true
         }
     });
 }
Beispiel #18
0
        /// <summary>
        /// Execute convert output.
        /// </summary>
        /// <param name="resultObject">DataModel</param>
        /// <returns>ResponseModel</returns>
        private BuyResponseModel Convert(BuyDataModel resultObject)
        {
            // Local variable declaration
            BuyResponseModel responseModel = null;

            // Variable initialize
            responseModel = new BuyResponseModel();

            // Set value
            responseModel.Cart = resultObject.Cart;

            // Return value
            return responseModel;
        }