/// <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 CreateCustomerProfileResponse Type
        /// </summary>
        public CreateCustomerProfileResponse CreateCustomerProfileTrans(string token, CreateCustomerProfileRequest createCustomerProfileRequest)
        {
            // Header details are available at Authentication header page.
            string methodUrl = ApiEndPointConfiguration.UrlCreateCustomer;

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

            //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 createCustomerProfileResponse = new CreateCustomerProfileResponse();

            createCustomerProfileResponse = JsonSerializer.DeserializeResponse <CreateCustomerProfileResponse>(tempResponse);

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

            //Return the Desearlized object
            return(createCustomerProfileResponse);
        }
예제 #2
0
 //Display the void Transaction Response
 protected void DisplaySaleResponse(CreateCustomerProfileResponse result)
 {
     Response.Write("<br>" + "Success : " + result.Success + "<br>");
     Response.Write("response_code : " + result.ResponseCode + "<br>");
     Response.Write("status_message : " + result.StatusMessage + "<br>");
     Response.Write("Customer_id : " + result.CustomerId + "<br>");
     Response.Write("Masked_card_number : " + result.MaskedCardNumber + "<br>");
 }
예제 #3
0
        //Based on the response display the result.
        protected void WriteResults(CreateCustomerProfileResponse 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("Masked_card_number : " + result.MaskedCardNumber + "<br>");

                //Check the actual API errors with appropriate response 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>");
                    }
                }
                //Optional
                Response.Write("Create Customer Profile " + "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
                // When Customer profile is created successfully.
                if (result.ResponseCode == 160 && result.Success == true)
                {
                    // Do you code for any additional verification

                    // Display Response - optional
                    DisplaySaleResponse(result);

                    //Optional
                    Response.Write("Create Customer Profile  " + "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

                    //optional - Display Response
                    DisplaySaleResponse(result);

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

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