Skip to content
This repository was archived by the owner on Oct 23, 2021. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CollAction/CollAction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

<ItemGroup>
<PackageReference Include="AspNetCore.IServiceCollection.AddIUrlHelper" Version="1.1.0" />
<PackageReference Include="AWSSDK.S3" Version="3.3.111.2" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.3.101.152" />
<PackageReference Include="AWSSDK.S3" Version="3.3.111.4" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.3.101.157" />
<PackageReference Include="Faker.Net" Version="1.3.77" />
<PackageReference Include="GraphiQL" Version="2.0.0" />
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="GraphQL.Authorization" Version="2.1.29" />
<PackageReference Include="GraphQL.EntityFramework" Version="9.4.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.6.4.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.23" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="HtmlSanitizer" Version="5.0.319" />
<PackageReference Include="MailChimp.Net.V3" Version="4.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.14.0" />
Expand All @@ -37,13 +37,13 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" PrivateAssets="All" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Slack" Version="1.2.63" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0007" />
<PackageReference Include="Stripe.net" Version="26.0.0" />
<PackageReference Include="Stripe.net" Version="37.6.0" />
</ItemGroup>
</Project>
47 changes: 24 additions & 23 deletions CollAction/Services/Donation/DonationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public sealed class DonationService : IDonationService
private readonly IEmailSender emailSender;
private readonly ILogger<DonationService> logger;
private readonly IServiceProvider serviceProvider;
private readonly StripeClient stripeClient;
private readonly StripeSignatures stripeSignatures;
private readonly ApplicationDbContext context;
private readonly UserManager<ApplicationUser> userManager;
Expand All @@ -89,13 +90,14 @@ public DonationService(
this.emailSender = emailSender;
this.logger = logger;
this.serviceProvider = serviceProvider;
customerService = new CustomerService(this.requestOptions.ApiKey);
sourceService = new SourceService(this.requestOptions.ApiKey);
chargeService = new ChargeService(this.requestOptions.ApiKey);
sessionService = new SessionService(this.requestOptions.ApiKey);
subscriptionService = new SubscriptionService(this.requestOptions.ApiKey);
planService = new PlanService(this.requestOptions.ApiKey);
productService = new ProductService(this.requestOptions.ApiKey);
this.stripeClient = new StripeClient(this.requestOptions.ApiKey);
customerService = new CustomerService(stripeClient);
sourceService = new SourceService(stripeClient);
chargeService = new ChargeService(stripeClient);
sessionService = new SessionService(stripeClient);
subscriptionService = new SubscriptionService(stripeClient);
planService = new PlanService(stripeClient);
productService = new ProductService(stripeClient);
}

public async Task<bool> HasIDealPaymentSucceeded(string sourceId, string clientSecret, CancellationToken token)
Expand All @@ -117,6 +119,7 @@ public async Task<string> InitializeCreditCardCheckout(CreditCardCheckout checko
}

ApplicationUser user = await userManager.FindByEmailAsync(checkout.Email).ConfigureAwait(false);
Customer customer = await GetOrCreateCustomer(checkout.Name, checkout.Email, token).ConfigureAwait(false);

var sessionOptions = new SessionCreateOptions()
{
Expand All @@ -125,20 +128,20 @@ public async Task<string> InitializeCreditCardCheckout(CreditCardCheckout checko
PaymentMethodTypes = new List<string>
{
"card",
}
},
Customer = customer.Id
};

