public async Task CreatePayment() { var logger = ServiceScope.ServiceProvider.GetService <ILogger <SquareTest> >(); var squareCustomerReference = CreateSquareCustomerReference.FromTimestamp(GetUniqueNow()); var squareCustomerId = await SquareMicroService.AllocateSquareCustomerAsync(squareCustomerReference); logger.LogInformation($"Square customer ID = {squareCustomerId}"); var squarePaymentReference = CreateSquarePaymentReference.FromTimestamp(GetUniqueNow()); var squarePaymentId = await SquareMicroService.AllocateSquarePaymentAsync(squarePaymentReference, squareCustomerId); logger.LogInformation($"Square payment ID = {squarePaymentId}"); var squareWebPaymentTransactionId = await SquareMicroService.CreateSquareWebPaymentRequestAsync(squarePaymentId, 100m, "cnon:card-nonce-ok"); var paymentResponse = await SquareMicroService.ProcessWebPaymentRequestAsync(squareWebPaymentTransactionId); logger.LogInformation($"Square payment response = {paymentResponse}"); //var squareRefundTransactionId = await SquareMicroService.CreateSquareRefundTransactionAsync(squarePaymentId, 25m); //var refundResponse = await SquareMicroService.ProcessSquarePaymentTransactionAsync(squareRefundTransactionId); //logger.LogInformation($"Square refund response = {refundResponse}"); _ = await SquareMicroService.ProcessEventsAsync(); }
public async Task <int> ProcessPendingEvents() { using var log = BeginFunction(nameof(EventProcessorMicroService), nameof(ProcessPendingEvents)); try { var totalCount = 0; int iterationCount; do { iterationCount = 0; iterationCount += await CommunicationMicroService.ProcessEventsAsync(); iterationCount += await FulfillmentMicroService.ProcessEventsAsync(); iterationCount += await FundingMicroService.ProcessEventsAsync(); iterationCount += await InventoryMicroService.ProcessEventsAsync(); iterationCount += await OrderMicroService.ProcessEventsAsync(); iterationCount += await SquareMicroService.ProcessEventsAsync(); iterationCount += await UserMicroService.ProcessEventsAsync(); //Task<int>[] tasks = { //CommunicationMicroService.ProcessEventsAsync(), //FulfillmentMicroService.ProcessEventsAsync(), //FundingMicroService.ProcessEventsAsync(), //InventoryMicroService.ProcessEventsAsync(), //OrderMicroService.ProcessEventsAsync(), //PayPalMicroService.ProcessEventsAsync(), //SquareMicroService.ProcessEventsAsync(), //UserMicroService.ProcessEventsAsync() }; //var counts = await Task.WhenAll(tasks); //iterationCount = counts.Sum(); totalCount += iterationCount; } while (iterationCount > 0); var result = totalCount; log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }