Exemplo n.º 1
0
        public string RemoveToken(GridMPGSConfig mpgsConfig, string token)
        {
            GatewayApiConfig config = new GatewayApiConfig(mpgsConfig);

            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(config)
            {
                ApiMethod = "DELETE"
            };

            gatewayApiRequest.buildDeleteUrl(token);

            gatewayApiRequest.buildPayload();

            string request = JsonConvert.SerializeObject(gatewayApiRequest);

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

            GatewayApiClient gatewayApiClient = new GatewayApiClient(config);

            string response = gatewayApiClient.executeHTTPMethod(gatewayApiRequest);

            LogInfo.Information(response);

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

            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(config)
            {
                ApiMethod           = "VOID",
                TargetTransactionId = "ea2d89bb24",
                TransactionId       = GenerateOrderId(),
                Token = "440003320900022"
            };

            gatewayApiRequest.buildRequestUrl();

            gatewayApiRequest.buildPayload();

            string request = JsonConvert.SerializeObject(gatewayApiRequest);

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

            GatewayApiClient gatewayApiClient = new GatewayApiClient(config);

            string response = gatewayApiClient.executeHTTPMethod(gatewayApiRequest);

            LogInfo.Information(response);

            return(TokenResponse.GetResponseResult(response));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        public string AuthorizeTest(GridMPGSConfig mpgsConfig)
        {
            GatewayApiConfig config = new GatewayApiConfig(mpgsConfig);

            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(config)
            {
                // SessionId = "" ,//checkOutDetails.CheckoutSession.Id,
                OrderId          = GenerateOrderId(), //checkOutDetails.OrderId,
                TransactionId    = GenerateOrderId(), //checkOutDetails.TransactionID,
                ApiOperation     = MPGSAPIOperation.AUTHORIZE.ToString(),
                OrderAmount      = "20",
                OrderCurrency    = config.Currency,
                ApiMethod        = "PUT",
                Token            = "4440008087700014",
                SourceType       = "CARD",
                OrderDescription = "test pay",
            };

            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));
        }
Exemplo n.º 6
0
        public string  Authorize(GridMPGSConfig mpgsConfig, Checkout checkOutDetails, PaymentMethod paymentMethod)
        {
            GatewayApiConfig config = new GatewayApiConfig(mpgsConfig);

            GatewayApiRequest gatewayApiRequest = new GatewayApiRequest(config, checkOutDetails.ReceiptNumber, checkOutDetails.OrderNumber)
            {
                SessionId        = checkOutDetails.CheckoutSession.Id,
                OrderId          = checkOutDetails.OrderId,
                TransactionId    = checkOutDetails.TransactionID,
                ApiOperation     = MPGSAPIOperation.AUTHORIZE.ToString(),
                OrderAmount      = checkOutDetails.Amount.ToString(),
                OrderCurrency    = config.Currency,
                ApiMethod        = "PUT",
                Token            = paymentMethod.Token,
                SourceType       = paymentMethod.SourceType,
                OrderDescription = "",
            };

            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));
        }
Exemplo n.º 7
0
        public string PayWithToken(GridMPGSConfig mpgsConfig, string token, string sessionID, string orderID, string transactionID, string amount)
        {
            try
            {
                //payment with token

                GatewayApiConfig config = new GatewayApiConfig(mpgsConfig);

                GatewayApiRequest gatewayGeneratePaymentRequest = new GatewayApiRequest(config);

                gatewayGeneratePaymentRequest.ApiOperation = "PAY";

                gatewayGeneratePaymentRequest.ApiMethod = GatewayApiClient.PUT;

                gatewayGeneratePaymentRequest.Token = token;                 //tokenResponse.Token;

                gatewayGeneratePaymentRequest.SessionId = sessionID;         // responseUpdate.MPGSResponse.session.id;

                gatewayGeneratePaymentRequest.OrderId = orderID;             //updateTokenSesisonDetails.MPGSOrderID;

                gatewayGeneratePaymentRequest.TransactionId = transactionID; // updateTokenSesisonDetails.TransactionID;

                gatewayGeneratePaymentRequest.OrderAmount = amount;

                gatewayGeneratePaymentRequest.buildPayload();

                gatewayGeneratePaymentRequest.buildRequestUrl();

                //payment response
                GatewayApiClient gatewayApiClient = new GatewayApiClient(config);

                string response = gatewayApiClient.SendTransaction(gatewayGeneratePaymentRequest);

                LogInfo.Information($" {EnumExtensions.GetDescription(MPGSAPIResponse.HostedCheckoutRetrieveReceipt) + " " + response}");

                return(TokenResponse.GetResponseResult(response));
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw ex;
            }
        }