public ActionResult tokenize(GatewayApiRequest gatewayApiRequest) { // Logger.LogInformation($"PaymentApiController ProcessHostedSession action gatewayApiRequest {JsonConvert.SerializeObject(gatewayApiRequest)}"); //update session with order details GatewayApiRequest gatewayUpdateSessionRequest = new GatewayApiRequest(GatewayApiConfig); gatewayUpdateSessionRequest.ApiMethod = GatewayApiClient.PUT; //update the url appending session id gatewayUpdateSessionRequest.buildSessionRequestUrl(gatewayApiRequest.SessionId); gatewayUpdateSessionRequest.OrderId = gatewayApiRequest.OrderId; gatewayUpdateSessionRequest.OrderCurrency = gatewayApiRequest.OrderCurrency; gatewayUpdateSessionRequest.OrderAmount = gatewayApiRequest.OrderAmount; //build payload with order info gatewayUpdateSessionRequest.buildPayload(); String response = GatewayApiClient.SendTransaction(gatewayUpdateSessionRequest); // Logger.LogInformation($"Tokenize updated session {response}"); //validate transaction response if (JsonHelper.isErrorMessage(response)) { return(View("Error", ErrorViewModel.toErrorViewModel(getRequestId(), response))); } //generate token GatewayApiRequest gatewayGenerateTokenRequest = new GatewayApiRequest(GatewayApiConfig); gatewayGenerateTokenRequest.SessionId = gatewayApiRequest.SessionId; gatewayGenerateTokenRequest.ApiMethod = GatewayApiClient.POST; gatewayGenerateTokenRequest.buildPayload(); gatewayGenerateTokenRequest.buildTokenUrl(); response = GatewayApiClient.SendTransaction(gatewayGenerateTokenRequest); //validate token response if (JsonHelper.isErrorMessage(response)) { return(View("Error", ErrorViewModel.toErrorViewModel(getRequestId(), response))); } //convert json to model TokenResponse tokenResponse = TokenResponse.ToTokenResponse(response); //payment with token GatewayApiRequest gatewayGeneratePaymentRequest = new GatewayApiRequest(GatewayApiConfig); gatewayGeneratePaymentRequest.ApiOperation = "PAY"; gatewayGeneratePaymentRequest.ApiMethod = GatewayApiClient.PUT; gatewayGeneratePaymentRequest.Token = tokenResponse.Token; gatewayGeneratePaymentRequest.SessionId = gatewayApiRequest.SessionId; gatewayGeneratePaymentRequest.OrderId = gatewayApiRequest.OrderId; gatewayGeneratePaymentRequest.TransactionId = gatewayApiRequest.TransactionId; gatewayGeneratePaymentRequest.buildPayload(); gatewayGeneratePaymentRequest.buildRequestUrl(); response = GatewayApiClient.SendTransaction(gatewayGeneratePaymentRequest); buildViewData(gatewayGeneratePaymentRequest, response, 0); return(View(ViewList["ApiResponse"])); }