示例#1
0
    private responseNMI ExecuteTransaction(string strUrl, stcTransactionDetailSet sT)
    {
        {
            var            iR          = new responseNMI();
            string         strResponse = "";
            HttpWebRequest hRequest    = HttpWebRequest.Create(strUrl) as HttpWebRequest;
            hRequest.Method      = "POST";
            hRequest.ContentType = "application/x-www-form-urlencoded";
            OpenAuthentication(sT, ref hRequest);

            using (HttpWebResponse hResponse = (HttpWebResponse)hRequest.GetResponse())
            {
                if (hResponse.StatusCode == HttpStatusCode.OK)
                {
                    var oReader = new StreamReader(hResponse.GetResponseStream());
                    strResponse = oReader.ReadToEnd();
                }
            }

            if (!string.IsNullOrEmpty(strResponse))
            {
                var    dict = HttpUtility.ParseQueryString(strResponse);
                string json = JsonConvert.SerializeObject(dict.Cast <string>().ToDictionary(k => k, v => dict[v]));
                iR = JsonConvert.DeserializeObject <responseNMI>(json);

                iR.response_message      = GetResponseText(iR.response);
                iR.avsresponse_message   = GetAVSResponse(iR.avsresponse);
                iR.cvvresponse_message   = GetAVSResponse(iR.cvvresponse);
                iR.response_code_message = GetResponseCodeMessage(iR.response_code);
            }

            return(iR);
        }
    }
示例#2
0
    public stcTransactionDetailSet ProcessTransaction(stcTransactionDetailSet sT)
    {
        try
        {
            var iR = new responseNMI();

            switch (sT.transaction.paymentStatusId)
            {
            case enTransactionStatusList.Authorized:
            {
                iR = AuthCaptureTransaction(sT);
                break;
            }

            case enTransactionStatusList.AuthCaptured:
            {
                iR = AuthCaptureTransaction(sT);
                break;
            }

            case enTransactionStatusList.Captured:
            {
                iR = CaptureTransaction(sT);
                break;
            }

            case enTransactionStatusList.Voided:
            {
                iR = VoidTransaction(sT);
                break;
            }

            case enTransactionStatusList.Refunded:
            {
                iR = RefundTransaction(sT);
                break;
            }
            }
        }
        catch (Exception ex)
        {
            string message = ex.Message.ToString();
            // This is the ONLY Point where it is indicated that RESPONSE has ERROR

            sT.transaction.response.responseErrorCode = new stcErrorCodeSet()
            {
                errorCode = enErrorCodeList.Transaction_Process_General_Error
            };
        }

        return(sT);
    }