Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion lightning-config.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
->setReceiver('default-receiver')
->setDescriptionTemplate('Pay to %s')
->setSuccessMessage('Payment received!')
->setInvoiceMemo('')
->setSendableRange(min: 100_000, max: 10_000_000_000)
->setCallbackUrl('localhost:8000/callback')
->addBackendsFile(getcwd() . DIRECTORY_SEPARATOR . 'nostr.json');
11 changes: 0 additions & 11 deletions src/Config/LightningConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ final class LightningConfig implements JsonSerializable
private ?string $callbackUrl = null;
private ?string $descriptionTemplate = null;
private ?string $successMessage = null;
private ?string $invoiceMemo = null;

public function setDomain(string $domain): self
{
Expand Down Expand Up @@ -57,12 +56,6 @@ public function setSuccessMessage(string $message): self
return $this;
}

public function setInvoiceMemo(string $memo): self
{
$this->invoiceMemo = $memo;
return $this;
}

public function addBackendsFile(string $path): self
{
$this->backends ??= new BackendsConfig();
Expand Down Expand Up @@ -119,10 +112,6 @@ public function jsonSerialize(): array
if ($this->successMessage !== null) {
$result['success-message'] = $this->successMessage;
}
if ($this->invoiceMemo !== null) {
$result['invoice-memo'] = $this->invoiceMemo;
}

return $result;
}
}
3 changes: 1 addition & 2 deletions src/Invoice/Application/InvoiceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function __construct(
private string $lnAddress,
private string $descriptionTemplate,
private string $successMessage,
private string $memo,
) {
}

Expand All @@ -37,7 +36,7 @@ public function generateInvoice(int $milliSats): array
$imageMetadata = '';
$metadata = '[["text/plain","' . $description . '"],["text/identifier","' . $this->lnAddress . '"]' . $imageMetadata . ']';

$invoice = $this->backendInvoice->requestInvoice((int)($milliSats / 1000), $metadata, $this->memo);
$invoice = $this->backendInvoice->requestInvoice((int)($milliSats / 1000), $metadata, $description);

return $this->mapResponseAsArray($invoice);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Invoice/InvoiceConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public function getSuccessMessage(): string
return (string)$this->get('success-message', 'Payment received!');
}

public function getInvoiceMemo(): string
{
return (string)$this->get('invoice-memo', '');
}

public function getDomain(): string
{
return (string)$this->get('domain', $_SERVER['HTTP_HOST'] ?? 'localhost');
Expand Down
1 change: 0 additions & 1 deletion src/Invoice/InvoiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function createInvoiceGenerator(string $username): InvoiceGenerator
$this->getConfig()->getDefaultLnAddress(),
$this->getConfig()->getDescriptionTemplate(),
$this->getConfig()->getSuccessMessage(),
$this->getConfig()->getInvoiceMemo(),
);
}

Expand Down
16 changes: 6 additions & 10 deletions tests/Unit/Invoice/Domain/LnAddress/InvoiceGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function test_invalid_amount(): void
SendableRange::withMinMax(1_000, 3_000),
'ln@address',
'Pay to %s',
'Payment received!',
'',
'Payment received!'
);
$actual = $invoice->generateInvoice(100);

Expand All @@ -44,8 +43,7 @@ public function test_unknown_backend(): void
SendableRange::withMinMax(1_000, 3_000),
'ln@address',
'Pay to %s',
'Payment received!',
'',
'Payment received!'
);
$actual = $invoice->generateInvoice(2_000);

Expand Down Expand Up @@ -74,8 +72,7 @@ public function test_successful_payment_request_with_amount(): void
SendableRange::withMinMax(1_000, 3_000),
'ln@address',
'Pay to %s',
'Payment received!',
'',
'Payment received!'
);
$actual = $invoice->generateInvoice(2_000);

Expand All @@ -93,21 +90,20 @@ public function test_successful_payment_request_with_amount(): void
], $actual);
}

public function test_passes_memo_to_backend(): void
public function test_passes_description_as_memo_to_backend(): void
{
$backend = $this->createMock(BackendInvoiceInterface::class);
$backend->expects(self::once())
->method('requestInvoice')
->with(2, $this->anything(), 'Custom memo')
->with(2, $this->anything(), 'Pay to ln@address')
->willReturn(new InvoiceTransfer());

$invoice = new InvoiceGenerator(
$backend,
SendableRange::withMinMax(1_000, 3_000),
'ln@address',
'Pay to %s',
'Payment received!',
'Custom memo',
'Payment received!'
);

$invoice->generateInvoice(2_000);
Expand Down
Loading