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

Issue with findInvoice() returning with an undefined variable: stripeInvoice #815

Closed
u01jmg3 opened this issue Nov 7, 2019 · 1 comment · Fixed by #817
Closed

Issue with findInvoice() returning with an undefined variable: stripeInvoice #815

u01jmg3 opened this issue Nov 7, 2019 · 1 comment · Fixed by #817
Labels

Comments

@u01jmg3
Copy link
Contributor

u01jmg3 commented Nov 7, 2019

  • Cashier Version: 10.4.0
  • Laravel Version: 6.5.0
  • PHP Version: 7.1.26

Description:

If the invoice is not retrieved from Stripe for whatever reason, the variable $stripeInvoice will not be set.

This results in return new Invoice($this, $stripeInvoice); failing.

Perhaps there should be a check in place (e.g. if (!isset($stripeInvoice)) { return null; }) to prevent an undefined variable error. Happy to put a PR together.

/**
 * Find an invoice by ID.
 *
 * @param  string  $id
 * @return \Laravel\Cashier\Invoice|null
 */
public function findInvoice($id)
{
    try {
        $stripeInvoice = StripeInvoice::retrieve(
            $id, $this->stripeOptions()
        );
    } catch (Exception $exception) {
        //
    }

    return new Invoice($this, $stripeInvoice);
}
@driesvints
Copy link
Member

Thanks! I've sent in a PR here: #817

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

Successfully merging a pull request may close this issue.

2 participants