/// <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 PayTraceExternalTransResponse Type 
        /// </summary>
        public PayTraceExternalTransResponse CaptureTransactionTrans(string token, CaptureTransactionRequest captureTransactionRequest)
		{

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

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

			//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 payTraceExternalTransResponse = new PayTraceExternalTransResponse();
			payTraceExternalTransResponse = JsonSerializer.DeserializeResponse<PayTraceExternalTransResponse>(tempResponse);

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

			//Return the Desearlized object
			return payTraceExternalTransResponse;
		}
Beispiel #2
0
 //Display the void Transaction Response
 protected void DisplaySaleResponse(PayTraceExternalTransResponse 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("external_transaction_id : " + result.ExternalTransactionId + "<br>");
 }
Beispiel #3
0
        //Based on the response display the result.
        protected void WriteResults(PayTraceExternalTransResponse 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 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("<br>" + "Capture Transaction: " + "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
                if (result.ResponseCode == 112 && result.Success == true)                  //for transaction successfully approved
                {
                    // Do you code for any additional verification

                    // Display Response - optional
                    DisplaySaleResponse(result);

                    //Optional
                    Response.Write("Capture Transaction : " + "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);

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

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