arlyon / async-stripe

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

No support for billing_portal webhook events #455

Closed TheBuilderJR closed 5 months ago

TheBuilderJR commented 9 months ago

Describe the bug

I get the following error

Dec 06 03:52:39 ubuntu-4gb-hel1-1 llm-templates[68831]:     Error("unknown variant `billing_portal.session`, expected one of `account`, `capability`, `application`, `application_fee`, `fee_refund`, `balance`, `bank_account`, `billing_portal.configuration`, `card`, `charge`, `checkout.session`, `coupon`, `customer`, `discount`, `dispute`, `file`, `invoice`, `invoiceitem`, `issuing.authorization`, `issuing.card`, `issuing.cardholder`, `issuing.dispute`, `issuing.transaction`, `mandate`, `payment_intent`, `payment_link`, `payment_method`, `payout`, `person`, `plan`, `price`, `product`, `promotion_code`, `quote`, `refund`, `review`, `setup_intent`, `subscription`, `subscription_schedule`, `tax_id`, `tax_rate`, `test_helpers.test_clock`, `topup`, `transfer`", line: 9, column: 40),

in the following code

    match Webhook::construct_event(&payload.contents, stripe_signature.signature, &endpoint_secret) {
        Ok(event) => {
            if let Err(e) = process_stripe_event(&event, &mut connection) {
                eprintln!("Failed to process stripe event: {:?}", e);
                return Status::InternalServerError; // Log and handle processing error
            }
            Status::Ok
        }
        Err(e) => {
            dbg!(e);
            Status::BadRequest
        }
    }

To Reproduce

Have stripe send a billing portal webhook

Expected behavior

no Error

Code snippets

No response

OS

MacOS

Rust version

cargo 1.74.0-nightly (59596f0f3 2023-09-29)

Library version

0.26.0

API version

0.26.0

Additional context

No response

DirkRusche commented 3 months ago

I think this issue is still relevant. I just got the same error with version 0.37.0.

It looks like the default / #[serde(other)] is not working. According to the documentation of #[serde(other)] it is only for "[...] a unit variant inside of an internally tagged or adjacently tagged enum".