Ejemplo n.º 1
0
        public virtual async Task <IActionResult> GetControlNumber([FromBody] IntentOfPay intent)
        {
            if (!ModelState.IsValid)
            {
                var error = ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage;

                if (intent != null)
                {
                    var resp = await _imisModules.GetPaymentModule().GetPaymentLogic().SaveIntent(intent, error.GetErrorNumber(), error.GetErrorMessage());

                    return(BadRequest(new ErrorResponseV2()
                    {
                        error_occured = true, error_message = error
                    }));
                }
                else
                {
                    return(BadRequest(new ErrorResponseV2()
                    {
                        error_occured = true, error_message = "10-Uknown type of payment"
                    }));
                }
            }

            try
            {
                var response = await _imisModules.GetPaymentModule().GetPaymentLogic().SaveIntent(intent);

                AssignedControlNumber data = (AssignedControlNumber)response.Data;

                return(Ok(new GetControlNumberResp()
                {
                    error_occured = response.ErrorOccured, error_message = response.MessageValue, internal_identifier = data.internal_identifier, control_number = data.control_number
                }));
            }
            catch (Exception e)
            {
                return(BadRequest(new ErrorResponseV2()
                {
                    error_occured = true, error_message = e.Message
                }));
            }
        }
Ejemplo n.º 2
0
        public async Task <DataMessage> SaveIntent(IntentOfPay intent, int?errorNumber = 0, string errorMessage = null)
        {
            var payment        = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            var cnHandler      = new SingleControlNumberHandler(_configuration, _hostingEnvironment);
            var return_message = cnHandler.GetControlNumber(intent);
            var data           = new AssignedControlNumber();

            if (return_message.ErrorOccured == true)
            {
                data = (AssignedControlNumber)return_message.Data;
            }

            if (return_message.ErrorOccured == false)
            {
                var objstring = return_message.Data.ToString();
                data = (JsonConvert.DeserializeObject <List <AssignedControlNumber> >(objstring)).FirstOrDefault();
                return_message.Data = data;
            }


            if (data.control_number != null & data.internal_identifier != null && intent.SmsRequired & !return_message.ErrorOccured)
            {
                payment.GetPaymentInfo(Convert.ToInt32(data.internal_identifier));
                ControlNumberAssignedSms(payment);
            }
            else
            {
                payment.ControlNum      = null;
                payment.InsureeProducts = new List <InsureeProduct>();
                payment.InsureeProducts.Add(
                    new InsureeProduct {
                    InsureeNumber = intent.policies.FirstOrDefault().insurance_number,
                    ProductCode   = intent.policies.FirstOrDefault().insurance_product_code
                }
                    );
                payment.PhoneNumber = intent.phone_number;
                ControlNumberNotassignedSms(payment, return_message.MessageValue);
            }

            return(return_message);
        }