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

[9.x] Add paymentRequired helper to Http Client response #45698

Closed
wants to merge 2 commits into from
Closed

[9.x] Add paymentRequired helper to Http Client response #45698

wants to merge 2 commits into from

Conversation

tjardoo
Copy link

@tjardoo tjardoo commented Jan 18, 2023

This PR adds the paymentRequired to the Http Client Response class. The 402 error page was just merged into the framework [9.x] Add 402 exception view #45682

Currently we have to use the following code to check if a response is 402 Payment Required.

$response = Http::get('https://laravel.com');

if ($response->status() === 402) {
    doSomething();
}

With this PR you can do the following, which is a bit cleaner.

$response = Http::get('https://laravel.com');

if ($response->paymentRequired()) {
    doSomething();
}

Thanks!

@taylorotwell
Copy link
Member

Just checking the status is fine.

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

Successfully merging this pull request may close these issues.

2 participants