feat(labrinth): quarterly billing support (#3714)
This commit is contained in:
parent
f52d020a3c
commit
be37f077d3
@ -49,6 +49,7 @@ pub enum Price {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum PriceDuration {
|
pub enum PriceDuration {
|
||||||
Monthly,
|
Monthly,
|
||||||
|
Quarterly,
|
||||||
Yearly,
|
Yearly,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ impl PriceDuration {
|
|||||||
pub fn duration(&self) -> chrono::Duration {
|
pub fn duration(&self) -> chrono::Duration {
|
||||||
match self {
|
match self {
|
||||||
PriceDuration::Monthly => chrono::Duration::days(30),
|
PriceDuration::Monthly => chrono::Duration::days(30),
|
||||||
|
PriceDuration::Quarterly => chrono::Duration::days(90),
|
||||||
PriceDuration::Yearly => chrono::Duration::days(365),
|
PriceDuration::Yearly => chrono::Duration::days(365),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,19 +65,27 @@ impl PriceDuration {
|
|||||||
pub fn from_string(string: &str) -> PriceDuration {
|
pub fn from_string(string: &str) -> PriceDuration {
|
||||||
match string {
|
match string {
|
||||||
"monthly" => PriceDuration::Monthly,
|
"monthly" => PriceDuration::Monthly,
|
||||||
|
"quarterly" => PriceDuration::Quarterly,
|
||||||
"yearly" => PriceDuration::Yearly,
|
"yearly" => PriceDuration::Yearly,
|
||||||
_ => PriceDuration::Monthly,
|
_ => PriceDuration::Monthly,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_str(&self) -> &'static str {
|
pub fn as_str(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
PriceDuration::Monthly => "monthly",
|
PriceDuration::Monthly => "monthly",
|
||||||
|
PriceDuration::Quarterly => "quarterly",
|
||||||
PriceDuration::Yearly => "yearly",
|
PriceDuration::Yearly => "yearly",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterator() -> impl Iterator<Item = PriceDuration> {
|
pub fn iterator() -> impl Iterator<Item = PriceDuration> {
|
||||||
vec![PriceDuration::Monthly, PriceDuration::Yearly].into_iter()
|
vec![
|
||||||
|
PriceDuration::Monthly,
|
||||||
|
PriceDuration::Quarterly,
|
||||||
|
PriceDuration::Yearly,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1856,6 +1856,7 @@ pub async fn stripe_webhook(
|
|||||||
"source": source,
|
"source": source,
|
||||||
"payment_interval": metadata.charge_item.subscription_interval.map(|x| match x {
|
"payment_interval": metadata.charge_item.subscription_interval.map(|x| match x {
|
||||||
PriceDuration::Monthly => 1,
|
PriceDuration::Monthly => 1,
|
||||||
|
PriceDuration::Quarterly => 3,
|
||||||
PriceDuration::Yearly => 12,
|
PriceDuration::Yearly => 12,
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user