Refunds + Upgrading/Downgrading plans (#2983)

* Refunds + Upgrading/Downgrading plans

* Servers list route

* Finish, lint

* add GAM fee to payouts

* Sync payment intent id with stripe

* fix lint, update migrations

* Remove tauri generated files

* Register refund route

* fix refund bugs
This commit is contained in:
Geometrically
2024-12-06 19:37:17 -08:00
committed by GitHub
parent 2cfb637451
commit 2987f507fe
41 changed files with 1045 additions and 13604 deletions

View File

@@ -104,6 +104,29 @@ impl UserSubscriptionItem {
.collect::<Result<Vec<_>, serde_json::Error>>()?)
}
pub async fn get_all_servers(
status: Option<SubscriptionStatus>,
exec: impl sqlx::Executor<'_, Database = sqlx::Postgres>,
) -> Result<Vec<UserSubscriptionItem>, DatabaseError> {
let status = status.map(|x| x.as_str());
let results = select_user_subscriptions_with_predicate!(
r#"
INNER JOIN products_prices pp ON us.price_id = pp.id
INNER JOIN products p ON p.metadata @> '{"type": "pyro"}'
WHERE $1::text IS NULL OR us.status = $1::text
"#,
status
)
.fetch_all(exec)
.await?;
Ok(results
.into_iter()
.map(|r| r.try_into())
.collect::<Result<Vec<_>, serde_json::Error>>()?)
}
pub async fn upsert(
&self,
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,