Пример #1
0
        public static string BalanceRequest(string cardNum, string processingServiceName, string terminalId, string requestId)
        {
            string clientType    = "ProcessingTest";
            string clientVersion = "1.0.0.0";
            string employeeId    = "Pinger";
            string hardwareID    = AdditionalFunc.GetMACAddress();
            int    isOffline     = 0;
            string shiftId       = string.Empty;
            string type          = "BALANCE";
            string ver           = "0.1";

            /*string authRes = AuthRequest(processingServiceName, terminalId, "80626056");
             * if (String.Equals(authRes, Variables.errorResponce))
             *  return Variables.errorResponce;*/

            /*string requestId = NextRRN(RRN(cardNum, processingServiceName, terminalId));
             *
             * if (String.Equals(requestId, Variables.errorResponce))
             *  return Variables.errorResponce;*/

            string sign = AdditionalFunc.StringToMD5("cardNum=" + cardNum + ";clientType=" + clientType + ";clientVersion=" + clientVersion + ";employeeId=" + employeeId
                                                     + ";isOffline=" + isOffline + ";requestId=" + requestId + ";shiftId=" + shiftId + ";terminalId=" + terminalId + ";type=" + type + ";ver=" + ver + ";" + hardwareID);

            string data = "{\"getBalanceRequest\":{\"request\":{\"ver\":\"" + ver + "\",\"clientType\":\"" + clientType + "\",\"clientVersion\":\"" + clientVersion + "\",\"type\":\"" + type + "\"," +
                          "\"requestId\":\"" + requestId + "\",\"terminalId\":\"" + terminalId + "\",\"requestDate\":\"" + String.Format("{0:yyyy-MM-ddTHH:mm:ss}", DateTime.Now) + "Z\"," +
                          "\"employeeId\":\"" + employeeId + "\",\"cardNum\":\"" + cardNum + "\",\"isOffline\":" + isOffline + ",\"shiftId\":\"" + shiftId + "\",\"sign\":\"" + sign + "\"}}}";

            string req_result = HTTPRequests.HTTPRequest(Variables.post, processingServiceName + "bpsApi/bpos/balance", data);

            if (String.Equals(req_result, Variables.requestStateError))
            {
                return(Variables.requestStateError);
            }
            else
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                BPSResp resp            = js.Deserialize <BPSResp>(req_result);

                if (String.Equals(resp.getBalanceResponse.response.requestState, Variables.requestStateError) & !String.Equals(resp.getBalanceResponse.response.requestStateCode, Variables.incorrectRequestId))
                {
                    return(Variables.requestStateError);
                }
                else
                {
                    return(resp.getBalanceResponse.response.requestStateCode);
                }
            }
        }
Пример #2
0
        public static string AuthRequest(string processingServiceName, string terminalId, string terminalPassword)
        {
            string cardNum       = string.Empty;
            string clientType    = "ProcessingTest";
            string clientVersion = "1.0.0.0";
            string employeeId    = "Pinger";
            string hardwareID    = AdditionalFunc.GetMACAddress();
            int    isOffline     = 0;
            string requestId     = "0000000000000000";
            string shiftId       = string.Empty;
            string type          = "AUTH";
            string ver           = "0.1";
            string sign          = AdditionalFunc.StringToMD5("cardNum=" + cardNum + ";clientType=" + clientType + ";clientVersion=" + clientVersion + ";employeeId=" + employeeId + ";hardwareID=" + hardwareID
                                                              + ";isOffline=" + isOffline + ";requestId=" + requestId + ";shiftId=" + shiftId + ";terminalId=" + terminalId + ";terminalPassword="******";type=" + type + ";ver=" + ver + ";" + hardwareID);

            string data = "{\"authRequest\":{\"request\":{\"ver\":\"" + ver + "\",\"clientType\":\"" + clientType + "\",\"clientVersion\":\"" + clientVersion + "\",\"type\":\"" + type + "\"," +
                          "\"requestId\":\"" + requestId + "\",\"terminalId\":\"" + terminalId + "\",\"requestDate\":\"" + String.Format("{0:yyyy-MM-ddTHH:mm:ss}", DateTime.Now) + "Z\",\"employeeId\":\"" + employeeId + "\","
                          + "\"cardNum\":\"\",\"isOffline\":" + isOffline + ",\"shiftId\":\"" + shiftId + "\",\"sign\":\"" + sign + "\"},\"auth\":{\"terminalPassword\":\"" + terminalPassword + "\",\"hardwareID\":\""
                          + hardwareID + "\"}}}";

            string req_result = HTTPRequests.HTTPRequest(Variables.post, processingServiceName + "bpsApi/bpos/auth", data);

            if (String.Equals(req_result, Variables.requestStateError))
            {
                return(Variables.requestStateError);
            }
            else
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                BPSResp resp            = js.Deserialize <BPSResp>(req_result);

                if (String.Equals(resp.authResponse.response.requestState, Variables.requestStateError))
                {
                    return(Variables.requestStateError);
                }
                else
                {
                    return(resp.authResponse.response.requestState);
                }
            }
        }