Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advice_code not defined in StripeError (incorrect release notes for v16.5.0) #1815

Closed
LeonMelis opened this issue Feb 12, 2025 · 5 comments
Closed

Comments

@LeonMelis
Copy link
Contributor

Describe the bug

The v16.5.0 release notes states that support for advice_code in the StripeError object is added:

Add support for advice_code on StripeError

However, it does not seem to be actually added. In fact, searching for advice_code in the entire repository only yields one occurrence: the release notes of 16.5.0.

Also note that the release notes mention StripeError, though in this PHP lib the class is known as ErrorObject.

See: https://github.com/stripe/stripe-php/releases/tag/v16.5.0

This field should be added to the PHPDoc of the ErrorObject class, so IDEs and linters can use this.

While we are at it: it would be really helpful to define the $last_payment_error in PaymentIntent.php as being an ErrorObject, instead of a generic StripeObject, again for code completion and linters.

To Reproduce

  • Fetch version 16.5.0 (or newer, at least up to 05c7c3a)
  • Notice how /lib/ErrorObject.php does not define the advice_code field in the class description (PHPDoc)
  • Notice how in the entire project advice_code is only mentioned once: in the release notes of v16.5.0

Expected behavior

The field advice_code should be defined in the PHPDoc of class ErrorObject in lib/ErrorObject.php

And if possible, the field $last_payment_error in PaymentIntent.php should be defined as an ErrorObject instead of a generic StripeObject

Code snippets

OS

n/a

PHP version

n/a

Library version

stripe-php v16.5.0

API version

n/a

Additional context

No response

@LeonMelis LeonMelis added the bug label Feb 12, 2025
@jar-stripe
Copy link
Contributor

Hi @LeonMelis thanks for the report, and very sorry for the inconvenience here! Let me look into this and see what is going on. Will be back in touch soon!

@jar-stripe
Copy link
Contributor

jar-stripe commented Mar 3, 2025

Hi @LeonMelis , sorry for the delay in getting back to you here! It looks like this field was not supposed to be included in our changelog. We are fixing this (see #1819). Sorry again for the trouble here!

@jar-stripe
Copy link
Contributor

If you need access to advice_code, it may be present on the ErrorObject you receive back from a failed SDK call. It won't be available in e.g. the IDE linters and code completion but you should be able to access it on the error object by field name, or via the values() method.

@LeonMelis
Copy link
Contributor Author

I understand that I can access that field, but it would be better to describe the field annotations of the ErrorObject class.That way you can use auto-complete and linters. It'll help developers working with Stripe-PHP tremendously.

I'm not sure whether the advice_code field is in all supported API versions, but if it is then please add the advice_code as @property in the doc block for the ErrorObject class. It's low hanging fruit and developers will thank you for it.

Same goes for correctly annotating the $last_payment_error property of the PaymentIntent class. It should be annotated as ErrorObject and not as a generic StripeObject instance.

@jar-stripe
Copy link
Contributor

Hi @LeonMelis totally understand! The GA version of stripe-php does not have type hints like you are describing, but our beta SDK does: #1787. We definitely understand the value of having type annotations here, and we're working to make that happen; in this case, it was an error in the release notes because we usually do not generate changelog entries for things that do not produce a tangible change in the SDK experience.

Thanks again for your feedback here, and please jump on that related issue if you want to try out the php SDK with type hints!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants