arlyon / async-stripe

Async (and blocking!) Rust bindings for the Stripe API
https://payments.rs
Apache License 2.0
418 stars 122 forks source link

Error when constructing event #499

Closed vincent-thomas closed 5 months ago

vincent-thomas commented 5 months ago

Describe the bug

When constructing the webhook event it something happens with the body so every event fails.

To Reproduce

This code

  let payload_str = std::str::from_utf8(&payload).unwrap();
  let stripe_signature = get_header(&req, "Stripe-Signature").unwrap_or_default();
  let stripe_secret_key = c.config.get_stripe_webhook_secret().await;
  let event = match Webhook::construct_event(payload_str, stripe_signature, &stripe_secret_key) {
    Ok(event) => event,
    Err(e) => {
      eprintln!("Error constructing event: {:?} {:?}", e, payload_str);
      return Ok(());
    }
  };

Every single event it goes to the Err and prints error

Error constructing event: BadParse(Error("unknown variant `self`, expected `account` or `self_`", line: 133, column: 3))

Expected behavior

It parses the event like it should

Code snippets

No response

OS

Not relevant

Rust version

1.77.0-nightly - but not relevant

Library version

0.31.0

API version

2023-10-16

Additional context

No response

augustoccesar commented 5 months ago

I believe this is related to https://github.com/arlyon/async-stripe/pull/490, so should get fixed once that gets merged.