if (checkout.Recurring)
{
logger.LogInformation("Initializing recurring credit card checkout session");
sessionOptions.CustomerEmail = checkout.Email; // TODO: sessionOptions.CustomerId = customer.Id; // Once supported
sessionOptions.SubscriptionData = new SessionSubscriptionDataOptions()
{
Items = new List<SessionSubscriptionDataItemOptions>()
{
new SessionSubscriptionDataItemOptions()
{
PlanId = (await CreateRecurringPlan(checkout.Amount, checkout.Currency, token).ConfigureAwait(false)).Id,
Plan = (await CreateRecurringPlan(checkout.Amount, checkout.Currency, token).ConfigureAwait(false)).Id,
Quantity = 1
}
}
Expand All @@ -147,8 +150,6 @@ public async Task<string> InitializeCreditCardCheckout(CreditCardCheckout checko
else
{
logger.LogInformation("Initializing credit card checkout session");
Customer customer = await GetOrCreateCustomer(checkout.Name, checkout.Email, token).ConfigureAwait(false);
sessionOptions.CustomerId = customer.Id;
sessionOptions.LineItems = new List<SessionLineItemOptions>()
{
new SessionLineItemOptions()
Expand Down Expand Up @@ -197,13 +198,13 @@ public async Task InitializeSepaDirect(SepaDirectCheckout checkout, Cancellation
new SubscriptionCreateOptions()
{
DefaultSource = source.Id,
Billing = Billing.ChargeAutomatically,
CustomerId = customer.Id,
Items = new List<SubscriptionItemOption>()
CollectionMethod = "charge_automatically",
Customer = customer.Id,
Items = new List<SubscriptionItemOptions>()
{
new SubscriptionItemOption()
new SubscriptionItemOptions()
{
PlanId = plan.Id,
Plan = plan.Id,
Quantity = 1
}
}
Expand Down Expand Up @@ -279,7 +280,7 @@ public async Task LogPaymentEvent(string json, string signature, CancellationTok
var subscriptions = await subscriptionService.ListAsync(
new SubscriptionListOptions()
{
CustomerId = charge.CustomerId
Customer = charge.CustomerId
},
cancellationToken: token).ConfigureAwait(false);
Customer customer = await customerService.GetAsync(charge.CustomerId, cancellationToken: token).ConfigureAwait(false);
Expand All @@ -303,8 +304,8 @@ public async Task Charge(string sourceId)
{
Amount = source.Amount,
Currency = source.Currency,
SourceId = sourceId,
CustomerId = source.Customer,
Source = sourceId,
Customer = source.Customer,
Description = "A donation to Stichting CollAction"
}).ConfigureAwait(false);
}
Expand Down Expand Up @@ -340,7 +341,7 @@ public async Task<IEnumerable<Subscription>> GetSubscriptionsFor(ApplicationUser
subscriptionService.ListAsync(
new SubscriptionListOptions()
{
CustomerId = c.Id
Customer = c.Id
},
cancellationToken: token))).ConfigureAwait(false);

Expand Down Expand Up @@ -370,7 +371,7 @@ private async Task<Plan> CreateRecurringPlan(int amount, string currency, Cancel
return await planService.CreateAsync(
new PlanCreateOptions()
{
ProductId = product.Id,
Product = product.Id,
Active = true,
Amount = amount * 100,
Currency = currency,
Expand Down Expand Up @@ -410,7 +411,7 @@ private async Task<Product> GetOrCreateRecurringDonationProduct(CancellationToke

private async Task<Customer> GetOrCreateCustomer(string name, string email, CancellationToken token)
{
Customer? customer = (await customerService.ListAsync(new CustomerListOptions() { Email = email, Limit = 1 }, requestOptions, token).ConfigureAwait(false)).FirstOrDefault();
Customer? customer = (await customerService.ListAsync(new CustomerListOptions() { Email = email, Limit = 1 }, cancellationToken: token).ConfigureAwait(false)).FirstOrDefault();
string? metadataName = null;
customer?.Metadata?.TryGetValue(NameKey, out metadataName);
var metadata = new Dictionary<string, string>() { { NameKey, name } };
Expand Down
1 change: 0 additions & 1 deletion Frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "collaction-frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@apollo/client": "^3.0.0-beta.50",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
<FormGroup>
<FormControl>
<TextField
name="name"
label="Crowdaction Name"
type="text"
{ ...formik.getFieldProps('name') }
Expand All @@ -221,7 +220,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl>
<TextField
name="description"
label="Description"
type="text"
multiline={true}
Expand All @@ -232,7 +230,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl>
<TextField
name="proposal"
label="Crowdaction Proposal"
type="text"
multiline={true}
Expand All @@ -243,7 +240,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="goal"
label="Crowdaction Goal"
type="text"
multiline={true}
Expand All @@ -254,7 +250,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="creatorComments"
multiline={true}
rows={5}
label="Creator Comments"
Expand All @@ -265,7 +260,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="target"
label="Target"
type="number"
{ ...formik.getFieldProps('target') }
Expand All @@ -274,7 +268,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="start"
label="Start"
type="date"
InputLabelProps={{ shrink: true }}
Expand All @@ -284,7 +277,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="end"
label="End"
type="date"
InputLabelProps={{ shrink: true }}
Expand All @@ -294,7 +286,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="descriptionVideoLink"
label="Description Video Link"
type="text"
{ ...formik.getFieldProps('descriptionVideoLink') }
Expand All @@ -303,7 +294,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="ownerEmail"
label="Owner E-Mail"
type="text"
{ ...formik.getFieldProps('ownerEmail') }
Expand All @@ -312,7 +302,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="tags"
label="Tags - separated by ';'"
type="text"
{ ...formik.getFieldProps('tags') }
Expand All @@ -321,7 +310,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="numberCrowdactionEmailsSent"
label="Number Crowdaction E-Mails Send"
type="number"
{ ...formik.getFieldProps('numberCrowdactionEmailsSent') }
Expand All @@ -330,7 +318,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl >
<TextField
name="anonymousUserParticipants"
label="Anonymous Participants"
type="number"
{ ...formik.getFieldProps('anonymousUserParticipants') }
Expand All @@ -339,37 +326,36 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl className={classes.formControl}>
<InputLabel shrink id="first-category-label">First Category</InputLabel>
<Select name="firstCategory" labelId="first-category-label" { ...formik.getFieldProps('firstCategory')}>
<Select labelId="first-category-label" { ...formik.getFieldProps('firstCategory')}>
<MenuItem key="" value="NONE">NONE</MenuItem>
{ categories.map(c => <MenuItem key={c} value={c}>{c}</MenuItem>) }
</Select>
<Alert type="error" text={formik.errors.firstCategory} />
</FormControl>
<FormControl className={classes.formControl}>
<InputLabel shrink id="second-category-label">Second Category</InputLabel>
<Select labelId="second-category-label" name="secondCategory" { ...formik.getFieldProps('secondCategory')}>
<Select labelId="second-category-label" { ...formik.getFieldProps('secondCategory')}>
<MenuItem key="" value="NONE">NONE</MenuItem>
{ categories.map(c => <MenuItem key={c} value={c}>{c}</MenuItem>) }
</Select>
<Alert type="error" text={formik.errors.secondCategory} />
</FormControl>
<FormControl className={classes.formControl}>
<InputLabel shrink id="status-label">Status</InputLabel>
<Select labelId="status-label" name="status" { ...formik.getFieldProps('status')}>
<Select labelId="status-label" { ...formik.getFieldProps('status')}>
{ crowdactionStatusses.map(s => <MenuItem key={s} value={s}>{s}</MenuItem>) }
</Select>
<Alert type="error" text={formik.errors.status} />
</FormControl>
<FormControl className={classes.formControl}>
<InputLabel shrink id="display-priority-label">Display Priority</InputLabel>
<Select labelId="display-priority-label" name="displayPriority" { ...formik.getFieldProps('displayPriority')}>
<Select labelId="display-priority-label" { ...formik.getFieldProps('displayPriority')}>
{ displayPriorities.map(d => <MenuItem key={d} value={d}>{d}</MenuItem>) }
</Select>
<Alert type="error" text={formik.errors.displayPriority} />
</FormControl>
<FormControl >
<TextField
name="descriptiveImageDescription"
label="Descriptive Image Description"
InputLabelProps={{ shrink: true }}
type="text"
Expand Down Expand Up @@ -399,7 +385,6 @@ export default ({ crowdactionId } : IEditCrowdactionProps): any => {
</FormControl>
<FormControl ></FormControl>
<TextField
name="bannerImageDescription"
label="Banner Image Description"
type="text"
InputLabelProps={{ shrink: true }}
Expand Down
Loading