Ejemplo n.º 1
0
        public ActionResult HostedCheckoutReceipt(string orderId, string result, string sessionId)
        {
            //    Logger.LogInformation($"PaymentApiController HostedCheckoutReceipt action orderId {orderId} result {result} sessionId {sessionId}");

            if (result == "SUCCESS")
            {
                GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(GatewayApiConfig)
                {
                    ApiOperation = "RETRIEVE_ORDER",
                    OrderId      = orderId,
                    ApiMethod    = GatewayApiClient.GET
                };

                gatewayApiRequest.buildOrderUrl();


                string response = GatewayApiClient.SendTransaction(gatewayApiRequest);

                //  Logger.LogInformation($"Hosted checkout retrieve order response {response}");

                //parse response
                TransactionResponseModel transactionResponseModel = null;
                try
                {
                    transactionResponseModel = TransactionResponseModel.toTransactionResponseModel(response);
                }
                catch (Exception e)
                {
                    //   Logger.LogError($"Hosted Checkout Receipt error : {JsonConvert.SerializeObject(e)}");

                    return(View("Error", new ErrorViewModel
                    {
                        RequestId = getRequestId(),
                        Cause = e.InnerException != null ? e.InnerException.StackTrace : e.StackTrace,
                        Message = e.Message
                    }));
                }

                return(View(ViewList["Receipt"], transactionResponseModel));
            }
            else
            {
                //   Logger.LogError($"The payment was unsuccessful {result}");
                return(View("Error", new ErrorViewModel
                {
                    RequestId = getRequestId(),
                    Cause = "Payment was unsuccessful",
                    Message = "There was a problem completing your transaction."
                }));
            }
        }
Ejemplo n.º 2
0
        public ActionResult browserPaymentReceipt(String transactionId, String orderId)
        {
            //get order id from page parameter

            //create a gateway parameters request to retrieve the transaction result
            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest();

            gatewayApiRequest.GatewayApiConfig = GatewayApiConfig;
            gatewayApiRequest.ApiMethod        = GatewayApiClient.GET;
            gatewayApiRequest.ApiOperation     = "RETRIEVE_TRANSACTION";
            gatewayApiRequest.OrderId          = orderId;

            gatewayApiRequest.buildOrderUrl();
            gatewayApiRequest.buildPayload();


            string response = GatewayApiClient.SendTransaction(gatewayApiRequest);

            //validate transaction response
            if (JsonHelper.isErrorMessage(response))
            {
                return(View("Error", ErrorViewModel.toErrorViewModel(getRequestId(), response)));
            }


            //parse response to model
            TransactionResponseModel model = null;

            try
            {
                model = TransactionResponseModel.toTransactionResponseModel(response);
            }
            catch (Exception e)
            {
                //  Logger.LogError($"browserPaymentReceipt error : {JsonConvert.SerializeObject(e)}");

                return(View("Error", new ErrorViewModel
                {
                    RequestId = getRequestId(),
                    Cause = e.InnerException != null ? e.InnerException.StackTrace : e.StackTrace,
                    Message = e.Message
                }));
            }

            return(View(ViewList["Receipt"], model));
        }
Ejemplo n.º 3
0
        public ActionResult Process(GatewayApiRequest gatewayApiRequest)
        {
            //  Logger.LogInformation($"PaymentApiController Process action gatewayApiRequest {JsonConvert.SerializeObject(gatewayApiRequest)}");

            gatewayApiRequest.GatewayApiConfig = GatewayApiConfig;

            //retrieve order doesnt require transaction information on the url
            if ("RETRIEVE_ORDER" == gatewayApiRequest.ApiOperation)
            {
                gatewayApiRequest.buildOrderUrl();
            }
            else
            {
                gatewayApiRequest.buildRequestUrl();
            }

            gatewayApiRequest.buildPayload();

            string response = GatewayApiClient.SendTransaction(gatewayApiRequest);

            buildViewData(gatewayApiRequest, response, 0);

            return(View(ViewList["ApiResponse"]));
        }