add: stripe integration

This commit is contained in:
trisua 2025-05-05 19:38:01 -04:00
parent 2fa5a4dc1f
commit 1d120555a0
31 changed files with 1137 additions and 122 deletions

View file

@ -163,6 +163,39 @@ pub struct ConnectionsConfig {
pub last_fm_secret: Option<String>,
}
/// Configuration for Stripe integration.
///
/// User IDs are sent to Stripe through the payment link.
/// <https://docs.stripe.com/payment-links/url-parameters#streamline-reconciliation-with-a-url-parameter>
///
/// # Testing
///
/// - Run `stripe login` using the Stripe CLI
/// - Run `stripe listen --forward-to localhost:4118/api/v1/service_hooks/stripe`
/// - Use testing card numbers: <https://docs.stripe.com/testing?testing-method=card-numbers#visa>
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct StripeConfig {
/// Payment link from the Stripe dashboard.
///
/// 1. Create a product and set the price for your membership
/// 2. Set the product price to a recurring subscription
/// 3. Create a payment link for the new product
/// 4. The payment link pasted into this config field should NOT include a query string
pub payment_link: String,
/// To apply benefits to user accounts, you should then go into the Stripe developer
/// "workbench" and create a new webhook. The webhook needs the scopes:
/// `invoice.payment_succeeded`, `customer.subscription.deleted`, `checkout.session.completed`.
///
/// The webhook's destination address should be `{your server origin}/api/v1/service_hooks/stripe`.
///
/// The signing secret can be found on the right after you have created the webhook.
pub webhook_signing_secret: String,
/// The URL of your customer billing portal.
///
/// <https://docs.stripe.com/no-code/customer-portal>
pub billing_portal_url: String,
}
/// Configuration file
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Config {
@ -224,6 +257,8 @@ pub struct Config {
/// into every HTML template. They support access to template fields like `{{ user }}`.
#[serde(default)]
pub html_footer_path: String,
#[serde(default)]
pub stripe: Option<StripeConfig>,
}
fn default_name() -> String {
@ -311,6 +346,7 @@ impl Default for Config {
town_square: 0,
connections: default_connections(),
html_footer_path: String::new(),
stripe: None,
}
}
}