Skip to content

Commit

Permalink
Merge pull request #817 from laravel/fix-find-method
Browse files Browse the repository at this point in the history
[10.x] Properly return null for find methods
  • Loading branch information
taylorotwell authored Nov 11, 2019
2 parents 7ab823d + b982bf9 commit 55eae2a
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 55eae2a

Please sign in to comment.