Ejemplo n.º 1
0
        public string  Capture(GridMPGSConfig mpgsConfig, TokenSession tokenSession)
        {
            GatewayApiConfig config = new GatewayApiConfig(mpgsConfig);

            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(config)
            {
                OrderId             = tokenSession.MPGSOrderID,
                ApiOperation        = MPGSAPIOperation.CAPTURE.ToString(),
                TransactionAmount   = tokenSession.Amount.ToString(),
                TransactionId       = PaymentHelper.GenerateOrderId(),
                TransactionCurrency = config.Currency,
                Token      = tokenSession.Token,
                SourceType = tokenSession.SourceOfFundType
            };

            gatewayApiRequest.buildRequestUrl();

            gatewayApiRequest.buildPayload();

            string request = JsonConvert.SerializeObject(gatewayApiRequest);

            LogInfo.Information(JsonConvert.SerializeObject(gatewayApiRequest));

            GatewayApiClient gatewayApiClient = new GatewayApiClient(config);

            string response = gatewayApiClient.SendTransaction(gatewayApiRequest);

            LogInfo.Information(response);

            return(TokenResponse.GetResponseResult(response));
        }
Ejemplo n.º 2
0
        public string CaptureTest(GridMPGSConfig mpgsConfig)
        {
            GatewayApiConfig config = new GatewayApiConfig(mpgsConfig);

            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(config)
            {
                OrderId             = "77749b36d8", // authorized order id
                ApiOperation        = MPGSAPIOperation.CAPTURE.ToString(),
                TransactionAmount   = "20",
                TransactionId       = PaymentHelper.GenerateOrderId(),
                TransactionCurrency = config.Currency,
                Token      = "4440008087700014",
                SourceType = "CARD"
            };

            gatewayApiRequest.buildRequestUrl();

            gatewayApiRequest.buildPayload();

            string request = JsonConvert.SerializeObject(gatewayApiRequest);

            LogInfo.Information(JsonConvert.SerializeObject(gatewayApiRequest));

            GatewayApiClient gatewayApiClient = new GatewayApiClient(config);

            string response = gatewayApiClient.SendTransaction(gatewayApiRequest);

            LogInfo.Information(response);

            return(TokenResponse.GetResponseResult(response));
        }
Ejemplo n.º 3
0
        public static GatewayApiRequest CreateTokenizationApiRequest(GatewayApiConfig gatewayApiConfig, string apiOperation = null, string sessionId = null)
        {
            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(gatewayApiConfig)
            {
                SessionId     = sessionId,
                OrderId       = PaymentHelper.GenerateOrderId(),
                TransactionId = PaymentHelper.GenerateOrderId(),
                ApiOperation  = apiOperation,
                OrderAmount   = "",
                OrderCurrency = gatewayApiConfig.Currency
            };

            gatewayApiRequest.buildRequestUrl();

            if (apiOperation == "CAPTURE" || apiOperation == "REFUND")
            {
                gatewayApiRequest.TransactionAmount = "";

                gatewayApiRequest.TransactionCurrency = gatewayApiConfig.Currency;

                gatewayApiRequest.OrderId = null;
            }
            if (apiOperation == "VOID" || apiOperation == "UPDATE_AUTHORIZATION")
            {
                gatewayApiRequest.OrderId = null;
            }
            if (apiOperation == "RETRIEVE_ORDER" || apiOperation == "RETRIEVE_TRANSACTION")
            {
                gatewayApiRequest.ApiMethod = "GET";

                gatewayApiRequest.OrderId = null;

                gatewayApiRequest.TransactionId = null;
            }

            gatewayApiRequest.buildPayload();

            return(gatewayApiRequest);
        }