Skip to content

Commit

Permalink
fix : added an error handler whether product creation from subscripti…
Browse files Browse the repository at this point in the history
…on helper was successful or not.
  • Loading branch information
otnansirk committed Feb 23, 2024
1 parent c24b181 commit 20d8187
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Traits/PayPalAPI/Subscriptions/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,18 @@ public function addProduct(string $name, string $description, string $type, stri

$request_id = Str::random();

$this->product = $this->createProduct([
$product = $this->createProduct([
'name' => $name,
'description' => $description,
'type' => $type,
'category' => $category,
], $request_id);

if ($error = data_get($product, 'error', false)) {
throw new \RuntimeException(data_get($error, 'details.0.description', 'Failed to add product'));
}
$this->product = $product;

return $this;
}

Expand Down

0 comments on commit 20d8187

Please sign in to comment.