Purchases for admins only until the opening; brand images for Stripe
CI / test (push) Successful in 1m22s
CI / build (push) Successful in 7m0s
CI / deploy (push) Skipped

PURCHASES_OPEN (default false) keeps Stripe purchases to admins, also with
a live key, so nobody types a real card before the opening.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-20 06:57:00 +00:00
co-authored by Claude Opus 5.5
parent 42a982010d
commit d9e71ed349
13 changed files with 76 additions and 11 deletions
+18
View File
@@ -2375,6 +2375,7 @@ async fn stripe_test_mode_is_for_admins_only(pool: PgPool) {
let r = app.get("/v1/config", None).await;
assert_eq!(r.body["payments"], "stripe");
assert_eq!(r.body["payments_test"], true);
assert_eq!(r.body["payments_admins_only"], true);
let anna = app.register("anna@example.com", "Anna").await;
let r = app.post("/v1/payments/checkout", Some(&anna), json!({"package": "single"})).await;
assert_eq!(r.status, StatusCode::FORBIDDEN);
@@ -2383,3 +2384,20 @@ async fn stripe_test_mode_is_for_admins_only(pool: PgPool) {
let r = app.post("/v1/payments/checkout", Some(&admin), json!({"package": "single"})).await;
assert_eq!(r.body["error"]["code"], "payment_unavailable", "{}", r.body);
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn stripe_purchases_wait_for_the_opening(pool: PgPool) {
let app = TestApp::with_config(pool, |c| {
with_stripe(c, "sk_live_fake");
c.purchases_open = false;
})
.await;
let r = app.get("/v1/config", None).await;
assert_eq!((&r.body["payments_test"], &r.body["payments_admins_only"]), (&json!(false), &json!(true)));
let anna = app.register("anna@example.com", "Anna").await;
let r = app.post("/v1/payments/checkout", Some(&anna), json!({"package": "single"})).await;
assert_eq!(r.status, StatusCode::FORBIDDEN);
let admin = app.register("admin@example.com", "Admin").await;
let r = app.post("/v1/payments/checkout", Some(&admin), json!({"package": "single"})).await;
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
}