Promo codes; purchases off in production
Admins make promo codes for a package (Admin → Promókódok: batch, note, copy all), list them filtered (unused by default, used, revoked; by package; by code, note or redeemer) and withdraw unused ones. A logged-in user redeems a code once (header link, /bevaltas?kod=... prefilled, packages page, and the analysis and question offers point there) and gets the package as an order with source 'promo'. Failed redemptions are rate limited. Production purchases are off: MOCK_PAYMENTS now defaults to false in the deploy compose, so package cards say 'Hamarosan'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -184,6 +184,8 @@ impl Package {
|
||||
pub enum Source {
|
||||
Admin,
|
||||
Mock,
|
||||
/// A redeemed promo code.
|
||||
Promo,
|
||||
}
|
||||
|
||||
impl Source {
|
||||
@@ -191,6 +193,7 @@ impl Source {
|
||||
match self {
|
||||
Source::Admin => "admin",
|
||||
Source::Mock => "mock",
|
||||
Source::Promo => "promo",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,7 +209,7 @@ pub async fn grant(
|
||||
) -> Result<Uuid, ApiError> {
|
||||
let order = Uuid::now_v7();
|
||||
let price = match source {
|
||||
Source::Admin => 0,
|
||||
Source::Admin | Source::Promo => 0,
|
||||
Source::Mock => package.price_huf,
|
||||
};
|
||||
sqlx::query(
|
||||
|
||||
Reference in New Issue
Block a user