From 324895cd5b4e7c962281116ea7b365e708f9f01d Mon Sep 17 00:00:00 2001 From: 021-projects <20326979+021-projects@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:12:55 +0300 Subject: [PATCH] refactor(helpers): extract helpers to separate classes because of bad support of psr-4 in XenForo --- src/addons/BS/BtcPayProvider/Helpers/Data.php | 11 +++++++++++ .../BS/BtcPayProvider/Payment/Concerns/Webhook.php | 13 ++++++------- src/addons/BS/BtcPayProvider/helpers.php | 8 -------- 3 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 src/addons/BS/BtcPayProvider/Helpers/Data.php delete mode 100644 src/addons/BS/BtcPayProvider/helpers.php diff --git a/src/addons/BS/BtcPayProvider/Helpers/Data.php b/src/addons/BS/BtcPayProvider/Helpers/Data.php new file mode 100644 index 0000000..2e52ea0 --- /dev/null +++ b/src/addons/BS/BtcPayProvider/Helpers/Data.php @@ -0,0 +1,11 @@ +purchaseRequest->extra_data, 'invoiceExpired')) { + if (! Data::get($state->purchaseRequest->extra_data, 'invoiceExpired')) { $state->logType = 'info'; $state->logMessage = 'Invoice (partial) payment settled.'; return null; @@ -40,7 +39,7 @@ protected function getWebhookPaymentResult(CallbackState $state): ?int case 'InvoiceReceivedPayment': $state->logType = 'info'; - if (data_get($payload, 'afterExpiration')) { + if (Data::get($payload, 'afterExpiration')) { $state->logMessage = 'Invoice (partial) payment incoming (unconfirmed) after invoice was already expired.'; } else { $state->logMessage = 'Invoice (partial) payment incoming (unconfirmed). Waiting for settlement.'; @@ -49,7 +48,7 @@ protected function getWebhookPaymentResult(CallbackState $state): ?int case 'InvoiceProcessing': $state->logType = 'info'; - if (data_get($payload, 'overPaid')) { + if (Data::get($payload, 'overPaid')) { $state->logMessage = 'Invoice payment received fully with overpayment, waiting for settlement.'; } else { $state->logMessage = 'Invoice payment received fully, waiting for settlement.'; @@ -58,7 +57,7 @@ protected function getWebhookPaymentResult(CallbackState $state): ?int case 'InvoiceExpired': $state->logType = 'info'; - if (data_get($payload, 'partiallyPaid')) { + if (Data::get($payload, 'partiallyPaid')) { $state->logMessage = 'Invoice expired but was paid partially, please check.'; } else { $state->logMessage = 'Invoice expired. No action to take.'; @@ -68,7 +67,7 @@ protected function getWebhookPaymentResult(CallbackState $state): ?int case 'InvoiceInvalid': $state->logType = 'info'; - if (data_get($payload, 'manuallyMarked')) { + if (Data::get($payload, 'manuallyMarked')) { $state->logMessage = 'Invoice manually marked invalid.'; } else { $state->logMessage = 'Invoice became invalid.'; diff --git a/src/addons/BS/BtcPayProvider/helpers.php b/src/addons/BS/BtcPayProvider/helpers.php deleted file mode 100644 index 8cbdaba..0000000 --- a/src/addons/BS/BtcPayProvider/helpers.php +++ /dev/null @@ -1,8 +0,0 @@ -