Shared state
This commit is contained in:
parent
53fff3efaa
commit
15fa09430b
25 changed files with 174 additions and 215 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use axum::body::Bytes;
|
||||
use axum::extract::State;
|
||||
use axum::http::{HeaderMap, StatusCode};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use hmac::{Hmac, Mac};
|
||||
|
|
@ -8,7 +9,7 @@ use sha2::Sha256;
|
|||
use tracing::{info, warn};
|
||||
|
||||
use crate::pocketbase::auth_superuser;
|
||||
use crate::state::AppState;
|
||||
use crate::state::SharedState;
|
||||
|
||||
type HmacSha256 = Hmac<Sha256>;
|
||||
|
||||
|
|
@ -49,10 +50,11 @@ fn verify_signature(payload: &[u8], sig_header: &str, secret: &str) -> bool {
|
|||
/// Handle Stripe webhook events.
|
||||
/// On `checkout.session.completed`, updates the user's subscription to "licensed".
|
||||
pub async fn post_stripe_webhook(
|
||||
state: Arc<AppState>,
|
||||
State(shared): State<Arc<SharedState>>,
|
||||
headers: HeaderMap,
|
||||
body: Bytes,
|
||||
) -> Response {
|
||||
let state = shared.load_state();
|
||||
let webhook_secret = &state.stripe_webhook_secret;
|
||||
|
||||
let sig_header = match headers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue