Skip to content

Commit

Permalink
Merge pull request #128 from ndeet/cleanup
Browse files Browse the repository at this point in the history
Cleanup and adding getCurrency() for new data field.
  • Loading branch information
ndeet authored Sep 16, 2024
2 parents 5e2ba7e + 108f18b commit 28197bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/Result/InvoicePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ public function getPaymentMethod(): string
public function getCryptoCode(): string
{
$data = $this->getData();
// BTCPay 2.0.0 compatibility: cryptoCode was renamed to currency.
if (isset($data['currency'])) {
return $data['currency'];
}

// For future compatibility check if cryptoCode exists.
if (isset($data['cryptoCode'])) {
Expand All @@ -87,4 +83,13 @@ public function getCryptoCode(): string
return $parts[0];
}
}

/**
* New field as of BTCPay 2.0.0.
*/
public function getCurrency(): ?string
{
$data = $this->getData();
return $data['currency'] ?? null;
}
}
2 changes: 1 addition & 1 deletion src/Result/StorePaymentMethodCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function all(): array
$paymentMethodData['cryptoCode'] = str_replace('-LightningNetwork', '', $paymentMethod);
}

// BTCPay 2.0 compatibility: put the currency code in the cryptoCode field.
// BTCPay 2.0 compatibility: put the extracted cryptoCode in the cryptoCode field.
if (isset($extractedCryptoCode)) {
$paymentMethodData['cryptoCode'] = $extractedCryptoCode;
}
Expand Down

0 comments on commit 28197bf

Please sign in to comment.