Invoice every payment again, test payments included
CI / test (push) Successful in 1m27s
CI / build (push) Successful in 4m36s
CI / deploy (push) Skipped

The Billingo account is a test one for now, and the whole flow is being
tested; skipping test payments was not asked for. Stripe and Billingo
go live together at 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 10:00:48 +00:00
co-authored by Claude Opus 5.5
parent e4905ec5f1
commit e741f9b491
3 changed files with 13 additions and 39 deletions
+5 -26
View File
@@ -2475,35 +2475,14 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
.unwrap();
assert_eq!((name.as_str(), tax_type.as_str()), ("Anna Teszt", "NO_TAX_NUMBER"));
// A test payment grants the package but gets no invoice (Billingo's are real).
sqlx::query(
"INSERT INTO stripe_checkouts (id, user_id, package, price_huf, live) \
SELECT 'cs_test_1', id, 'single', 2000, false FROM users WHERE email = 'anna@example.com'",
)
.execute(&app.pool)
.await
.unwrap();
let test = json!({"type": "checkout.session.completed",
"data": {"object": {"id": "cs_test_1", "payment_status": "paid", "amount_total": 200000, "currency": "huf"}}});
let sig = crate::stripe::sign("whsec_fake", test.to_string().as_bytes(), now);
let r = app.call_with("POST", "/v1/payments/stripe/webhook", None, Some(test), &[("stripe-signature", &sig)]).await;
assert_eq!(r.status, StatusCode::OK);
assert_eq!(stripe_orders(&app.pool, "anna@example.com").await.len(), 3);
let (invoices,): (i64,) = sqlx::query_as("SELECT count(*) FROM invoices WHERE checkout_id = 'cs_test_1'")
.fetch_one(&app.pool)
.await
.unwrap();
assert_eq!(invoices, 0);
// Deleting the account keeps the payments (accounting law).
let r = app.call("DELETE", "/v1/me", Some(&anna), Some(json!({"confirm": "DELETE"}))).await;
assert!(r.status.is_success(), "{}", r.body);
let (kept,): (i64,) = sqlx::query_as(
"SELECT count(*) FROM stripe_checkouts WHERE user_id IS NULL AND completed_at IS NOT NULL AND live",
)
.fetch_one(&app.pool)
.await
.unwrap();
let (kept,): (i64,) =
sqlx::query_as("SELECT count(*) FROM stripe_checkouts WHERE user_id IS NULL AND completed_at IS NOT NULL")
.fetch_one(&app.pool)
.await
.unwrap();
assert_eq!(kept, 2);
let (kept,): (i64,) =
sqlx::query_as("SELECT count(*) FROM invoices WHERE user_id IS NULL").fetch_one(&app.pool).await.unwrap();