Payments/subscriptions support (#943)

* [wip] Payments/subscriptions support

* finish

* working payment flow

* finish subscriptions, lint, clippy, etc

* docker compose
This commit is contained in:
Geometrically
2024-08-14 17:14:52 -07:00
committed by GitHub
parent 60edbcd5f0
commit 1d0d8d7fbe
71 changed files with 4009 additions and 1101 deletions

View File

@@ -32,6 +32,7 @@ pub struct User {
pub paypal_country: Option<String>,
pub paypal_email: Option<String>,
pub venmo_handle: Option<String>,
pub stripe_customer_id: Option<String>,
pub totp_secret: Option<String>,
@@ -60,13 +61,13 @@ impl User {
avatar_url, bio, created,
github_id, discord_id, gitlab_id, google_id, steam_id, microsoft_id,
email_verified, password, paypal_id, paypal_country, paypal_email,
venmo_handle
venmo_handle, stripe_customer_id
)
VALUES (
$1, $2, $3, $4, $5,
$6, $7,
$8, $9, $10, $11, $12, $13,
$14, $15, $16, $17, $18, $19
$14, $15, $16, $17, $18, $19, $20
)
",
self.id as UserId,
@@ -87,7 +88,8 @@ impl User {
self.paypal_id,
self.paypal_country,
self.paypal_email,
self.venmo_handle
self.venmo_handle,
self.stripe_customer_id
)
.execute(&mut **transaction)
.await?;
@@ -170,7 +172,7 @@ impl User {
balance,
github_id, discord_id, gitlab_id, google_id, steam_id, microsoft_id,
email_verified, password, totp_secret, paypal_id, paypal_country, paypal_email,
venmo_handle
venmo_handle, stripe_customer_id
FROM users
WHERE id = ANY($1) OR LOWER(username) = ANY($2)
",
@@ -202,6 +204,7 @@ impl User {
paypal_country: u.paypal_country,
paypal_email: u.paypal_email,
venmo_handle: u.venmo_handle,
stripe_customer_id: u.stripe_customer_id,
totp_secret: u.totp_secret,
};
@@ -264,8 +267,8 @@ impl User {
",
user_id as UserId,
)
.fetch_many(exec)
.try_filter_map(|e| async { Ok(e.right().map(|m| ProjectId(m.id))) })
.fetch(exec)
.map_ok(|m| ProjectId(m.id))
.try_collect::<Vec<ProjectId>>()
.await?;
@@ -293,8 +296,8 @@ impl User {
",
user_id as UserId,
)
.fetch_many(exec)
.try_filter_map(|e| async { Ok(e.right().map(|m| OrganizationId(m.id))) })
.fetch(exec)
.map_ok(|m| OrganizationId(m.id))
.try_collect::<Vec<OrganizationId>>()
.await?;
@@ -317,8 +320,8 @@ impl User {
",
user_id as UserId,
)
.fetch_many(exec)
.try_filter_map(|e| async { Ok(e.right().map(|m| CollectionId(m.id))) })
.fetch(exec)
.map_ok(|m| CollectionId(m.id))
.try_collect::<Vec<CollectionId>>()
.await?;
@@ -341,8 +344,8 @@ impl User {
",
user_id as UserId,
)
.fetch_many(exec)
.try_filter_map(|e| async { Ok(e.right().map(|m| to_base62(m.code as u64))) })
.fetch(exec)
.map_ok(|m| to_base62(m.code as u64))
.try_collect::<Vec<String>>()
.await?;
@@ -430,8 +433,8 @@ impl User {
",
id as UserId,
)
.fetch_many(&mut **transaction)
.try_filter_map(|e| async { Ok(e.right().map(|m| m.id)) })
.fetch(&mut **transaction)
.map_ok(|m| m.id)
.try_collect::<Vec<i64>>()
.await?;
@@ -463,8 +466,8 @@ impl User {
",
id as UserId,
)
.fetch_many(&mut **transaction)
.try_filter_map(|e| async { Ok(e.right().map(|x| CollectionId(x.id))) })
.fetch(&mut **transaction)
.map_ok(|x| CollectionId(x.id))
.try_collect::<Vec<_>>()
.await?;
@@ -481,8 +484,8 @@ impl User {
",
id as UserId,
)
.fetch_many(&mut **transaction)
.try_filter_map(|e| async { Ok(e.right().map(|x| ThreadId(x.id))) })
.fetch(&mut **transaction)
.map_ok(|x| ThreadId(x.id))
.try_collect::<Vec<_>>()
.await?;