示例#1
0
        public KeyedSaleResponse KeyedAuthorizationTrans(string token, KeyedSaleRequest keyedSaleRequest)
        {
            /// <summary>
            /// Method for builiding Transaction with Json Request,call the actual transaction execution method and call for Deseralize Json
            /// and Return the object.
            /// Returns the KeyedSaleResponse Type
            /// </summary>

            // Header details are available at Authentication header page.
            string methodUrl = ApiEndPointConfiguration.UrlKeyedAuthorization;

            //converting request into JSON string
            var requestJSON = JsonSerializer.GetSeralizedString(keyedSaleRequest);

            //Optional - Display Json Request
            //System.Web.HttpContext.Current.Response.Write ("<br>" + "Json Request: " + requestJSON + "<br>");

            //call for actual request and response
            var payTraceResponse = new PayTraceResponse();
            var tempResponse     = payTraceResponse.ProcessTransaction(methodUrl, token, requestJSON);

            //Create and assign the deseralized object to appropriate response type
            var keyedSaleResponse = new KeyedSaleResponse();

            keyedSaleResponse = JsonSerializer.DeserializeResponse <KeyedSaleResponse>(tempResponse);

            //Assign the http error if any
            JsonSerializer.AssignError(tempResponse, (PayTraceBasicResponse)keyedSaleResponse);

            //Return the Desearlized object
            return(keyedSaleResponse);
        }
示例#2
0
 //Display the Keyed Sale Response
 protected void DisplaySaleResponse(KeyedSaleResponse result)
 {
     Response.Write("<br>" + "Success : " + result.Success + "<br>");
     Response.Write("response_code : " + result.ResponseCode + "<br>");
     Response.Write("status_message : " + result.StatusMessage + "<br>");
     Response.Write("transaction_id : " + result.TransactionId + "<br>");
     Response.Write("approval_code : " + result.ApprovalCode + "<br>");
     Response.Write("approval_message : " + result.ApprovalMessage + "<br>");
     Response.Write("avs_response : " + result.AvsResponse + "<br>");
     Response.Write("csc_response : " + result.CscResponse + "<br>");
     Response.Write("external_transaction_id : " + result.ExternalTransactionId + "<br>");
     Response.Write("masked_card_number : " + result.MaskedCardNumber + "<br>");
 }
示例#3
0
        protected void WriteResults(KeyedSaleResponse result)
        {
            if (null != result.HttpErrorMessage && result.Success == false)
            {
                Response.Write("<br>" + "Http Error Code & Error : " + result.HttpErrorMessage + "<br>");

                Response.Write("Success : " + result.Success + "<br>");
                Response.Write("response_code : " + result.ResponseCode + "<br>");
                Response.Write("status_message : " + result.StatusMessage + "<br>");
                Response.Write("external_transaction_id : " + result.ExternalTransactionId + "<br>");
                Response.Write("masked_card_number : " + result.MaskedCardNumber + "<br>");

                //Check the actual API errors with appropriate code
                Response.Write(" API errors : " + "<br>");
                foreach (var item in result.TransactionErrors)
                {
                    // to read Error message with each error code in array.
                    foreach (var errorMessage in (string[])item.Value)
                    {
                        Response.Write(item.Key + "=" + errorMessage + "<BR>");
                    }
                }
                Response.Write("Keyed sale: " + "Failed!" + "<br>");
            }
            else
            {
                // Do your code when Response is available based on the response_code.
                // Please refer PayTrace-HTTP Status and Error Codes page for possible errors and Response Codes
                // For transation successfully approved
                if (result.ResponseCode == 101 && result.Success == true)
                {
                    // Do you code for any additional verification

                    // Display Response - optional
                    DisplaySaleResponse(result);
                    Response.Write("Keyed sale: " + "Success!" + "<br>");
                }

                else
                {
                    // Do your code here based on the response_code - use the PayTrace http status and error page for reference
                    // Do your code for any additional verification - avs_response and csc_response

                    //Display Response
                    DisplaySaleResponse(result);
                    Response.Write("Error : " + result.HttpErrorMessage + "<br>");
                }

                // Do your code for Any additional task !
            }
        }