Purchases for admins only until the opening; brand images for Stripe
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user