private async Task <PostStripeChargeResult> CreateCharge(ScheduledPayment scheduledPayment) { var charge = new StripeCharge { Amount = scheduledPayment.Amount.ToString(), Currency = "usd", Source = "tok_visa ", Description = "Posted using ResilientHttpClient" }; string response = ""; try { var values = GetValues(scheduledPayment); string stripeApiKey = await GetStripeKeyAsync(); var httpResponse = await _httpClient.PostToStripe(uri : "https://api.stripe.com/v1/charges", values : values, apiKey : stripeApiKey); response = await httpResponse.Content.ReadAsStringAsync(); } catch (Exception ex) { throw; } _logger.LogInformation(response); var mapResult = MapToPostStripeChargeResult(response); return(mapResult); }
private Dictionary <string, string> GetValues(ScheduledPayment scheduledPayment) => new Dictionary <string, string> { { "amount", scheduledPayment.Amount.ToString() }, { "currency", "usd" }, { "source", scheduledPayment.StripeCustomerId }, { "description", "From NetCoreBackGroundJon using ResilientHttpClient" } };
private void PostFailureToQueue(ScheduledPayment scheduledPayment) { // The case of Payment Microservice not available, post failures to SQS }