Beispiel #1
0
        /// <summary>
        ///  Telkom Payment
        /// </summary>

        // POST: api/Telkom
        public IHttpActionResult Post([FromBody] TelkomModels.TelkomPaymentRequest request)
        {
            if (request is null)
            {
                return(BadRequest());
            }

            TelkomModels.TelkomPaymentResponse result = new TelkomModels.TelkomPaymentResponse();
            TelkomHelper     telkomHelper             = new TelkomHelper();
            TelkomValidation telkomValidation         = new TelkomValidation();

            string IP = InstitutionCredentials.IP();

            var context           = new ValidationContext(Request, serviceProvider: null, items: null);
            var validationResults = new List <ValidationResult>();
            var authHeader        = Request.Headers.Authorization;

            request.institutionCode = InstitutionCredentials.InstitutionCode(authHeader);
            request.institutionKey  = InstitutionCredentials.InstitutionKey(authHeader);
            request.totalAmount     = (request.totalAmount is null ? "" : request.totalAmount);
            request.billingNumber   = (request.billingNumber is null ? "" : request.billingNumber);
            request.billingCode     = (request.billingCode is null ? "" : request.billingCode);
            request.reference       = (request.reference is null ? "" : request.reference);

            var isValid = Validator.TryValidateObject(Request, context, validationResults);

            if (!isValid)
            {
                foreach (var validationResult in validationResults)
                {
                    result.responseCode         = "01";
                    result.responseDescription += validationResult.ErrorMessage;
                }

                return(BadRequest());
            }

            string rc = telkomValidation.ValidatePaymentTelkom(ref request);

            if (rc.Equals("0005"))
            {
                result = telkomHelper.PaymentTelkom(ref request, IP);
            }
            else
            {
                result.responseCode        = rc;
                result.responseDescription = ResponseCodeModels.GetResponseDescription(rc);
            }

            return(Ok(result));
        }
Beispiel #2
0
        public IHttpActionResult Get(string cardNumber)
        {
            CreditCardModels.CreditCardInquiryRequest request  = new CreditCardModels.CreditCardInquiryRequest();
            CreditCardModels.CreditCardInquiryRespone response = new CreditCardModels.CreditCardInquiryRespone();

            request.cardNumber = cardNumber;

            if (cardNumber == null || cardNumber == "")
            {
                return(BadRequest());
            }


            var    context           = new ValidationContext(Request, serviceProvider: null, items: null);
            var    validationResults = new List <ValidationResult>();
            var    authHeader        = Request.Headers.Authorization;
            string featureCode       = "";

            request.instiutionCode = InstitutionCredentials.InstitutionCode(authHeader);
            request.instiutionKey  = InstitutionCredentials.InstitutionKey(authHeader);

            var isValid = Validator.TryValidateObject(Request, context, validationResults);

            if (!isValid)
            {
                foreach (var validationResult in validationResults)
                {
                    response.responseCode         = "01";
                    response.responseDescription += validationResult.ErrorMessage;
                }
                return(Ok(response));
            }

            featureCode = ConstantModels.FeatureCode_CC;

            string rc = CreditCardValidation.ValidateInputInquiryCC(ref request, featureCode);//telkomHelper.ValidateInputInquiryTelkom(ref request, IP);

            if (rc.Equals("0005"))
            {
                response = CreditCardHelper.InquiryCC(ref request, featureCode); //accountOnline.inquiryAccountOnline(ref request, IP);
            }
            else
            {
                response.responseCode        = rc;
                response.responseDescription = ResponseCodeModels.GetResponseDescription(response.responseCode);
            }

            return(Ok(response));
        }
Beispiel #3
0
        /// <summary>
        ///  Telkom Inquriy
        /// </summary>

        //GET: api/Telkom
        public TelkomModels.TelkomInquiryResponse Get(string billingNumber)
        {
            TelkomModels.TelkomInquiryResponse result  = new TelkomModels.TelkomInquiryResponse();
            TelkomModels.TelkomInquiryRequest  request = new TelkomModels.TelkomInquiryRequest();
            TelkomHelper     telkomHelper     = new TelkomHelper();
            TelkomValidation telkomValidation = new TelkomValidation();

            var context           = new ValidationContext(Request, serviceProvider: null, items: null);
            var validationResults = new List <ValidationResult>();

            var authHeader = Request.Headers.Authorization;

            billingNumber = (billingNumber is null ? "" : billingNumber);

            request.institutionCode = InstitutionCredentials.InstitutionCode(authHeader);
            request.institutionKey  = InstitutionCredentials.InstitutionKey(authHeader);
            request.billingNumber   = billingNumber;

            string IP = InstitutionCredentials.IP();

            var isValid = Validator.TryValidateObject(Request, context, validationResults);

            if (!isValid)
            {
                foreach (var validationResult in validationResults)
                {
                    result.responseCode         = "01";
                    result.responseDescription += validationResult.ErrorMessage;
                }
                return(result);
            }

            string rc = telkomValidation.ValidateInputInquiryTelkom(ref request);

            if (rc.Equals("0005"))
            {
                result = telkomHelper.InquiryTelkom(ref request, IP);
            }
            else
            {
                result.responseCode        = rc;
                result.responseDescription = ResponseCodeModels.GetResponseDescription(rc);
            }

            return(result);
        }