stripe_pay_server/webhook/struct.rs
1use super::*;
2
3/// A webhook payload whose signature Stripe vouches for.
4///
5/// The struct keeps the three values verification actually needs, so a
6/// handler never has to re-parse the header once this is built.
7///
8/// Read accessors are generated by `#[derive(Getter)]`. The digest is
9/// only meaningful together with the payload and timestamp it was
10/// computed over, so it is exposed read-only: a caller that could
11/// replace the signature independently of the other two could make a
12/// forged event verify against its own digest.
13#[derive(Clone, Debug, Eq, Getter, PartialEq)]
14pub struct WebhookEvent {
15 /// The exact bytes Stripe signed.
16 pub(super) payload: String,
17 /// The timestamp Stripe signed, in seconds since the epoch.
18 #[get(type(copy))]
19 pub(super) timestamp: i64,
20 /// The hex digest Stripe sent, without the `v1=` prefix.
21 pub(super) signature: String,
22}