Exemplo n.º 1
0
        private FdCreditCardResp Force(Ticket ticket, decimal amount, out string requestStatus)
        {
            var             txType = ((ComboBoxItem)_view.FdTransactionType.SelectedItem).Tag.ToString();
            FdCreditCardReq fdReq  = new FdCreditCardReq(txType);

            fdReq.amount           = amount.ToString();
            fdReq.cardholder_name  = _view.CardName.Text;
            fdReq.cc_expiry        = _view.CardExpire.Text;
            fdReq.cc_number        = _view.CardNumber.Password;
            fdReq.gateway_id       = Settings.GatewayId;
            fdReq.password         = Settings.Password;
            fdReq.transaction_type = txType;
            fdReq.reference_no     = ticket.Id.ToString();

            FdCreditCardResp fdResp;
            var fdGwMgr = new FdGatewayManager(Settings.GatewayUri, FdGatewayManager.ApiVersion.V11);

            if (fdGwMgr.SendFdCreditCardRequest(fdReq, out fdResp, out requestStatus))
            {
                return(fdResp);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// SendFdCreditCardRequest
        /// </summary>
        /// <param name="req"></param>
        /// <param name="resp"></param>
        /// <param name="errorResp"></param>
        /// <returns></returns>
        public bool SendFdCreditCardRequest(FdCreditCardReq req, out FdCreditCardResp resp, out string errorResp)
        {
            errorResp = "";
            resp = null;
            string result = String.Empty;
            string jsonPayload = String.Empty;

            try
            {
                jsonPayload = JsonConvert.SerializeObject(req);
            }
            catch (Exception ex)
            {
                errorResp = ex.Message;
                return false;
            }

            if (Version != ApiVersion.V11)
            {
                throw new Exception(String.Format("Version {0} is not supported", Version));
            }
            if (SendRequestV11(jsonPayload, out result))
            {
                try
                {
                    resp = JsonConvert.DeserializeObject<FdCreditCardResp>(result);
                    return true;
                }
                catch (Exception exception)
                {
                    try
                    {
                        JObject jobj = JObject.Parse(result);

                        resp = new FdCreditCardResp();
                        resp.transaction_approved = (jobj["transaction_approved"].ToString() == "1") ? true : false;
                        resp.bank_message = jobj["bank_message"].ToString();
                        resp.exact_resp_code = jobj["exact_resp_code"].ToString();
                        return true;
                    }
                    catch (Exception ex)
                    {
                        errorResp = exception.Message;
                        return false;
                    }

                }
            }
            else
            {
                errorResp = result;
                return false;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// SendFdCreditCardRequest
        /// </summary>
        /// <param name="req"></param>
        /// <param name="resp"></param>
        /// <param name="errorResp"></param>
        /// <returns></returns>
        public bool SendFdCreditCardRequest(FdCreditCardReq req, out FdCreditCardResp resp, out string errorResp)
        {
            errorResp = "";
            resp      = null;
            string result      = String.Empty;
            string jsonPayload = String.Empty;

            try
            {
                jsonPayload = JsonConvert.SerializeObject(req);
            }
            catch (Exception ex)
            {
                errorResp = ex.Message;
                return(false);
            }

            if (Version != ApiVersion.V11)
            {
                throw new Exception(String.Format("Version {0} is not supported", Version));
            }
            if (SendRequestV11(jsonPayload, out result))
            {
                try
                {
                    resp = JsonConvert.DeserializeObject <FdCreditCardResp>(result);
                    return(true);
                }
                catch (Exception exception)
                {
                    try
                    {
                        JObject jobj = JObject.Parse(result);

                        resp = new FdCreditCardResp();
                        resp.transaction_approved = (jobj["transaction_approved"].ToString() == "1") ? true : false;
                        resp.bank_message         = jobj["bank_message"].ToString();
                        resp.exact_resp_code      = jobj["exact_resp_code"].ToString();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        errorResp = exception.Message;
                        return(false);
                    }
                }
            }
            else
            {
                errorResp = result;
                return(false);
            }
        }
Exemplo n.º 4
0
        private FdCreditCardResp Force(Ticket ticket, decimal amount, out string requestStatus)
        {
            var txType = ((ComboBoxItem)_view.FdTransactionType.SelectedItem).Tag.ToString();
            FdCreditCardReq fdReq = new FdCreditCardReq(txType);
            fdReq.amount = amount.ToString();
            fdReq.cardholder_name = _view.CardName.Text;
            fdReq.cc_expiry = _view.CardExpire.Text;
            fdReq.cc_number = _view.CardNumber.Password;
            fdReq.gateway_id = Settings.GatewayId;
            fdReq.password = Settings.Password;
            fdReq.transaction_type = txType;
            fdReq.reference_no = ticket.Id.ToString();

            FdCreditCardResp fdResp;
            var fdGwMgr = new FdGatewayManager(Settings.GatewayUri, FdGatewayManager.ApiVersion.V11);
            if (fdGwMgr.SendFdCreditCardRequest(fdReq, out fdResp, out requestStatus))
            {

                return fdResp;
            }
            else
            {
                return null;
            }
        }