arlyon / async-stripe

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

Parse paypal events in stripe webhooks #430

Open Overdash opened 10 months ago

Overdash commented 10 months ago

Describe the bug

When I test a failed PayPal transaction, the library fails to construct the Webhook Event that's triggered. I get the following:

Err(
    BadParse(
        Error("unknown variant `paypal`, expected one of `acss_debit`, `affirm`, `afterpay_clearpay`, `alipay`, `au_becs_debit`, `bacs_debit`, `bancontact`, `blik`, `boleto`, `card`, `card_present`, `customer_balance`, `eps`, `fpx`, `giropay`, `grabpay`, `ideal`, `interac_present`, `klarna`, `konbini`, `link`, `oxxo`, `p24`, `paynow`, `pix`, `promptpay`, `sepa_debit`, `sofort`, `us_bank_account`, `wechat_pay`", line: 228, column: 3),
    ),
)

Weirdly this works when the payment is successful!

To Reproduce

  1. Setup Webhook environment locally. Use Webhook::construct_event() to construct the event.
  2. Setup PayPal as a payment method on Stripe's dashboard (Test mode!)
  3. Initiate a PaymentIntent - use Stripe Payment Element for simplicity
  4. Try fund the payment the payment via PayPal
  5. Click Fail Test Payment on the test payment page
  6. Observe webhook logs - Webhook::construct_event should produce a Err(BadParse(...)) as above

Expected behavior

PayPal should be recognised as a variant! And the webhooks should be constructed as any other valid variant.

Code snippets

No response

OS

Windows 10

Rust version

1.70.0

Library version

0.22.2

API version

2022-11-15

Additional context

Successful PayPal attempts work correctly

arlyon commented 9 months ago

Hello, sorry for the delay in replies. Stripe does not to my knowledge publish a list of all the possible webhook formats in an easy-to-consume manner so this is currently hand-written and the paypal event has not been added.

I am marking this as a feature request for now.

Overdash commented 9 months ago

No need to apologise. Thanks for this :).