collab: Add endpoint for initiating a billing subscription (#15452)

This PR adds a new `POST /billing/subscriptions` endpoint that can be
used to initiate a billing subscription.

The endpoint will use the provided `github_user_id` to look up a user,
generate a Stripe Checkout session, and then return the URL.

The caller would then redirect the user to the URL to initiate the
checkout flow.

Here's an example of how to call it:

```sh
curl -X POST "http://localhost:8080/billing/subscriptions" \
     -H "Authorization: <ADMIN_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"github_user_id": 12345}'
```

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2024-07-29 17:31:36 -04:00
committed by GitHub
parent 8bb34fd93e
commit e15d59c445
9 changed files with 258 additions and 0 deletions
+3
View File
@@ -637,6 +637,7 @@ impl TestServer {
db: test_db.db().clone(),
live_kit_client: Some(Arc::new(live_kit_test_server.create_api_client())),
blob_store_client: None,
stripe_client: None,
rate_limiter: Arc::new(RateLimiter::new(test_db.db().clone())),
executor,
clickhouse_client: None,
@@ -669,6 +670,8 @@ impl TestServer {
auto_join_channel_id: None,
migrations_path: None,
seed_path: None,
stripe_api_key: None,
stripe_price_id: None,
supermaven_admin_api_key: None,
},
})