/// <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 PayTraceBasicSaleResponse Type
        /// </summary>
        public PayTraceBasicSaleResponse SwipedSaleTrans(string token, SwipedSaleRequest swipedSaleRequest)
        {
            // Header details are available at Authentication header page.
            string methodUrl = ApiEndPointConfiguration.UrlSwipedSale;

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

            //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 payTraceBasicSaleResponse = new PayTraceBasicSaleResponse();

            payTraceBasicSaleResponse = JsonSerializer.DeserializeResponse <PayTraceBasicSaleResponse>(tempResponse);

            //Assign the http error
            JsonSerializer.AssignError(tempResponse, (PayTraceBasicResponse)payTraceBasicSaleResponse);

            //Return the Desearlized object
            return(payTraceBasicSaleResponse);
        }
Example #2
0
        protected void WriteResults(PayTraceBasicSaleResponse result)
        {
            // Based on the response display the 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>");

                //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 an array.
                    foreach (var errorMessage in (string[])item.Value)
                    {
                        //Do your code here to handle an specific error based on the error key code

                        //Optional - display
                        Response.Write(item.Key + "=" + errorMessage + "<br>");
                    }
                }
                //Optional
                Response.Write("Vault Sale by Customer ID :  " + "Failed!" + "<br>" + "<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);

                    //Optional
                    Response.Write("Vault Sale by Customer ID :" + "Success!" + "<br>" + "<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);

                    //Optional : Provide Appropriate message/action
                    Response.Write("Error : " + result.HttpErrorMessage + "<br>" + "<br>");
                }

                // Do your code for Any additional task!
            }
        }
Example #3
0
 protected void DisplaySaleResponse(PayTraceBasicSaleResponse result)
 {
     // Display the Swiped Sale Response
     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>");
 }