Skip to content

Commit

Permalink
work on stripe integration
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mk committed Jan 2, 2025
1 parent 06386e9 commit 839d5a3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
12 changes: 7 additions & 5 deletions src/FMBot.Bot/Builders/StaticBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,28 @@ public async Task<ResponseModel> DonateAsync(
"- See first listen dates, have an expanded profile and advanced recaps\n" +
"- Ability to store your complete Discogs collection");

response.Embed.AddField("<:history:1131511469096312914> Import your Spotify history",
"- Use your full Spotify listening history together with your Last.fm data\n" +
response.Embed.AddField("<:history:1131511469096312914> Import your Spotify and Apple Music history",
"- Use your full Spotify and/or Apple Music listening history together with your Last.fm data\n" +
"- Get the most accurate playcounts and listening time");

response.Embed.AddField("🔥 Expanded judge command",
"- GPT-4 powered compliments and roasts\n" +
"- GPT-4o powered compliments and roasts\n" +
"- Increased usage limits and ability to use the command on others");

response.Embed.AddField("<:discoveries:1145740579284713512> Go back in time",
"- View when you discovered artists with the exclusive `discoveries` command\n" +
"- See discovery dates in the `artist`, `album` and `track` commands");

response.Embed.AddField("🎮 Play unlimited games",
"- Remove the daily limit on Jumble and Pixel Jumble and play as much as you want");

response.Embed.AddField("⚙️ Customize your commands",
"- Expand your `.fm` footer with extra stats\n" +
"- Add more friends for expanded friend commands\n"+
"- Set your own personal automatic emote reactions");

response.Embed.AddField("⭐ Flex your support",
$"- Get a badge after your name to show your support\n" +
"- Exclusive role and channel in the [.fmbot server](https://discord.gg/fmbot) with sneak peeks\n" +
"- Get a badge in the bot and a role on the [.fmbot server](https://discord.gg/fmbot) with access to sneak peeks\n" +
$"- Higher chance to get featured on Supporter Sundays (next up in {FeaturedService.GetDaysUntilNextSupporterSunday()} {StringExtensions.GetDaysString(FeaturedService.GetDaysUntilNextSupporterSunday())})");

if (existingSupporter != null)
Expand Down
5 changes: 3 additions & 2 deletions src/FMBot.Bot/Services/SupporterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,18 +1407,19 @@ public async Task<IReadOnlyList<Supporter>> GetAllSupporters()
.ToListAsync();
}

public async Task<string> GetSupporterCheckoutLink(ulong discordUserId, string type)
public async Task<string> GetSupporterCheckoutLink(ulong discordUserId, string lastFmUserName, string type)
{
var url = await this._supporterLinkService.GetCheckoutLinkAsync(new CreateLinkOptions
{
DiscordUserId = (long)discordUserId,
LastFmUserName = lastFmUserName,
Type = type
});

return url?.CheckoutLink;
}

public async Task<string> GetSupporterManageLink(ulong discordUserId)
public async Task<string> GetSupporterManageLink(ulong discordUserId, string lastFmUserName)
{
var url = await this._supporterLinkService.GetManageLinkAsync(new GetManageLinkOptions
{
Expand Down
4 changes: 2 additions & 2 deletions src/FMBot.Bot/SlashCommands/StaticSlashCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task GetSupporterLink(string type)
{
var contextUser = await this._userService.GetUserSettingsAsync(this.Context.User);

var link = await this._supporterService.GetSupporterCheckoutLink(this.Context.User.Id, type);
var link = await this._supporterService.GetSupporterCheckoutLink(this.Context.User.Id, contextUser.UserNameLastFM, type);

var components = new ComponentBuilder().WithButton($"Get {type} supporter", style: ButtonStyle.Link, url: link, emote: Emoji.Parse("⭐"));

Expand All @@ -94,7 +94,7 @@ public async Task GetManageLink()
{
var contextUser = await this._userService.GetUserSettingsAsync(this.Context.User);

var link = await this._supporterService.GetSupporterManageLink(this.Context.User.Id);
var link = await this._supporterService.GetSupporterManageLink(this.Context.User.Id, contextUser.UserNameLastFM);

var components = new ComponentBuilder().WithButton("Manage supporter", style: ButtonStyle.Link, url: link, emote: Emoji.Parse("⭐"));

Expand Down
5 changes: 2 additions & 3 deletions src/FMBot.Bot/TextCommands/AdminCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,6 @@ public async Task RunTopListUpdate([Remainder] string user = null)
}

[Command("supporterlink")]
[Summary("Runs a toplist update for someone else")]
public async Task GetSupporterTestLink([Remainder] string user = null)
{
try
Expand All @@ -2389,8 +2388,8 @@ public async Task GetSupporterTestLink([Remainder] string user = null)
embed.WithDescription("⭐ Support .fmbot with .fmbot supporter and unlock extra perks");
embed.AddField("Monthly - $3.99",
"-# $3.99 per month", true);
embed.AddField("Yearly - $29.99",
"-# $2.49 per month - Saves 45%", true);
embed.AddField("Yearly - $23.99",
"-# $1.99 per month - Saves 50%", true);
embed.WithColor(DiscordConstants.InformationColorBlue);

await ReplyAsync(embed: embed.Build(), components: components.Build());
Expand Down
6 changes: 3 additions & 3 deletions src/FMBot.Persistence.Domain/Models/SupporterStripe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public class SupporterStripe
{
public ulong PurchaserDiscordUserId { get; set; }

public ulong PurchaserLastFmUserName { get; set; }

public ulong ReceiverDiscordUserId { get; set; }

public string Email { get; set; }

public string StripeSubscriptionId { get; set; }

public string StripeCustomerId { get; set; }

public string StripeProductId { get; set; }
public string StripeSubscriptionId { get; set; }

public string Type { get; set; }

Expand Down
14 changes: 9 additions & 5 deletions src/Shared.Protos/supporter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ service SupporterLinkService {

rpc GetManageLink (GetManageLinkOptions) returns (GetManageLinkReply);

rpc AddStripeSupporter (AddStripeSupporterRequest) returns (AddStripeSupporterReply);
rpc AddOrUpdateStripeSupporter (AddOrUpdateStripeSupporterRequest) returns (AddStripeSupporterReply);
}


message CreateLinkOptions {
int64 discordUserId = 1;
string type = 2;
string lastFmUserName = 3;

}

message CreateLinkReply {
Expand All @@ -32,11 +34,13 @@ message GetManageLinkReply {
string manageLink = 1;
}

message AddStripeSupporterRequest {
message AddOrUpdateStripeSupporterRequest {
int64 discordUserId = 1;
string stripeCustomerId = 2;
string stripeSubscriptionId = 3;
google.protobuf.Timestamp endsAt = 4;
string lastFmUserName = 2;
string stripeCustomerId = 3;
string stripeSubscriptionId = 4;
google.protobuf.Timestamp created = 5;
google.protobuf.Timestamp endsAt = 6;
}

message AddStripeSupporterReply {
Expand Down

0 comments on commit 839d5a3

Please sign in to comment.