Esempio n. 1
0
        public async Task <bool> Handle(CreateEntryRequest message, IOutputPort <ServiceResponse> outputPort)
        {
            var response = await _entryRepository.Create(message.Name, message.PhoneNumber, message.PhoneBookId);

            outputPort.Handle(response.Success ? new ServiceResponse(response.Id, true) : new ServiceResponse(response.Errors.Select(e => e.Description)));
            return(response.Success);
        }
Esempio n. 2
0
        public Entry Create(Entry entry)
        {
            entry.Created = DateTime.UtcNow;

            if (string.IsNullOrEmpty(entry.Summary) || string.IsNullOrEmpty(entry.Content))
            {
                entry.State = EntryStateEnum.Draft;
            }

            return(Repository.Create(entry));
        }
Esempio n. 3
0
        public string Init(Entry entry)
        {
            if (entry.Cost == 0)
            {
                return("Unable to complete entry as cost can not be calculated, please contact support.");
            }

            entry.Paid        = false;
            entry.DateOfBirth = DateTime.ParseExact(entry.DateOfBirthString, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            string apiKey = ConfigurationManager.AppSettings["stripeSecretKey"];

            StripeConfiguration.ApiKey = apiKey;

            int cost = entry.Cost * 100;

            var options = new PaymentIntentCreateOptions
            {
                Amount       = cost,
                Currency     = "gbp",
                ReceiptEmail = entry.Email,
                Description  = $"{entry.RaceType} Entry",
                // Verify your integration in this guide by including this parameter
                Metadata = new Dictionary <string, string>
                {
                    { "integration_check", "accept_a_payment" },
                },
            };

            var           service       = new PaymentIntentService();
            PaymentIntent paymentIntent = service.Create(options);

            entry.ClientSecret = paymentIntent.ClientSecret;
            string entryString = JsonConvert.SerializeObject(entry);

            Logger.Info(this.GetType(), "New entry request: {0}", () => entryString);

            entry = _entryRepository.Create(entry);

            return(paymentIntent.ClientSecret);
        }