-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0a5367
commit c60bd67
Showing
24 changed files
with
700 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
...tion/Features/Modules.Subscription.Features/Infrastructure/Configuration/StripeOptions.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...ures/Modules.Subscription.Features/Infrastructure/Configuration/StripeSubscriptionType.cs
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
.../Modules.Subscription.Features/Infrastructure/Configuration/SubscriptionsConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Modules.Subscriptions.Features.Infrastructure.StripePayments; | ||
using Shared.Features.Modules.Configuration; | ||
using Shared.Kernel.BuildingBlocks.Auth; | ||
using Shared.Kernel.BuildingBlocks.Auth.DomainKernel; | ||
|
||
namespace Modules.Subscriptions.Features.Infrastructure.Configuration | ||
{ | ||
public class SubscriptionsConfiguration : IModuleConfiguration | ||
{ | ||
public string StripeAPIKey { get; set; } | ||
public string StripeEndpointSecret { get; set; } | ||
public string StripeProfessionalPlanPriceId { get; set; } | ||
public string StripeEnterprisePlanPriceId { get; set; } | ||
|
||
public StripeSubscriptionPlan GetSubscriptionType(SubscriptionPlanType subscriptionPlanType) | ||
{ | ||
return Subscriptions.Single(s => s.Type == subscriptionPlanType); | ||
} | ||
|
||
public List<StripeSubscriptionPlan> Subscriptions => new List<StripeSubscriptionPlan>() | ||
{ | ||
new StripeSubscriptionPlan | ||
{ | ||
Type = SubscriptionPlanType.Professional, | ||
TrialPeriodDays = 14, | ||
StripePriceId = StripeProfessionalPlanPriceId | ||
}, | ||
new StripeSubscriptionPlan | ||
{ | ||
Type = SubscriptionPlanType.Enterprise, | ||
TrialPeriodDays = 14, | ||
StripePriceId = StripeEnterprisePlanPriceId | ||
} | ||
}; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...Subscription.Features/Infrastructure/Configuration/SubscriptionsConfigurationValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Modules.Subscriptions.Features.Infrastructure.Configuration | ||
{ | ||
public class SubscriptionsConfigurationValidator : IValidateOptions<SubscriptionsConfiguration> | ||
{ | ||
public ValidateOptionsResult Validate(string name, SubscriptionsConfiguration options) | ||
{ | ||
if (string.IsNullOrEmpty(options.StripeProfessionalPlanPriceId)) | ||
{ | ||
throw new ArgumentNullException(); | ||
} | ||
|
||
return ValidateOptionsResult.Success; | ||
} | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
...Subscription.Features/Infrastructure/EFCore/Migrations/20240218050150_initial.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
.../Modules.Subscription.Features/Infrastructure/EFCore/Migrations/20240218050150_initial.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Modules.Subscriptions.Features.Infrastructure.EFCore.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class initial : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.EnsureSchema( | ||
name: "Subscriptions"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "StripeCustomers", | ||
schema: "Subscriptions", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
StripePortalCustomerId = table.Column<string>(type: "nvarchar(max)", nullable: true), | ||
CreatedByUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
RowVersion = table.Column<byte[]>(type: "varbinary(max)", nullable: true), | ||
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), | ||
LastUpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_StripeCustomers", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "StripeSubscriptions", | ||
schema: "Subscriptions", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
StripeCustomerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
ExpirationDate = table.Column<DateTime>(type: "datetime2", nullable: true), | ||
PlanType = table.Column<int>(type: "int", nullable: false), | ||
Status = table.Column<int>(type: "int", nullable: false), | ||
CreatedByUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
RowVersion = table.Column<byte[]>(type: "varbinary(max)", nullable: true), | ||
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), | ||
LastUpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), | ||
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_StripeSubscriptions", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_StripeSubscriptions_StripeCustomers_StripeCustomerId", | ||
column: x => x.StripeCustomerId, | ||
principalSchema: "Subscriptions", | ||
principalTable: "StripeCustomers", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_StripeSubscriptions_StripeCustomerId", | ||
schema: "Subscriptions", | ||
table: "StripeSubscriptions", | ||
column: "StripeCustomerId"); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "StripeSubscriptions", | ||
schema: "Subscriptions"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "StripeCustomers", | ||
schema: "Subscriptions"); | ||
} | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
...es/Infrastructure/EFCore/Migrations/20240328173742_StripeSubscriptionPortalId.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.