/// <summary> /// Creates a gateway-client that connects itself to the recipe-api /// </summary> /// <returns></returns> private async Task <GatewayRecipeClient> CreateRecipeApiClient() { var config = GetConfig(); var info = new GatewayInformation(config); var clientInfo = new Helpers.Options.GatewayInformation() { Credentials = new ClientCredentials() { ClientId = info.ClientInfo.ClientId, ClientSecret = info.ClientInfo.ClientSecret, }, AuthServerLocation = info.AuthServerUrl, GatewayClients = info.Apis }; var clientInfoOptions = new OptionsWrapper <Helpers.Options.GatewayInformation>(clientInfo); var client = new GatewayRecipeClient(clientInfoOptions, new MockLoggerFactory <object>()); var tokenResponse = await GetAccessTokenFromAuthServer(clientInfo.GetClientInformation(APINAME_RECIPEAPI)); client.SetBearerToken(tokenResponse.AccessToken); return(client); }
/// <summary> /// Creates a Bot client that connects itself to the api gateway /// </summary> /// <returns></returns> private async Task <GatewayClient> CreateExternalClient() { var config = GetConfig(); var info = new GatewayInformation(config); var clientInfo = new ClientInformation() { Credentials = new ClientCredentials() { ClientId = info.ExternalClientInfo.ClientId, ClientSecret = info.ExternalClientInfo.ClientSecret }, TargetApiName = info.GatewayApiName, TargetBaseUrl = info.GatewayApiBaseUrl, AuthServerLocation = info.AuthServerUrl }; var clientInfoOptions = new OptionsWrapper <ClientInformation>(clientInfo); var client = new GatewayClient(clientInfoOptions, new MockLoggerFactory <object>()); var tokenResponse = await GetAccessTokenFromAuthServer(clientInfo); client.SetBearerToken(tokenResponse.AccessToken); return(client); }
public async Task <PaymentResponse> PaymentRequestAsync(GatewayInformation gatewayInfo) { TokenService.TokensClient tokenClient = new TokensClient(); var response = await tokenClient.MakeTokenAsync("1000", "AA6E", "54545545", "662584852", "", "http://localhost:35521/verifypage.aspx", "Test Sample").ConfigureAwait(false); return(null); }
public PaymentResponse PaymentRequest(GatewayInformation gatewayInfo) { httpClient.jsonConvert = jsonConvert; var requestModel = new Models.RequestToPay(gatewayInfo.Amount, gatewayInfo.MerchantID, gatewayInfo.CallbackURL, "12334"); var resdata = httpClient.HttpRequest(Urls.BaseUrl, HttpMethod.POST, requestModel); return(null); }
public PaymentResponse PaymentRequest(GatewayInformation gatewayInfo) { httpClient.jsonConvert = jsonConvert; var urlInfo = new Configurations.URLs(true); httpClient.BaseUrl = urlInfo.GetPaymentRequestURL(); var data = httpClient.HttpRequest("", HttpMethod.POST, gatewayInfo); var response = jsonConvert.JsonDesrialize <Models.PaymentResponse>((string)data); if (response.Status == 100) { return(new PaymentResponse(true, urlInfo.GetPaymenGatewayURL(response.Authority), response.Authority)); } return(new PaymentResponse(false, $"ErrorCode: {response.Status.ToString()}")); }
private GatewayInformation GetGatewayInformation(StatisticContext context) { var GateStatistic = context.Statistics.Where(x => x.ServerName == ServerName.GATEWAY).ToList(); int CountUnauthorized = 0; int CountAccess = 0; List <int> arrayTime = new List <int>(24); for (int i = 0; i < 24; i++) { arrayTime.Add(0); } List <int> arrayType = new List <int>(5); for (int i = 0; i < 5; i++) { arrayType.Add(0); } foreach (var item in GateStatistic) { string q = item.Detail.ToString(); string[] w = q.Split(' '); if (w[0] == "Unauthorized") { CountUnauthorized++; } if (w[0] == "Access") { CountAccess++; } arrayTime[item.Time.Value.Hour]++; arrayType[(int)item.RequestType]++; } GatewayInformation GateInfo = new GatewayInformation(); GateInfo.NonAuth = CountUnauthorized; GateInfo.Auth = CountAccess; GateInfo.StatTime = arrayTime; GateInfo.StatType = arrayType; return(GateInfo); }
public async Task Test_GetAccessToken() { var config = GetConfig(); var info = new GatewayInformation(config); var clientInfo = new ClientInformation() { Credentials = new ClientCredentials() { ClientId = info.ClientInfo.ClientId, ClientSecret = info.ClientInfo.ClientSecret }, TargetBaseUrl = info.Apis[APINAME_RECIPEAPI], TargetApiName = APINAME_RECIPEAPI, AuthServerLocation = info.AuthServerUrl }; var tokenResponse = await GetAccessTokenFromAuthServer(clientInfo); Assert.False(tokenResponse.IsError); Assert.NotEmpty(tokenResponse.AccessToken); }
public async Task <string> RequestToGateway(GatewayInformation gatewayInfo) { var paymentUrl = gateway.PaymentRequest(gatewayInfo); return(paymentUrl.Url); }
public Task <PaymentResponse> PaymentRequestAsync(GatewayInformation gatewayInfo) { throw new NotImplementedException(); }
public async Task <PaymentResponse> PaymentRequestAsync(GatewayInformation gatewayInfo) { return(null); }