Skip to content

Commit

Permalink
Merge pull request #52 from BitcoinMitchell/return-secret
Browse files Browse the repository at this point in the history
Added WebhookCreated for `createWebhook`
  • Loading branch information
ndeet authored Feb 14, 2022
2 parents 8585486 + 946779b commit f6fa7ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Client/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function redeliverDelivery(string $storeId, string $webhookId, string $de
}
}

public function createWebhook(string $storeId, string $url, ?array $specificEvents, ?string $secret): \BTCPayServer\Result\Webhook
public function createWebhook(string $storeId, string $url, ?array $specificEvents, ?string $secret): \BTCPayServer\Result\WebhookCreated
{
$data = [
'enabled' => true,
Expand Down Expand Up @@ -152,7 +152,7 @@ public function createWebhook(string $storeId, string $url, ?array $specificEven

if ($response->getStatus() === 200) {
$data = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);
return new \BTCPayServer\Result\Webhook($data);
return new \BTCPayServer\Result\WebhookCreated($data);
} else {
throw $this->getExceptionByStatusCode($method, $url, $response);
}
Expand Down
14 changes: 14 additions & 0 deletions src/Result/WebhookCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace BTCPayServer\Result;

class WebhookCreated extends Webhook
{
public function getSecret(): string
{
$data = $this->getData();
return $data['secret'];
}
}

0 comments on commit f6fa7ae

Please sign in to comment.