-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
receiptOptions
& additionalSearchTerms
to createInvoice
- Loading branch information
1 parent
f4fac20
commit 21814f3
Showing
2 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BTCPayServer\Client; | ||
|
||
/** | ||
* Additional settings to customize the public receipt | ||
*/ | ||
class InvoiceReceiptOptions | ||
{ | ||
/** @var bool */ | ||
protected $enabled; | ||
|
||
/** @var bool */ | ||
protected $showQR; | ||
|
||
/** @var bool */ | ||
protected $showPayments; | ||
|
||
public static function create( | ||
?bool $enabled, | ||
?bool $showQR, | ||
?bool $showPayments, | ||
) { | ||
$options = new InvoiceReceiptOptions(); | ||
$options->enabled = $enabled; | ||
$options->showQR = $showQR ?? null; | ||
$options->showPayments = $showPayments; | ||
return $options; | ||
} | ||
|
||
public function isEnabled(): ?bool | ||
{ | ||
return $this->enabled; | ||
} | ||
|
||
|
||
public function setEnabled(?bool $enabled): self | ||
{ | ||
$this->enabled = $enabled; | ||
return $this; | ||
} | ||
|
||
public function showsQR(): ?bool | ||
{ | ||
return $this->showQR; | ||
} | ||
|
||
public function setShowQR(?bool $showQR): self | ||
{ | ||
$this->showQR = $showQR; | ||
return $this; | ||
} | ||
|
||
public function showsPayments(): ?bool | ||
{ | ||
return $this->showPayments; | ||
} | ||
|
||
public function setShowPayments(?bool $showPayments): self | ||
{ | ||
$this->showPayments = $showPayments; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Converts the whole object incl. protected and private properties to an array. | ||
*/ | ||
public function toArray(): array | ||
{ | ||
$array = []; | ||
$objAsArray = (array) $this; | ||
foreach ($objAsArray as $k => $v) { | ||
$separator = "\0"; | ||
$k = rtrim($k, $separator); | ||
|
||
$lastIndex = strrpos($k, $separator); | ||
if ($lastIndex !== false) { | ||
$k = substr($k, $lastIndex + 1); | ||
} | ||
$array[$k] = $v; | ||
} | ||
|
||
return $array; | ||
} | ||
} |