forked from didirus/AstralRinth
Move charges to DB + fix subscription recurring payments (#971)
* Move charges to DB + fix subscription recurring payments * Finish most + pyro integration * Finish billing * Run prepare * Fix intervals * Fix clippy * Remove unused test
This commit is contained in:
@@ -256,6 +256,14 @@ generate_ids!(
|
||||
UserSubscriptionId
|
||||
);
|
||||
|
||||
generate_ids!(
|
||||
pub generate_charge_id,
|
||||
ChargeId,
|
||||
8,
|
||||
"SELECT EXISTS(SELECT 1 FROM charges WHERE id=$1)",
|
||||
ChargeId
|
||||
);
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Type, Hash, Serialize, Deserialize)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct UserId(pub i64);
|
||||
@@ -386,6 +394,10 @@ pub struct ProductPriceId(pub i64);
|
||||
#[sqlx(transparent)]
|
||||
pub struct UserSubscriptionId(pub i64);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Type, Serialize, Deserialize, Eq, PartialEq, Hash)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct ChargeId(pub i64);
|
||||
|
||||
use crate::models::ids;
|
||||
|
||||
impl From<ids::ProjectId> for ProjectId {
|
||||
@@ -571,3 +583,14 @@ impl From<UserSubscriptionId> for ids::UserSubscriptionId {
|
||||
ids::UserSubscriptionId(id.0 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ids::ChargeId> for ChargeId {
|
||||
fn from(id: ids::ChargeId) -> Self {
|
||||
ChargeId(id.0 as i64)
|
||||
}
|
||||
}
|
||||
impl From<ChargeId> for ids::ChargeId {
|
||||
fn from(id: ChargeId) -> Self {
|
||||
ids::ChargeId(id.0 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user