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

delete method of PaymentMethod class returns void instead of \Stripe\PaymentMethod #1568

Closed
jwjenkin opened this issue Sep 15, 2023 · 2 comments

Comments

@jwjenkin
Copy link
Contributor

jwjenkin commented Sep 15, 2023

Cashier Stripe Version

12.17.2

Laravel Version

8.83.27

PHP Version

8.1.17

Database Driver & Version

No response

Description

According to the docstring of PaymentMethod::delete, calling the function will return \Stripe\PaymentMethod regardless of result. However, the ManagesPaymentMethods::removePaymentMethod returns to void, leading to issues if you are validating the result of the delete function call.

This appears to still affect the latest Cashier version, as looking at the source code still has it in there.
https://github.com/laravel/cashier-stripe/blob/14.x/src/PaymentMethod.php#L51
https://github.com/laravel/cashier-stripe/blob/14.x/src/Concerns/ManagesPaymentMethods.php#L115

I suppose there are a few options:

  • change the docstring of PaymentMethod::delete to have @return void
  • change ManagesPaymentMethods::removePaymentMethod to return the PaymentMethod
  • change ManagesPaymentMethods::removePaymentMethod to return a bool result and change the docstring of PaymentMethod::delete to @return bool

Steps To Reproduce

$ php artisan tinker
Psy Shell v0.11.9 (PHP 8.1.17 — cli) by Justin Hileman
> $user = User::first();
[!] Aliasing 'User' to 'App\Models\User' for this Tinker session.
= App\Models\User {#5488
...
}

> $user->paymentMethods()->first();
= Laravel\Cashier\PaymentMethod {#5545}

> $user->paymentMethods()->first()->delete();
= null

> $user->paymentMethods()->first();
= null
@driesvints
Copy link
Member

Hey there,

Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? If so, please open up a new issue and we'll help you out.

Thanks!

@jwjenkin
Copy link
Contributor Author

Howdy!

The "problem" should still exist, as the docs that cause the confusion are still in the latest 14.x blobs:
https://github.com/laravel/cashier-stripe/blob/14.x/src/PaymentMethod.php#L51
https://github.com/laravel/cashier-stripe/blob/14.x/src/Concerns/ManagesPaymentMethods.php#L115

Main point in here:
It isn't necessarily a bug in code, it's a documentation issue that causes confusion.

Thanks!

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

No branches or pull requests

2 participants