| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
mod checkout; |
| 6 |
mod connect; |
| 7 |
mod webhook; |
| 8 |
mod webhook_v2; |
| 9 |
|
| 10 |
pub(crate) use checkout::grant_bundle_items; |
| 11 |
pub(crate) use webhook::process_webhook_event; |
| 12 |
|
| 13 |
use axum::routing::get; |
| 14 |
|
| 15 |
use crate::{ |
| 16 |
csrf::{post_csrf, post_csrf_manual, post_csrf_skip, CsrfRouter}, |
| 17 |
AppState, |
| 18 |
}; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
const STRIPE_SESSION_SKIP: &str = |
| 25 |
"Stripe Checkout Session constructor — no mutation until webhook"; |
| 26 |
|
| 27 |
|
| 28 |
pub fn stripe_routes() -> CsrfRouter<AppState> { |
| 29 |
CsrfRouter::new() |
| 30 |
|
| 31 |
.route_get("/stripe/connect", get(connect::stripe_connect_disclaimer)) |
| 32 |
.route("/stripe/connect/proceed", post_csrf(connect::stripe_connect_proceed)) |
| 33 |
.route_get("/stripe/connect/return", get(connect::stripe_connect_return)) |
| 34 |
.route_get("/stripe/connect/refresh", get(connect::stripe_connect_refresh)) |
| 35 |
|
| 36 |
.route("/stripe/fan-plus", post_csrf(checkout::create_fan_plus_checkout)) |
| 37 |
.route("/stripe/fan-plus/cancel", post_csrf(checkout::cancel_fan_plus)) |
| 38 |
.route("/stripe/fan-plus/resume", post_csrf(checkout::resume_fan_plus)) |
| 39 |
.route("/stripe/billing-portal", post_csrf(checkout::open_billing_portal)) |
| 40 |
.route("/stripe/creator-tier", post_csrf(checkout::create_creator_tier_checkout)) |
| 41 |
.route("/stripe/checkout/{item_id}", post_csrf_skip(STRIPE_SESSION_SKIP, checkout::create_checkout)) |
| 42 |
.route("/stripe/checkout/{item_id}/cancel-pending", post_csrf(checkout::cancel_pending_item_checkout)) |
| 43 |
.route("/stripe/checkout/project/{project_id}", post_csrf_skip(STRIPE_SESSION_SKIP, checkout::create_project_checkout)) |
| 44 |
.route("/stripe/subscribe/{tier_id}", post_csrf_skip(STRIPE_SESSION_SKIP, checkout::create_subscription_checkout)) |
| 45 |
.route("/stripe/checkout/tip/{recipient_id}", post_csrf_manual( |
| 46 |
"inserts pending_tip row before Stripe call — handler validates _csrf", |
| 47 |
checkout::create_tip_checkout, |
| 48 |
)) |
| 49 |
.route("/stripe/checkout/cart", post_csrf_skip(STRIPE_SESSION_SKIP, checkout::create_cart_checkout)) |
| 50 |
.route("/stripe/checkout/cart/all", post_csrf_skip(STRIPE_SESSION_SKIP, checkout::create_cart_checkout_all)) |
| 51 |
.route_get("/stripe/success", get(checkout::checkout_success)) |
| 52 |
.route_get("/stripe/cancel", get(checkout::checkout_cancel)) |
| 53 |
|
| 54 |
.route("/stripe/webhook", post_csrf_skip("webhook: stripe signature verified in handler", webhook::webhook)) |
| 55 |
.route("/stripe/webhook/v2", post_csrf_skip("webhook: stripe signature verified in handler", webhook_v2::webhook_v2)) |
| 56 |
} |
| 57 |
|