arlyon / async-stripe

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

API error caused serialization issue #384

Closed kurtbuilds closed 5 months ago

kurtbuilds commented 1 year ago

Describe the bug

I made a request to POST /v1/transfers and it errored beacuse of insufficient capabilities on the account.

{
  "error": {
    "code": "insufficient_capabilities_for_transfer",
    "message": "Your destination account needs to have at least one of the following capabilities enabled: transfers, crypto_transfers, legacy_payments",
    "request_log_url": "https://dashboard.stripe.com/logs/req_nIhlutaV4amLEs?t=1685040634",
    "type": "invalid_request_error"
  }
}

is what the API gave back.

However, async-stripe doesn't deserialize that correctly, instead throwing an error with message "error serializing or deserializing a request".

To Reproduce

Make a request to POST /v1/transfers, transferring to an account without the capability for transfers.

Expected behavior

async-stripe handles the error returned from the Stripe API correctly, without throwing a deserialization error.

Code snippets

No response

OS

macos

Rust version

1.69

Library version

0.22.2

API version

2022-11-15

Additional context

No response

c1wren commented 1 year ago

I just starting having the same serialization error when I updated to the latest crate version the other day. I had to revert back to 0.19.0 to have this error go away.