-
-
Notifications
You must be signed in to change notification settings - Fork 173
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
In my webhook, I serialize and push the stripe events to a task queue to process them later and to return 200 to Stripe immediately. Then a worker picks up the task, deserialise the event and process it.
Since events are both verified and deserialised in do_construct_event, they are de/serialized twice
Describe the solution you'd like
We can separate verification and deserialisation.
struct VerifiedEventPayload(pub String); // name can change
impl VerifiedEventPayload {
fn parse_payload(self) -> Result<Event, WebhookError> {
// Same as `parse_payload` in async-stripe-webhook/src/webhook.rs
}
}
// in webhook.rs
fn verify_event(
self,
payload: String,
sig: &str,
secret: &str,
) -> Result<VerifiedEventPayload, WebhookError>{
// Same as `do_construct_event` except the last line `parse_payload`
}do_construct_event will run verify_event then parse_payload. We need to have construct_event and construct_event_with_timestamp equivalents also. I can open a PR if you would like
Describe alternatives you've considered
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request