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

[10.x] Properly return null for find methods #817

Merged
merged 1 commit into from
Nov 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public function upcomingInvoice()
*/
public function findInvoice($id)
{
$stripeInvoice = null;

try {
$stripeInvoice = StripeInvoice::retrieve(
$id, $this->stripeOptions()
Expand All @@ -283,7 +285,7 @@ public function findInvoice($id)
//
}

return new Invoice($this, $stripeInvoice);
return $stripeInvoice ? new Invoice($this, $stripeInvoice) : null;
}

/**
Expand Down Expand Up @@ -608,17 +610,19 @@ public function deletePaymentMethods()
* Find a PaymentMethod by ID.
*
* @param string $paymentMethod
* @return \Laravel\Cashier\PaymentMethod
* @return \Laravel\Cashier\PaymentMethod|null
*/
public function findPaymentMethod($paymentMethod)
{
$stripePaymentMethod = null;

try {
$stripePaymentMethod = $this->resolveStripePaymentMethod($paymentMethod);
} catch (Exception $exception) {
//
}

return new PaymentMethod($this, $stripePaymentMethod);
return $stripePaymentMethod ? new PaymentMethod($this, $stripePaymentMethod) : null;
}

/**
Expand Down