diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d42fc32 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# The image installs tooling only — nothing from this directory is copied into +# it — so the build context can be empty. Without this, `docker compose build` +# would ship vendor/, node_modules/ and .git to the Docker daemon on every build +# for no reason. The Dockerfile itself is read separately and is unaffected. +# +# If a COPY of plugin sources is ever added to the Dockerfile, un-ignore exactly +# what it needs rather than deleting this file. +* diff --git a/.gitignore b/.gitignore index eed05ad..0d37ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,11 @@ venv/ /build/ /out/ +# Compiled assets that `make zip` (shopware-cli extension zip) regenerates into +# the source tree during its storefront/admin build. They are build output, not +# source, and must not be committed from a dev checkout. +/src/Storefront/Resources/public/ + # SQL dumps *.sql *.sqlite diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a01a529 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# 0.9.0-beta.2 + +Second pre-release. Still for internal development, QA and sandbox/staging +testing; not yet submitted to the Shopware Store. + +- Debug logging is now resolved per sales channel. `enableDebugging` and the log levels are ordinary plugin settings, so a merchant can scope them to a single sales channel; previously they were only read from the global scope, so enabling debugging on one sales channel produced no output at all. +- Storefront bank-verification template blocks are namespaced, so they no longer collide with other plugins that extend the same account templates. +- Relicensed from MIT to the Apache License 2.0, adding an explicit patent grant, an explicit reservation of trademark rights, and a `NOTICE` file that carries attribution into forks. +- The plugin now states clearly that it is an independent, third-party integration and is not affiliated with or endorsed by Paystack. Added a trademark and branding policy (`TRADEMARKS.md`). +- Replaced the third-party logos used as the plugin and administration icons with KommandHub branding. +- Build tooling: `make prepare` now works for pre-release versions and on repeat runs, and the test container ships `shopware-cli` for plugin validation. + +--- + +# 0.9.0-beta.1 + +Pre-release for internal development, QA and sandbox/staging testing. Not yet +submitted to the Shopware Store. The public API and namespaces may still +change before `1.0.0`. + +- Paystack payment for Shopware 6: card, bank transfer, USSD and mobile money. +- Payment verification checks status, amount and currency before an order is marked paid. +- Refunds from the order detail page, including partial refunds, with a server-side over-refund guard. +- Dedicated "Paystack refund" admin permission that can be assigned to roles (depends on the order editor permission). +- Webhook handling for `charge.success`, `refund.pending` and `refund.processed`, with signature verification. +- Bank-account verification in the customer account (account resolution via Paystack). +- Correct amount handling for every currency Paystack supports, including zero- and three-decimal currencies (e.g. XOF, RWF, KWD). The plugin does not create currencies or languages in the shop. +- Plugin interface translated into English, German and French. +- Configurable logging, sandbox/live mode and a minimum refund amount. +- Supports Shopware 6.6 and 6.7. diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index fa2923c..775c733 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,17 @@ +# 0.9.0-beta.2 + +Zweite Vorabversion. Weiterhin für interne Entwicklung, QA und Sandbox-/ +Staging-Tests; noch nicht im Shopware Store eingereicht. + +- Die Debug-Protokollierung wird jetzt pro Verkaufskanal ausgewertet. `enableDebugging` und die Log-Level sind normale Plugin-Einstellungen und lassen sich je Verkaufskanal setzen; bisher wurden sie nur global gelesen, sodass die Aktivierung für einen einzelnen Verkaufskanal wirkungslos blieb. +- Die Template-Blöcke der Bankverifizierung im Storefront sind jetzt eindeutig benannt und kollidieren nicht mehr mit anderen Plugins, die dieselben Konto-Templates erweitern. +- Lizenzwechsel von MIT zur Apache License 2.0: mit ausdrücklicher Patentlizenz, ausdrücklichem Markenvorbehalt und einer `NOTICE`-Datei, die die Urheberangaben in Forks weiterträgt. +- Das Plugin weist nun deutlich darauf hin, dass es eine unabhängige Drittanbieter-Integration ist und nicht mit Paystack verbunden oder von Paystack unterstützt wird. Ergänzt um eine Marken- und Branding-Richtlinie (`TRADEMARKS.md`). +- Die als Plugin- und Administrations-Icon verwendeten fremden Logos wurden durch KommandHub-Branding ersetzt. +- Build-Werkzeuge: `make prepare` funktioniert jetzt auch mit Vorabversionen und bei wiederholten Läufen, und der Testcontainer enthält `shopware-cli` für die Plugin-Validierung. + +--- + # 0.9.0-beta.1 Vorabversion für interne Entwicklung, QA und Sandbox-/Staging-Tests. Noch diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md deleted file mode 100644 index c88c568..0000000 --- a/CHANGELOG_en-GB.md +++ /dev/null @@ -1,16 +0,0 @@ -# 0.9.0-beta.1 - -Pre-release for internal development, QA and sandbox/staging testing. Not yet -submitted to the Shopware Store. The public API and namespaces may still -change before `1.0.0`. - -- Paystack payment for Shopware 6: card, bank transfer, USSD and mobile money. -- Payment verification checks status, amount and currency before an order is marked paid. -- Refunds from the order detail page, including partial refunds, with a server-side over-refund guard. -- Dedicated "Paystack refund" admin permission that can be assigned to roles (depends on the order editor permission). -- Webhook handling for `charge.success`, `refund.pending` and `refund.processed`, with signature verification. -- Bank-account verification in the customer account (account resolution via Paystack). -- Correct amount handling for every currency Paystack supports, including zero- and three-decimal currencies (e.g. XOF, RWF, KWD). The plugin does not create currencies or languages in the shop. -- Plugin interface translated into English, German and French. -- Configurable logging, sandbox/live mode and a minimum refund amount. -- Supports Shopware 6.6 and 6.7. diff --git a/CHANGELOG_fr-FR.md b/CHANGELOG_fr-FR.md index b9b8c4f..64bc6f6 100644 --- a/CHANGELOG_fr-FR.md +++ b/CHANGELOG_fr-FR.md @@ -1,3 +1,18 @@ +# 0.9.0-beta.2 + +Deuxième version préliminaire. Toujours destinée au développement interne, à +l'assurance qualité et aux tests sandbox/staging ; pas encore soumise au +Shopware Store. + +- La journalisation de débogage est désormais résolue par canal de vente. `enableDebugging` et les niveaux de journalisation sont des réglages de plugin ordinaires, configurables par canal de vente ; ils n'étaient auparavant lus qu'au niveau global, de sorte que l'activation sur un seul canal restait sans effet. +- Les blocs de template de la vérification bancaire côté storefront sont désormais préfixés et n'entrent plus en conflit avec d'autres plugins étendant les mêmes templates de compte. +- Passage de la licence MIT à la licence Apache 2.0 : concession de brevet explicite, réserve explicite des droits de marque et fichier `NOTICE` transmettant l'attribution aux forks. +- Le plugin indique désormais clairement qu'il s'agit d'une intégration indépendante et tierce, non affiliée à Paystack ni approuvée par Paystack. Ajout d'une politique de marque et d'image (`TRADEMARKS.md`). +- Les logos tiers utilisés comme icônes du plugin et de l'administration ont été remplacés par l'identité visuelle KommandHub. +- Outils de build : `make prepare` fonctionne désormais avec les versions préliminaires et lors d'exécutions répétées, et le conteneur de test embarque `shopware-cli` pour la validation du plugin. + +--- + # 0.9.0-beta.1 Version préliminaire pour le développement interne, l'assurance qualité et les diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5dd9c2..3e16011 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,29 @@ Contributions are **welcome** and will be fully **credited**. +## Licensing of contributions + +This project is licensed under the [Apache License 2.0](LICENSE). Under Section 5 +of that license, **any contribution you submit is provided under the same +license**, unless you explicitly state otherwise. You retain the copyright to +your contribution. + +We use the **Developer Certificate of Origin (DCO)** rather than a Contributor +License Agreement — a one-line assertion, added by signing off your commits, +that you have the right to submit the code under the project license: + +```bash +git commit -s -m "fix: correct refund balance rounding" +``` + +`-s` appends a `Signed-off-by:` line using your configured Git identity. The full +text of what you are certifying is at . + +## Trademarks + +The code license does **not** grant rights to the KommandHub name or logo. If you +fork and redistribute your own version, you must rebrand it. See +[TRADEMARKS.md](TRADEMARKS.md). ## Branching Strategy (GitHub Flow) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c4c4ade --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +# syntax=docker/dockerfile:1 + +# shopware-cli, for validating this plugin from inside its own test container. +# +# It is published as a purpose-built image containing nothing but the static Go +# binary (~50 MB, multi-arch: amd64 and arm64). Copying the binary out of it is +# the leanest install available: no apt source to add, no curl/gpg tooling to +# install, no archive to clean up, and a single layer. The alternative — the +# full shopware/shopware-cli: image — is ~1.25 GB to pull for one file. +# +# ":bin" tracks the latest stable release, which is what this environment wants: +# validation should reflect what the Shopware Store runs today. The trade-off is +# that a rebuild can pick up a newer CLI. Pin it for a reproducible build by +# passing a digest: +# +# docker compose build \ +# --build-arg SHOPWARE_CLI_IMAGE=shopware/shopware-cli:bin@sha256: +ARG SHOPWARE_CLI_IMAGE=shopware/shopware-cli:bin + +FROM ${SHOPWARE_CLI_IMAGE} AS shopware-cli + +FROM dockware/shopware:6.7.8.0 + +# Root is needed to write into /usr/local/bin. +USER root + +# /usr/local/bin is already on PATH for every user and shell, so no PATH edit is +# needed for `shopware-cli` to be callable directly. +COPY --from=shopware-cli /shopware-cli /usr/local/bin/shopware-cli + +# Fail the build — not the first `make validate-plugin` — if the binary is +# missing, not executable, or built for the wrong architecture. +RUN chmod +x /usr/local/bin/shopware-cli \ + && shopware-cli --version + +# Restore the image's declared default user, or the container would run as root. +# +# It must be "dockware" specifically, not "www-data". They share uid 33, so the +# two look interchangeable — but dockware's entrypoint escalates with sudo, and +# the sudo rights are granted to the dockware account. Setting USER www-data +# starts the container as the same uid under a name sudo has no rule for, and +# boot dies with "sudo: a password is required". +USER dockware diff --git a/LICENSE b/LICENSE index 8a80abd..71f24aa 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -MIT License - -Copyright (c) 2026 KommandHub - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative + Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, excluding + those notices that do not pertain to any part of the Derivative + Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and do + not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an + addendum to the NOTICE text from the Work, provided that such + additional attribution notices cannot be construed as modifying + the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 Kommandhub Limited + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile index 983fa2b..7b241f9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help up down build restart shell plugin-list test test-coverage cs cs-fix analyse fixture-load resync prepare +.PHONY: help up down build restart shell plugin-list test test-coverage cs cs-fix analyse fixture-load resync prepare validate-plugin cli changelog zip CONTAINER := shopware PLUGIN_DIR := custom/static-plugins/KommandhubPaystackSW @@ -12,8 +12,34 @@ STATIC_PLUGINS := \ STATIC_COPY_PLUGINS := \ kommandhub/foundation-sw:KommandhubFoundationSW -# Composer install list (includes all) -COMPOSER_PLUGINS := $(foreach p,$(STATIC_PLUGINS),$(word 1,$(subst :, ,$(p)))) +# This plugin may ship at any stability (see "version" in composer.json), while +# the Shopware install it is tested against pins minimum-stability to "stable". +# Composer therefore refuses to resolve a pre-release unless the requirement +# carries its own stability flag: +# +# Could not find a version of package kommandhub/paystack-sw matching your +# minimum-stability (stable). +# +# Composer's ladder is: dev < alpha < beta < RC < stable. A flag accepts its own +# level *and everything above it*, so "@dev" — the bottom rung — accepts every +# stability there is. That makes this work unchanged for 0.9.0-alpha.1, +# -beta.1, -RC1, a dev- branch, and 1.0.0 stable, with no edit per release. +# ("@beta" would have covered beta/RC/stable but silently broken on an alpha.) +# +# This is a PER-PACKAGE flag: the root minimum-stability stays "stable", so no +# other dependency can quietly resolve to a pre-release. That containment is why +# this is preferred over relaxing minimum-stability globally. +# +# It is only permissive about *stability*, not about which package is chosen: +# this plugin resolves from the custom/static-plugins path repository, which +# offers exactly one candidate — the working tree being tested. +PLUGIN_PACKAGE := kommandhub/paystack-sw +PLUGIN_STABILITY := *@dev + +# Composer install list (includes all). The package under development is +# requested with its stability flag; every other plugin is required as-is. +COMPOSER_PLUGINS := $(patsubst $(PLUGIN_PACKAGE),'$(PLUGIN_PACKAGE):$(PLUGIN_STABILITY)',\ + $(foreach p,$(STATIC_PLUGINS),$(word 1,$(subst :, ,$(p))))) define CHECK_READY @if [ -z "$$(docker compose ps $(CONTAINER) --status running --quiet)" ]; then \ @@ -55,6 +81,10 @@ help: @echo " fixture-load - Load fixtures" @echo " resync - Sync config directory into the root project" @echo " prepare - Full project preparation" + @echo " validate-plugin - Validate the plugin with shopware-cli (store compliance)" + @echo " cli - Run any shopware-cli command: make cli ARGS=\"--version\"" + @echo " changelog - Render the plugin changelog as the store would" + @echo " zip - Build a distributable plugin zip into build/" up: docker compose up -d --build @@ -100,6 +130,33 @@ analyse: $(CHECK_READY) $(call EXEC_IN_PLUGIN,./vendor/bin/phpstan analyse src -c phpstan.dist.neon --memory-limit=1G) +# shopware-cli lives in the image (see Dockerfile), so these run against the same +# PHP version and vendor tree as the tests — not whatever a developer has on their +# host. Run `make build` after pulling a change to the Dockerfile. + +validate-plugin: + $(CHECK_READY) + $(call EXEC_IN_PLUGIN,shopware-cli extension validate . --full --store-compliance) + +# Escape hatch for the rest of the CLI, so a new target is not needed per command: +# make cli ARGS="extension get-version ." +# make cli ARGS="extension format ." +cli: + $(CHECK_READY) + $(call EXEC_IN_PLUGIN,shopware-cli $(ARGS)) + +changelog: + $(CHECK_READY) + $(call EXEC_IN_PLUGIN,shopware-cli extension get-changelog .) + +# --disable-git packages the working tree as it stands. Without it the CLI zips +# from a git ref, which fails in this mounted checkout ("cannot find checkout tag +# or branch") and would exclude uncommitted work anyway — the opposite of what a +# test-container package is for. +zip: + $(CHECK_READY) + $(call EXEC_IN_PLUGIN,shopware-cli extension zip . --release --disable-git --output-directory build) + fixture-load: $(CHECK_READY) docker compose exec $(CONTAINER) bin/console fixture:load --no-interaction @@ -116,6 +173,27 @@ prepare: docker compose exec $(CONTAINER) rm -rf custom/plugins/* +# Drop the copies a previous run left in custom/static-plugins, and the vendor +# entries pointing at them, BEFORE composer resolves anything. +# +# The root composer.json registers custom/static-plugins/* as a path repository, +# so a copy left there is a package in its own right and takes precedence over +# Packagist. That makes prepare work exactly once per fresh container and fail on +# every later run: composer symlinks vendor/ -> custom/static-plugins/, +# and the copy step below then tries to copy a directory onto itself +# ("are the same file"). +# +# It also silently pins the version — once copied, "^1.0" resolves to whatever is +# on disk rather than the latest release. Clearing first keeps Packagist +# authoritative and makes this target idempotent. + @echo "Clearing previously copied vendor plugins..." + @$(foreach plugin,$(STATIC_COPY_PLUGINS), \ + VENDOR_DIR=$(word 1,$(subst :, ,$(plugin))); \ + TARGET_DIR=$(word 2,$(subst :, ,$(plugin))); \ + echo " $$TARGET_DIR"; \ + docker compose exec $(CONTAINER) rm -rf custom/static-plugins/$$TARGET_DIR vendor/$$VENDOR_DIR; \ + ) + @echo "Installing required plugins via composer..." docker compose exec $(CONTAINER) composer require $(COMPOSER_PLUGINS) --no-interaction diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..14881e9 --- /dev/null +++ b/NOTICE @@ -0,0 +1,26 @@ +Paystack Payment for Shopware 6 +Copyright 2026 Kommandhub Limited + +This product is licensed under the Apache License, Version 2.0 (see the LICENSE +file). Any redistribution, with or without modification, must retain this NOTICE +file per Section 4(d) of that License. + +-------------------------------------------------------------------------------- +Trademark notice +-------------------------------------------------------------------------------- + +This software is an independent, third-party integration. It is not affiliated +with, endorsed by, sponsored by, certified by, or officially supported by +Paystack. + +"Paystack", the Paystack logo, and related marks are trademarks of their +respective owner and are referenced here solely to identify the payment gateway +this software connects to (nominative use). "Shopware" is a registered trademark +of shopware AG, referenced only to identify the platform this software extends. +No trademark rights are granted by the Apache License, Version 2.0 (see Section +6 of the LICENSE). + +"KommandHub", the KommandHub logo, and "Kommandhub Limited" are trademarks of +Kommandhub Limited. The Apache License covers the source code only and does not +grant any right to use these marks. See the TRADEMARKS.md file for the branding +policy that applies to forks and redistributions. diff --git a/README.md b/README.md index a963140..597061f 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@ # Paystack Payment for Shopware 6 -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Shopware](https://img.shields.io/badge/Shopware-6.6%20%7C%206.7-blue.svg)](https://shopware.com) [![PHP](https://img.shields.io/badge/PHP-8.2%2B-777bb4.svg)](https://www.php.net) [![PHPStan](https://img.shields.io/badge/PHPStan-level%209-brightgreen.svg)](https://phpstan.org) -![Shopware Paystack Logo](src/Resources/config/shopware.png) +

+ + Kommandhub Logo + +

A production-grade **Shopware 6 payment plugin** that integrates the **[Paystack](https://paystack.com)** payment gateway, enabling merchants across Africa to accept secure online payments through cards, bank transfers, USSD, and mobile money. Developed by [Kommandhub Limited](https://kommandhub.com). +> **Independent integration.** This is an independent, third-party plugin. It is **not** affiliated with, endorsed by, sponsored by, certified by, or officially supported by Paystack. "Paystack" and the Paystack logo are trademarks of their respective owner and are used here only to identify the payment gateway this plugin connects to. See [Trademarks & Disclaimer](#trademarks--disclaimer). + This document is the technical reference for developers **contributing to** the plugin. If you only want to install and configure it on a live shop, the [Installation](#installation) and [Configuration](#configuration) sections are enough. --- @@ -44,6 +50,7 @@ This document is the technical reference for developers **contributing to** the - [Coding Standards](#coding-standards) - [Roadmap](#roadmap) - [License](#license) +- [Trademarks & Disclaimer](#trademarks--disclaimer) - [Support](#support) --- @@ -206,7 +213,7 @@ KommandhubPaystackSW/ ├── .php-cs-fixer.dist.php ├── docker-compose.yml ├── Makefile -├── CHANGELOG_en-GB.md +├── CHANGELOG.md # English; CHANGELOG_.md for translations └── CLAUDE.md # Contributor conventions (read this too) ``` @@ -277,9 +284,16 @@ Default dockware credentials: ## Docker & Docker Compose -The stack is defined in [`docker-compose.yml`](docker-compose.yml): +The stack is defined in [`docker-compose.yml`](docker-compose.yml) and built from +a small [`Dockerfile`](Dockerfile): -- **Image**: `dockware/shopware:6.7.8.0` +- **Base image**: `dockware/shopware:6.7.8.0` +- **Added tooling**: [`shopware-cli`](https://sw-cli.fos.gg/) — the static binary + is copied from the upstream `shopware/shopware-cli:bin` image (latest stable, + ~50 MB, multi-arch), so no package manager or cleanup is involved. The build + runs `shopware-cli --version` so a broken install fails the image build rather + than the first `make validate-plugin`. Pin it for a reproducible build by + passing `--build-arg SHOPWARE_CLI_IMAGE=shopware/shopware-cli:bin@sha256:`. - **Container**: `kommandhub-paystack-plugin` - **PHP**: 8.3 (`XDEBUG_ENABLED` toggle available) - **Persistent volume**: `database` (MySQL data) @@ -314,6 +328,12 @@ All targets run the underlying tools inside the running container. | `make fixture-load` | Load test fixtures | | `make resync` | Sync the test config into the shop root | | `make prepare` | Full project preparation (run by `make up`) | +| `make validate-plugin` | Validate the plugin with `shopware-cli` (`--full --store-compliance`) | +| `make cli` | Run any `shopware-cli` command: `make cli ARGS="extension get-version ."` | +| `make changelog` | Render `CHANGELOG.md` as the Shopware Store would display it | +| `make zip` | Build a distributable plugin zip into `build/` | + +`shopware-cli` ships inside the container image (see [Docker & Docker Compose](#docker--docker-compose)), so these run against the same PHP version and installed Shopware as the tests — not whatever is on the host. No local install is required. **Before committing, run:** @@ -457,12 +477,18 @@ Logging goes through `Logging\ConfigurableLogger`, wired to the `paystack_channe 4. Configure live secret keys and disable sandbox mode. 5. Grant the **Paystack → Process Paystack refunds** permission to the roles that should be able to issue refunds (the built-in admin role already has all privileges). -Validate a release build for the Shopware Store with: +Validate a release build for the Shopware Store from inside the container, where +`shopware-cli` runs against the installed Shopware and full vendor tree: ```bash -shopware-cli extension validate . --full --store-compliance +make validate-plugin +# equivalently: make cli ARGS="extension validate . --full --store-compliance" ``` +Running the same command against a host-only `shopware-cli` reports false +positives (see the PHPStan note under [Troubleshooting](#troubleshooting)) — +the container has the dependencies it needs to resolve Shopware's classes. + --- ## CI/CD @@ -561,7 +587,21 @@ Please also read [`CLAUDE.md`](CLAUDE.md) for the module boundaries and project- ## License -Licensed under the **MIT License**. See [LICENSE](LICENSE) for details. +Licensed under the **Apache License 2.0**. See [LICENSE](LICENSE) and [NOTICE](NOTICE) for details. + +Apache-2.0 was chosen over a simpler permissive licence for its explicit patent grant, its explicit reservation of trademark rights (§6), and the `NOTICE` mechanism that carries attribution downstream into forks. The licence covers this plugin's **own source code only**. It grants **no rights** in the KommandHub name or logo (see [TRADEMARKS.md](TRADEMARKS.md)), nor in Paystack's trademarks, logos, or services (see [Trademarks & Disclaimer](#trademarks--disclaimer)). + +--- + +## Trademarks & Disclaimer + +This plugin is an **independent, third-party integration** developed and maintained by [Kommandhub Limited](https://kommandhub.com). It is **not** affiliated with, endorsed by, sponsored by, certified by, or officially supported by Paystack or any of its affiliates. + +"Paystack", the Paystack logo, and any related names, marks, and logos are trademarks of their respective owner. "Shopware" is a registered trademark of shopware AG. All other trademarks referenced in this project are the property of their respective owners. These marks are used in this project solely for **nominative purposes** — to identify the third-party payment gateway and the platform that this plugin integrates with — and their use does not imply any endorsement, partnership, or affiliation. + +Use of the Paystack payment gateway is subject to Paystack's own terms of service and agreements, which are between the merchant and Paystack. This plugin merely provides a technical integration and makes no warranty regarding Paystack's services. To use it you must hold your own valid Paystack account and API credentials. + +**KommandHub's own marks** — the "KommandHub" name and logo — are trademarks of Kommandhub Limited. The open-source licence covers the code, not the brand: a fork must be **rebranded** before redistribution. The full policy is in [TRADEMARKS.md](TRADEMARKS.md). --- diff --git a/TRADEMARKS.md b/TRADEMARKS.md new file mode 100644 index 0000000..adcaa0c --- /dev/null +++ b/TRADEMARKS.md @@ -0,0 +1,67 @@ +# Trademark & Branding Policy + +This project's **code** is open source under the [Apache License 2.0](LICENSE). A +licence to the code is **not** a licence to the project's **name, logo, or brand +identity**. This policy explains the line between the two. + +It exists because the Apache License (like every open-source licence) lets anyone +fork, modify, redistribute, and even sell the code. What it does **not** let +anyone do is pass their version off as *this* project, or as a product of +Kommandhub Limited. Trademark law — not the code licence — is what protects the +project's integrity and the community's trust in the name. + +## The marks + +The following are trademarks of **Kommandhub Limited** ("the Marks"): + +- The names **"KommandHub"** and **"Kommandhub"**. +- The **KommandHub logo** (the rounded-square network mark shipped in this + repository, e.g. `src/Resources/config/plugin.png`). +- Product names that combine the above, such as **"Paystack Payment by + Kommandhub"**. + +## What you may do (no permission needed) + +- Use, modify, and redistribute the **code** under the Apache License 2.0. +- State, factually and accurately, that your product **is based on**, **is a + fork of**, or **is derived from** this project — as long as you do not imply + it is endorsed by or affiliated with Kommandhub Limited. +- Use the Marks in **nominative** ways: unmodified references in prose, + documentation, and comparisons ("compatible with KommandHub's plugin"). +- Keep the `LICENSE` and `NOTICE` files intact in redistributions (this is required by the + licence, not optional). + +## What you may not do (without written permission) + +- **Publish or distribute a fork under the KommandHub name or logo**, or under a + name or icon confusingly similar to them — including on the Shopware Store, on + Packagist, or in any marketplace. +- Present a modified version as the **official** KommandHub plugin, or imply + Kommandhub Limited's endorsement, sponsorship, certification, or support. +- Use the Marks in your **company name, product name, domain name, or logo** in + a way likely to cause confusion about origin. + +**If you fork this project and distribute your own version, you must rebrand +it** — remove the KommandHub name and logo and ship it under your own, +non-confusing identity. This is the one thing the code licence does not grant +and this policy explicitly withholds. + +## Third-party trademarks + +"Paystack", the Paystack logo, and related marks are trademarks of their +respective owner. This project is an **independent, third-party** integration +and is **not** affiliated with, endorsed by, or officially supported by +Paystack. Those marks are used here only to identify the payment gateway the +plugin connects to. Your own use of the Paystack name and brand is subject to +Paystack's own brand and trademark guidelines, not this policy. + +"Shopware" is a registered trademark of shopware AG and is used here only to +identify the platform this plugin extends. + +## Questions & permission requests + +To request permission for a use this policy does not allow, contact +**legal@kommandhub.com** (or **info@kommandhub.com**). We are generally happy to +grant reasonable requests that do not create confusion about origin. + +*This policy may be updated over time. It does not constitute legal advice.* diff --git a/composer.json b/composer.json index b6d5dbc..96b80a6 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "kommandhub/paystack-sw", - "description": "Integrate the Paystack payment gateway into Shopware 6 to accept secure payments via credit cards, bank transfers, and mobile money. Expand your business across Africa with ease.", + "description": "Independent, third-party Shopware 6 integration for the Paystack payment gateway: accept secure payments via cards, bank transfers, USSD, and mobile money across Africa. Not affiliated with, endorsed by, or officially connected to Paystack.", "type": "shopware-platform-plugin", - "version": "0.9.0-beta.1", - "license": "MIT", + "version": "0.9.0-beta.2", + "license": "Apache-2.0", "keywords": [ "shopware", "shopware6", @@ -61,14 +61,14 @@ "extra": { "shopware-plugin-class": "Kommandhub\\PaystackSW\\KommandhubPaystackSW", "label": { - "de-DE": "Paystack Zahlung", - "en-GB": "Paystack Payment", - "fr-FR": "Paystack Paiement" + "de-DE": "Paystack-Zahlung von Kommandhub", + "en-GB": "Paystack Payment by Kommandhub", + "fr-FR": "Paiement Paystack par Kommandhub" }, "description": { - "de-DE": "Integrieren Sie das Paystack-Zahlungsgateway nahtlos in Shopware 6. Ermöglichen Sie Ihren Kunden sichere Zahlungen per Kreditkarte, Banküberweisung und Mobile Money in ganz Afrika.", - "en-GB": "Integrate the Paystack payment gateway into Shopware 6 to accept secure payments via credit cards, bank transfers, and mobile money. Expand your business across Africa with ease.", - "fr-FR": "Intégrez Paystack à Shopware 6 pour accepter des paiements sécurisés par carte, virement et mobile money. Développez votre activité en Afrique avec cette solution de paiement fiable." + "de-DE": "Unabhängige Drittanbieter-Integration des Paystack-Gateways für Shopware 6: sichere Zahlungen per Karte, Überweisung, USSD und Mobile Money. Nicht mit Paystack verbunden.", + "en-GB": "Independent third-party Shopware 6 integration for the Paystack payment gateway: secure card, bank transfer, USSD, and mobile money payments. Not affiliated with Paystack.", + "fr-FR": "Intégration Shopware 6 indépendante et tierce pour la passerelle Paystack : paiements sécurisés par carte, virement, USSD et mobile money. Non affiliée à Paystack." }, "manufacturerLink": { "de-DE": "https://kommandhub.com", diff --git a/docker-compose.yml b/docker-compose.yml index 11b6b7e..4cdc17e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,11 @@ services: shopware: - image: 'dockware/shopware:6.7.8.0' + # Built from the local Dockerfile: the stock dockware image plus shopware-cli, + # so the plugin can be validated from inside its own test environment. + build: + context: . + dockerfile: Dockerfile + image: 'kommandhub-paystack-plugin:6.7.8.0' container_name: kommandhub-paystack-plugin environment: - 'XDEBUG_ENABLED=0' diff --git a/src/Checkout/Cart/CartValidator.php b/src/Checkout/Cart/CartValidator.php index 648cdbe..1997d9d 100644 --- a/src/Checkout/Cart/CartValidator.php +++ b/src/Checkout/Cart/CartValidator.php @@ -53,7 +53,7 @@ public function validate( return; } - $this->logger->error('Paystack API secret key is not configured.', [ + $this->logger->error('[Paystack] API secret key is not configured.', [ 'salesChannelId' => $salesChannelId, 'isSandbox' => $isSandbox, 'cartToken' => $cart->getToken(), diff --git a/src/Checkout/Payment/Service/FinalizeProcessor.php b/src/Checkout/Payment/Service/FinalizeProcessor.php index 655b07d..7cf7025 100644 --- a/src/Checkout/Payment/Service/FinalizeProcessor.php +++ b/src/Checkout/Payment/Service/FinalizeProcessor.php @@ -59,7 +59,8 @@ public function process( $reference = $this->extractReference($request, $transactionId); if ($this->isAlreadyProcessed($orderTransaction)) { - $this->logger->info('Paystack payment already processed.', [ + $this->logger->info('[Paystack] Payment already processed.', [ + ConfigurableLogger::CONTEXT_SALES_CHANNEL_ID => $orderTransaction->getOrder()?->getSalesChannelId(), 'transaction_id' => $transactionId, 'reference' => $reference, ]); @@ -96,7 +97,8 @@ public function process( $paystackTransactionId = is_scalar($id) ? (string)$id : ''; } - $this->logger->info('Paystack payment finalized.', [ + $this->logger->info('[Paystack] Payment finalized.', [ + ConfigurableLogger::CONTEXT_SALES_CHANNEL_ID => $orderTransaction->getOrder()?->getSalesChannelId(), 'transaction_id' => $transactionId, 'reference' => $reference, 'paystack_transaction_id' => $paystackTransactionId, @@ -119,7 +121,7 @@ private function extractReference(Request $request, string $transactionId): stri $reference = $request->query->getString('reference'); if ($reference === '') { - $this->logger->error('Missing Paystack reference.', [ + $this->logger->error('[Paystack] Missing transaction reference.', [ 'transaction_id' => $transactionId, 'query' => $request->query->all(), ]); diff --git a/src/Checkout/Payment/Service/PaymentProcessor.php b/src/Checkout/Payment/Service/PaymentProcessor.php index 0e166d5..41433ac 100644 --- a/src/Checkout/Payment/Service/PaymentProcessor.php +++ b/src/Checkout/Payment/Service/PaymentProcessor.php @@ -49,7 +49,7 @@ public function process( $payload = $this->payloadBuilder->build($orderTransaction, $transaction); $response = $this->transactionService->initialize($payload); } catch (\RuntimeException $exception) { - $this->logger->error('Failed to build Paystack payment payload.', [ + $this->logger->error('[Paystack] Failed to build the payment payload.', [ 'transactionId' => $transactionId, 'exception' => $exception, ]); @@ -59,7 +59,7 @@ public function process( sprintf('Unable to prepare payment payload: %s', $exception->getMessage()) ); } catch (PaystackException $exception) { - $this->logger->error('Paystack communication error during initialization.', [ + $this->logger->error('[Paystack] Communication error during initialization.', [ 'transactionId' => $transactionId, 'exception' => $exception, ]); diff --git a/src/Checkout/Payment/Service/TransactionVerificationProcessor.php b/src/Checkout/Payment/Service/TransactionVerificationProcessor.php index 2a47b44..13bd5c3 100644 --- a/src/Checkout/Payment/Service/TransactionVerificationProcessor.php +++ b/src/Checkout/Payment/Service/TransactionVerificationProcessor.php @@ -54,7 +54,7 @@ private function fetchVerification( try { return $this->transactionService->verify($reference); } catch (\Throwable $e) { - $this->logger->error('Paystack verification API failure', [ + $this->logger->error('[Paystack] Verification API failure.', [ 'transactionId' => $transaction->getId(), 'reference' => $reference, 'error' => $e->getMessage(), @@ -124,7 +124,8 @@ private function assertTransactionAmount( ); if ((int)$paystackAmount !== $expected) { - $this->logger->warning('Paystack amount mismatch', [ + $this->logger->warning('[Paystack] Amount mismatch.', [ + ConfigurableLogger::CONTEXT_SALES_CHANNEL_ID => $order->getSalesChannelId(), 'transactionId' => $transaction->getId(), 'expected' => $expected, 'received' => (int)$paystackAmount, @@ -157,7 +158,7 @@ private function assertTransactionCurrency( $received = is_scalar($data['currency'] ?? null) ? strtoupper((string)$data['currency']) : ''; if ($received !== $expected) { - $this->logger->warning('Paystack currency mismatch', [ + $this->logger->warning('[Paystack] Currency mismatch.', [ 'transactionId' => $transaction->getId(), 'expected' => $expected, 'received' => $received, @@ -198,7 +199,7 @@ private function assertTransactionStatus( PaystackTransactionStatus::PROCESSING, PaystackTransactionStatus::QUEUED, PaystackTransactionStatus::ONGOING, - PaystackTransactionStatus::ABANDONED => $this->logger->info('Paystack transaction not final yet.', [ + PaystackTransactionStatus::ABANDONED => $this->logger->info('[Paystack] Transaction not final yet.', [ 'transactionId' => $transaction->getId(), 'status' => $statusValue, ]), diff --git a/src/Logging/ConfigurableLogger.php b/src/Logging/ConfigurableLogger.php index bcf827d..2857212 100644 --- a/src/Logging/ConfigurableLogger.php +++ b/src/Logging/ConfigurableLogger.php @@ -19,11 +19,28 @@ * Features: * - Enables/disables logging entirely via configuration. * - Filters log entries by configured PSR-3 log levels. + * - Resolves both against the sales channel an entry belongs to. * - Falls back to logging all levels when no specific levels are configured * to maintain backwards compatibility. */ class ConfigurableLogger extends AbstractLogger { + /** + * Context key carrying the sales channel a log entry belongs to. + * + * `enableDebugging` and `logLevels` are ordinary plugin settings, so Shopware + * lets a merchant scope them to a single sales channel. This class used to + * read them without a sales channel id, i.e. from the global scope only, + * which meant a merchant who enabled debugging on one sales channel got + * nothing at all. PSR-3 has no argument for the scope, so callers pass the + * id in the log context and it is resolved from there. Entries without the + * key keep the previous behaviour and resolve against the global scope. + * + * The key is left in the forwarded context on purpose: it is useful + * structured data on the entry itself. + */ + public const CONTEXT_SALES_CHANNEL_ID = 'salesChannelId'; + public function __construct( private readonly LoggerInterface $logger, private readonly Config $config @@ -34,8 +51,8 @@ public function __construct( * Logs a message at the specified level. * * The message is forwarded to the underlying logger only if: - * - Logging is enabled. - * - The log level is allowed by configuration. + * - Logging is enabled for the entry's sales channel. + * - The log level is allowed by configuration for that sales channel. * * @param mixed $level PSR-3 log level * @param string|Stringable $message Log message @@ -45,13 +62,23 @@ public function log($level, string|Stringable $message, array $context = []): vo { $levelString = is_scalar($level) || $level instanceof Stringable ? (string)$level : 'unknown'; - if (!$this->shouldLog($levelString)) { + if (!$this->shouldLog($levelString, $this->resolveSalesChannelId($context))) { return; } $this->logger->log($levelString, $message, $context); } + /** + * @param array $context + */ + private function resolveSalesChannelId(array $context): ?string + { + $salesChannelId = $context[self::CONTEXT_SALES_CHANNEL_ID] ?? null; + + return is_string($salesChannelId) && $salesChannelId !== '' ? $salesChannelId : null; + } + /** * Severity levels always written, regardless of the debug toggle, so * production keeps a trail of failures (webhook signature rejections, @@ -67,34 +94,34 @@ public function log($level, string|Stringable $message, array $context = []): vo /** * Determines whether a log entry should be written. */ - private function shouldLog(string $level): bool + private function shouldLog(string $level, ?string $salesChannelId): bool { if (in_array($level, self::ALWAYS_LOGGED, true)) { return true; } - return $this->isLoggingEnabled() - && $this->isLevelAllowed($level); + return $this->isLoggingEnabled($salesChannelId) + && $this->isLevelAllowed($level, $salesChannelId); } /** - * Determines whether logging is enabled. + * Determines whether logging is enabled for the entry's sales channel. */ - private function isLoggingEnabled(): bool + private function isLoggingEnabled(?string $salesChannelId): bool { - return $this->config->getBool('enableDebugging'); + return $this->config->getBool('enableDebugging', $salesChannelId); } /** - * Determines whether the given log level is allowed. + * Determines whether the given log level is allowed for the entry's sales channel. * * If no log levels are configured, all levels are considered allowed. * This preserves backwards compatibility for installations that have * enabled debugging but have not explicitly selected any log levels. */ - private function isLevelAllowed(string $level): bool + private function isLevelAllowed(string $level, ?string $salesChannelId): bool { - $allowedLevels = $this->config->getArray('logLevels'); + $allowedLevels = $this->config->getArray('logLevels', $salesChannelId); return empty($allowedLevels) || in_array($level, $allowedLevels, true); diff --git a/src/Resources/app/administration/src/view/kommandhub-paystack-detail/icon.png b/src/Resources/app/administration/src/view/kommandhub-paystack-detail/icon.png index c437641..7bea047 100644 Binary files a/src/Resources/app/administration/src/view/kommandhub-paystack-detail/icon.png and b/src/Resources/app/administration/src/view/kommandhub-paystack-detail/icon.png differ diff --git a/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.js b/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.js index 43f36a7..a0b4d1f 100644 --- a/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.js +++ b/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.js @@ -1 +1 @@ -(()=>{var e={},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.exports}t.m=e,t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((r,o)=>(t.f[o](e,r),r),[])),t.u=e=>"./js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.d99562.js",t.miniCssF=e=>{},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={};t.l=(r,o,n,a)=>{if(e[r]){e[r].push(o);return}if(void 0!==n)for(var i,c,s=document.getElementsByTagName("script"),l=0;l{i.onerror=i.onload=null,clearTimeout(d);var n=e[r];if(delete e[r],i.parentNode&&i.parentNode.removeChild(i),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),c&&document.head.appendChild(i)}})(),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{t.g.importScripts&&(e=t.g.location+"");var e,r=t.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var o=r.getElementsByTagName("script");if(o.length)for(var n=o.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=o[n--].src}if(!e)throw Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t.p=e+"../../"})(),(()=>{var e={46170:0};t.f.j=(r,o)=>{var n=t.o(e,r)?e[r]:void 0;if(0!==n){if(n)o.push(n[2]);else{var a=new Promise((t,o)=>n=e[r]=[t,o]);o.push(n[2]=a);var i=t.p+t.u(r),c=Error();t.l(i,o=>{if(t.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var a=o&&("load"===o.type?"missing":o.type),i=o&&o.target&&o.target.src;c.message="Loading chunk "+r+" failed.\n("+a+": "+i+")",c.name="ChunkLoadError",c.type=a,c.request=i,n[1](c)}},"chunk-"+r,r)}}};var r=(r,o)=>{var n,a,[i,c,s]=o,l=0;if(i.some(r=>0!==e[r])){for(n in c)t.o(c,n)&&(t.m[n]=c[n]);s&&s(t)}for(r&&r(o);lt.e(99382).then(t.bind(t,382)),"[data-paystack-bank-verification]")})(); \ No newline at end of file +(()=>{var e={},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.exports}t.m=e,t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((r,o)=>(t.f[o](e,r),r),[])),t.u=e=>"./js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.0f8875.js",t.miniCssF=e=>{},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={};t.l=(r,o,n,a)=>{if(e[r]){e[r].push(o);return}if(void 0!==n)for(var i,c,s=document.getElementsByTagName("script"),l=0;l{i.onerror=i.onload=null,clearTimeout(d);var n=e[r];if(delete e[r],i.parentNode&&i.parentNode.removeChild(i),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),c&&document.head.appendChild(i)}})(),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{t.g.importScripts&&(e=t.g.location+"");var e,r=t.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var o=r.getElementsByTagName("script");if(o.length)for(var n=o.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=o[n--].src}if(!e)throw Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t.p=e+"../../"})(),(()=>{var e={46170:0};t.f.j=(r,o)=>{var n=t.o(e,r)?e[r]:void 0;if(0!==n){if(n)o.push(n[2]);else{var a=new Promise((t,o)=>n=e[r]=[t,o]);o.push(n[2]=a);var i=t.p+t.u(r),c=Error();t.l(i,o=>{if(t.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var a=o&&("load"===o.type?"missing":o.type),i=o&&o.target&&o.target.src;c.message="Loading chunk "+r+" failed.\n("+a+": "+i+")",c.name="ChunkLoadError",c.type=a,c.request=i,n[1](c)}},"chunk-"+r,r)}}};var r=(r,o)=>{var n,a,[i,c,s]=o,l=0;if(i.some(r=>0!==e[r])){for(n in c)t.o(c,n)&&(t.m[n]=c[n]);s&&s(t)}for(r&&r(o);lt.e(64319).then(t.bind(t,319)),"[data-paystack-bank-verification]")})(); \ No newline at end of file diff --git a/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.0f8875.js b/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.0f8875.js new file mode 100644 index 0000000..5534a8b --- /dev/null +++ b/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.0f8875.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[64319],{319(t,e,n){n.r(e),n.d(e,{default:()=>a});let{PluginBaseClass:i}=window;class a extends i{static #t=this.options={banksUrl:"",verifyUrl:"",bankSelectSelector:"#bankName",accountNumberSelector:"#accountNumber",bvnSelector:"#bvn",accountNameSelector:"#accountName",submitButtonSelector:'button[type="submit"]',initialBankCode:""};static #e=this.ACCOUNT_NUMBER_LENGTH=10;static #n=this.BVN_LENGTH=11;init(){this._bankSelect=this.el.querySelector(this.options.bankSelectSelector),this._accountNumberInput=this.el.querySelector(this.options.accountNumberSelector),this._bvnInput=this.el.querySelector(this.options.bvnSelector),this._accountNameInput=this.el.querySelector(this.options.accountNameSelector),this._submitButton=this.el.querySelector(this.options.submitButtonSelector),this._bankSelect&&this._accountNumberInput&&(this._registerEvents(),this._loadBanks())}_registerEvents(){this._accountNumberInput.addEventListener("blur",this._onAccountNumberBlur.bind(this)),this._bankSelect.addEventListener("change",this._onBankChange.bind(this)),this.el.addEventListener("submit",this._onFormSubmit.bind(this))}_loadBanks(){this.options.banksUrl&&fetch(this.options.banksUrl,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(t=>t.json()).then(t=>{t.status&&Array.isArray(t.data)&&this._populateBankSelect(t.data)}).catch(t=>{console.error("Failed to load banks.",t)})}_populateBankSelect(t){for(;this._bankSelect.options.length>1;)this._bankSelect.remove(1);t.forEach(t=>{let e=document.createElement("option");e.value=t.code,e.text=t.name,e.dataset.bankName=t.name,t.code===this.options.initialBankCode&&(e.selected=!0),this._bankSelect.add(e)}),this._bankSelect.value&&this._accountNumberInput.value&&!this._accountNameInput.value&&this._verifyAccount()}_onAccountNumberBlur(){this._verifyAccount()}_onBankChange(){this._verifyAccount()}_verifyAccount(){if(!this.options.verifyUrl)return;let t=this._accountNumberInput.value.trim(),e=this._bankSelect.value;if(t.length0&&t.lengtht.json()).then(t=>{this._setLoading(!1,this._accountNumberInput),t.status&&t.data?(this._accountNameInput.value=t.data.account_name,this._markValidationState(this._accountNumberInput,!0,`Account verified: ${t.data.account_name}`)):this._markValidationState(this._accountNumberInput,!1,t.message||"Account verification failed")}).catch(t=>{this._setLoading(!1,this._accountNumberInput),console.error("Failed to verify account.",t),this._markValidationState(this._accountNumberInput,!1,"Verification service unavailable")})}_setLoading(t,e){e.classList.toggle("is-loading",t)}_markValidationState(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=t.closest(".form-group"),a=i?.querySelector(".invalid-feedback"),s=i?.querySelector(".valid-feedback");if(null===e){t.classList.remove("is-valid","is-invalid"),a&&(a.textContent=""),s&&(s.textContent="");return}t.classList.toggle("is-valid",e),t.classList.toggle("is-invalid",!e),s&&(s.textContent=e?n:""),a&&(a.textContent=e?"":n)}_onFormSubmit(){let t=this._bankSelect.options[this._bankSelect.selectedIndex];t&&(this._createOrUpdateHiddenField("hiddenBankName","bankName",t.dataset.bankName||""),this._createOrUpdateHiddenField("hiddenBankCode","bankCode",this._bankSelect.value))}_createOrUpdateHiddenField(t,e,n){let i=this.el.querySelector(`#${t}`);i||((i=document.createElement("input")).type="hidden",i.id=t,i.name=e,this.el.appendChild(i)),i.value=n}}}}]); \ No newline at end of file diff --git a/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.d99562.js b/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.d99562.js deleted file mode 100644 index 831b320..0000000 --- a/src/Resources/app/storefront/dist/storefront/js/kommandhub-paystack-s-w/kommandhub-paystack-s-w.paystack-bank-verification.plugin.d99562.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[99382],{382(e,t,n){n.r(t),n.d(t,{default:()=>a});class s{constructor(){this._request=null,this._errorHandlingInternal=!1}get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",s=this._createPreparedRequest("GET",e,n);return this._sendRequest(s,null,t)}post(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let i=this._createPreparedRequest("POST",e,s);return this._sendRequest(i,t,n)}delete(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let i=this._createPreparedRequest("DELETE",e,s);return this._sendRequest(i,t,n)}patch(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let i=this._createPreparedRequest("PATCH",e,s);return this._sendRequest(i,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn(`the request to ${e.responseURL} was aborted`)}),e.addEventListener("error",()=>{console.warn(`the request to ${e.responseURL} failed with status ${e.status}`)}),e.addEventListener("timeout",()=>{console.warn(`the request to ${e.responseURL} timed out`)})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}}let{PluginBaseClass:i}=window;class a extends i{static #e=this.options={banksUrl:"",verifyUrl:"",bankSelectSelector:"#bankName",accountNumberSelector:"#accountNumber",bvnSelector:"#bvn",accountNameSelector:"#accountName",submitButtonSelector:'button[type="submit"]',initialBankCode:""};static #t=this.ACCOUNT_NUMBER_LENGTH=10;static #n=this.BVN_LENGTH=11;init(){this._client=new s,this._bankSelect=this.el.querySelector(this.options.bankSelectSelector),this._accountNumberInput=this.el.querySelector(this.options.accountNumberSelector),this._bvnInput=this.el.querySelector(this.options.bvnSelector),this._accountNameInput=this.el.querySelector(this.options.accountNameSelector),this._submitButton=this.el.querySelector(this.options.submitButtonSelector),this._bankSelect&&this._accountNumberInput&&(this._registerEvents(),this._loadBanks())}_registerEvents(){this._accountNumberInput.addEventListener("blur",this._onAccountNumberBlur.bind(this)),this._bankSelect.addEventListener("change",this._onBankChange.bind(this)),this.el.addEventListener("submit",this._onFormSubmit.bind(this))}_loadBanks(){this.options.banksUrl&&this._client.get(this.options.banksUrl,e=>{try{let t=JSON.parse(e);t.status&&Array.isArray(t.data)&&this._populateBankSelect(t.data)}catch(e){console.error("Failed to parse banks response.",e)}})}_populateBankSelect(e){for(;this._bankSelect.options.length>1;)this._bankSelect.remove(1);e.forEach(e=>{let t=document.createElement("option");t.value=e.code,t.text=e.name,t.dataset.bankName=e.name,e.code===this.options.initialBankCode&&(t.selected=!0),this._bankSelect.add(t)}),this._bankSelect.value&&this._accountNumberInput.value&&!this._accountNameInput.value&&this._verifyAccount()}_onAccountNumberBlur(){this._verifyAccount()}_onBankChange(){this._verifyAccount()}_verifyAccount(){if(!this.options.verifyUrl)return;let e=this._accountNumberInput.value.trim(),t=this._bankSelect.value;if(e.length0&&e.length{this._setLoading(!1,this._accountNumberInput);try{let t=JSON.parse(e);t.status&&t.data?(this._accountNameInput.value=t.data.account_name,this._markValidationState(this._accountNumberInput,!0,`Account verified: ${t.data.account_name}`)):this._markValidationState(this._accountNumberInput,!1,t.message||"Account verification failed")}catch(e){console.error("Failed to parse verification response.",e),this._markValidationState(this._accountNumberInput,!1,"Verification service unavailable")}})}_setLoading(e,t){t.classList.toggle("is-loading",e)}_markValidationState(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",s=e.closest(".form-group"),i=s?.querySelector(".invalid-feedback"),a=s?.querySelector(".valid-feedback");if(null===t){e.classList.remove("is-valid","is-invalid"),i&&(i.textContent=""),a&&(a.textContent="");return}e.classList.toggle("is-valid",t),e.classList.toggle("is-invalid",!t),a&&(a.textContent=t?n:""),i&&(i.textContent=t?"":n)}_onFormSubmit(){let e=this._bankSelect.options[this._bankSelect.selectedIndex];e&&(this._createOrUpdateHiddenField("hiddenBankName","bankName",e.dataset.bankName||""),this._createOrUpdateHiddenField("hiddenBankCode","bankCode",this._bankSelect.value))}_createOrUpdateHiddenField(e,t,n){let s=this.el.querySelector(`#${e}`);s||((s=document.createElement("input")).type="hidden",s.id=e,s.name=t,this.el.appendChild(s)),s.value=n}}}}]); \ No newline at end of file diff --git a/src/Resources/config/kommandhub.png b/src/Resources/config/kommandhub.png new file mode 100644 index 0000000..00bc7d2 Binary files /dev/null and b/src/Resources/config/kommandhub.png differ diff --git a/src/Resources/config/plugin.png b/src/Resources/config/plugin.png index c437641..59be608 100644 Binary files a/src/Resources/config/plugin.png and b/src/Resources/config/plugin.png differ diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index f957e18..bde08fd 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -3,6 +3,17 @@ services: autowire: true autoconfigure: true public: false + # Give this plugin's services the ConfigurableLogger wherever they type-hint + # PSR-3, without touching the container-wide Psr\Log\LoggerInterface alias. + # + # Aliasing that globally rebinds LoggerInterface for *every* autowired + # consumer in the installation, including Shopware core and other plugins. + # Two plugins doing it means the last one compiled wins, so sibling plugins + # (this one and KommandhubFlutterwaveV3SW) would silently log through each + # other's logger and each other's debug toggle. A bind is scoped to the + # services defined in this file, so it cannot collide. + bind: + Psr\Log\LoggerInterface $logger: '@Kommandhub\PaystackSW\Logging\ConfigurableLogger' Kommandhub\PaystackSW\: resource: '../../*' @@ -41,11 +52,10 @@ services: arguments: $orderTransactionCaptureRefundRepository: '@order_transaction_capture_refund.repository' + # The explicit $logger argument overrides the bind above, so the wrapper + # decorates the real monolog channel instead of recursing into itself. Kommandhub\PaystackSW\Logging\ConfigurableLogger: arguments: $logger: '@monolog.logger.paystack_channel' tags: - { name: 'monolog.logger', channel: 'paystack_channel' } - - Psr\Log\LoggerInterface: - alias: Kommandhub\PaystackSW\Logging\ConfigurableLogger diff --git a/src/Resources/config/shopware.png b/src/Resources/config/shopware.png deleted file mode 100644 index fa8d91d..0000000 Binary files a/src/Resources/config/shopware.png and /dev/null differ diff --git a/src/Resources/public/administration/.vite/entrypoints.json b/src/Resources/public/administration/.vite/entrypoints.json index d45bddd..3dd9e40 100644 --- a/src/Resources/public/administration/.vite/entrypoints.json +++ b/src/Resources/public/administration/.vite/entrypoints.json @@ -7,7 +7,7 @@ ], "dynamic": [], "js": [ - "/bundles/kommandhubpaystacksw/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js" + "/bundles/kommandhubpaystacksw/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js" ], "legacy": false, "preload": [] diff --git a/src/Resources/public/administration/.vite/manifest.json b/src/Resources/public/administration/.vite/manifest.json index 2d1c504..2faebf7 100644 --- a/src/Resources/public/administration/.vite/manifest.json +++ b/src/Resources/public/administration/.vite/manifest.json @@ -1,11 +1,18 @@ { "main.js": { - "file": "assets/kommandhub-paystack-s-w-DpuWP_xG.js", + "file": "assets/kommandhub-paystack-s-w-CbnlwT5p.js", "name": "kommandhub-paystack-s-w", "src": "main.js", "isEntry": true, "css": [ "assets/kommandhub-paystack-s-w-Bqi7SZ4U.css" + ], + "assets": [ + "assets/icon-DCLC8I4X.png" ] + }, + "view/kommandhub-paystack-detail/icon.png": { + "file": "assets/icon-DCLC8I4X.png", + "src": "view/kommandhub-paystack-detail/icon.png" } } \ No newline at end of file diff --git a/src/Resources/public/administration/assets/icon-DCLC8I4X.png b/src/Resources/public/administration/assets/icon-DCLC8I4X.png new file mode 100644 index 0000000..7bea047 Binary files /dev/null and b/src/Resources/public/administration/assets/icon-DCLC8I4X.png differ diff --git a/src/Resources/public/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js b/src/Resources/public/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js similarity index 57% rename from src/Resources/public/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js rename to src/Resources/public/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js index 25ca0cc..cd62fe5 100644 --- a/src/Resources/public/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js +++ b/src/Resources/public/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js @@ -1,2 +1,2 @@ -const f={"kommandhub-paystack-detail":{title:"Paystack",summary:{chargedAmount:"Montant débité",paymentChannel:"Canal de paiement"},grid:{reference:"Référence",transactionId:"ID de transaction",processingFee:"Frais de traitement",state:"Statut",verifiedAt:"Vérifié à",refund:"Remboursement",captures:"Captures",refunds:"Remboursements"},refund:{modalTitle:"Traiter le remboursement",listModalTitle:"Remboursements",amountLabel:"Montant du remboursement",amountPlaceholder:"Entrez le montant à rembourser",amountHelpText:"Le montant sera converti dans la plus petite unité monétaire (ex: kobo).",currencyLabel:"Devise",customerNoteLabel:"Note client",customerNotePlaceholder:"Note du marchand au client",merchantNoteLabel:"Note marchand",merchantNotePlaceholder:"Note du marchand pour lui-même",confirmButton:"Traiter le remboursement",errorAmountTooHigh:"Le montant du remboursement ne peut pas dépasser {maxAmount}.",errorAmountTooLow:"Le montant du remboursement doit être d'au moins {minAmount}."},captures:{grid:{amount:"Montant",state:"Statut",externalReference:"Référence externe",createdAt:"Créé le"}},refunds:{grid:{amount:"Montant",state:"Statut",externalReference:"Référence externe",reason:"Raison",createdAt:"Créé le"}},header:"Transactions Paystack",emptyState:{title:"Aucune transaction Paystack trouvée",subline:"Cette commande n'a pas été traitée via Paystack ou les détails de la transaction ne sont pas disponibles."}},"sw-order":{detail:{tabPaystack:"Paystack"}},"sw-privileges":{additional_permissions:{paystack:{label:"Paystack",refund:"Effectuer des remboursements Paystack"}}}},b={"kommandhub-paystack-detail":{title:"Paystack",summary:{chargedAmount:"Abgerechneter Betrag",paymentChannel:"Zahlungskanal"},grid:{reference:"Referenz",transactionId:"Transaktions-ID",processingFee:"Bearbeitungsgebühr",state:"Status",verifiedAt:"Verifiziert am",refund:"Rückerstattung",captures:"Erfassungen",refunds:"Rückerstattungen"},refund:{modalTitle:"Rückerstattung bearbeiten",listModalTitle:"Rückerstattungen",amountLabel:"Rückerstattungsbetrag",amountPlaceholder:"Geben Sie den zu erstattenden Betrag ein",amountHelpText:"Der Betrag wird in die kleinste Währungseinheit umgerechnet (z. B. Kobo).",currencyLabel:"Währung",customerNoteLabel:"Kundennotiz",customerNotePlaceholder:"Notiz vom Händler an den Kunden",merchantNoteLabel:"Händlernotiz",merchantNotePlaceholder:"Notiz vom Händler an sich selbst",confirmButton:"Rückerstattung bearbeiten",errorAmountTooHigh:"Der Rückerstattungsbetrag darf {maxAmount} nicht überschreiten.",errorAmountTooLow:"Der Rückerstattungsbetrag muss mindestens {minAmount} betragen."},captures:{grid:{amount:"Betrag",state:"Status",externalReference:"Externe Referenz",createdAt:"Erstellt am"}},refunds:{grid:{amount:"Betrag",state:"Status",externalReference:"Externe Referenz",reason:"Grund",createdAt:"Erstellt am"}},header:"Paystack-Transaktionen",emptyState:{title:"Keine Paystack-Transaktion gefunden",subline:"Diese Bestellung wurde nicht über Paystack abgewickelt oder die Transaktionsdetails sind nicht verfügbar."}},"sw-order":{detail:{tabPaystack:"Paystack"}},"sw-privileges":{additional_permissions:{paystack:{label:"Paystack",refund:"Paystack-Rückerstattungen durchführen"}}}},y={"kommandhub-paystack-detail":{title:"Paystack",summary:{chargedAmount:"Charged Amount",paymentChannel:"Payment Channel"},grid:{reference:"Reference",transactionId:"Transaction ID",processingFee:"Processing Fee",state:"Status",verifiedAt:"Verified At",refund:"Refund",captures:"Captures",refunds:"Refunds"},refund:{modalTitle:"Process Refund",listModalTitle:"Refunds",amountLabel:"Refund Amount",amountPlaceholder:"Enter amount to refund",amountHelpText:"The amount will be converted to the smallest currency unit (e.g. kobo).",currencyLabel:"Currency",customerNoteLabel:"Customer Note",customerNotePlaceholder:"Note from the merchant to the customer",merchantNoteLabel:"Merchant Note",merchantNotePlaceholder:"Note from the merchant to themselves",confirmButton:"Process Refund",errorAmountTooHigh:"The refund amount cannot exceed {maxAmount}.",errorAmountTooLow:"The refund amount must be at least {minAmount}."},captures:{grid:{amount:"Amount",state:"Status",externalReference:"External Reference",createdAt:"Created At"}},refunds:{grid:{amount:"Amount",state:"Status",externalReference:"External Reference",reason:"Reason",createdAt:"Created At"}},header:"Paystack Transactions",emptyState:{title:"No Paystack Transaction Found",subline:"This order was not processed via Paystack or the transaction details are unavailable."}},"sw-order":{detail:{tabPaystack:"Paystack"}},"sw-privileges":{additional_permissions:{paystack:{label:"Paystack",refund:"Process Paystack refunds"}}}},{Classes:m}=Shopware;class _ extends m.ApiService{constructor(t,a,n="paystack"){super(t,a,n),this.name="paystackRefundService"}refund(t){return this.httpClient.post("_action/paystack/refund",t,{headers:this.getBasicHeaders()}).then(a=>m.ApiService.handleResponse(a))}}Shopware.Service("privileges").addPrivilegeMappingEntry({category:"additional_permissions",parent:null,key:"paystack",roles:{refund:{privileges:[],dependencies:["order.editor"]}}});const g=`{% block sw_order_detail_content_tabs_extension %} {% block sw_order_detail_content_tabs_paystack %} {% block sw_order_detail_content_tabs_paystack_item %} {% block sw_order_detail_content_tabs_paystack_label %} {{ $t('sw-order.detail.tabPaystack') }} {% endblock %} {% endblock %} {% endblock %} {% block sw_order_detail_content_tabs_paystack_parent %} {% parent %} {% endblock %} {% endblock %}`,k="Kommandhub\\PaystackSW\\Checkout\\Payment\\Handler\\PaystackPaymentHandler";function l(e){return(e==null?void 0:e.code)==="ECONNABORTED"||(e==null?void 0:e.name)==="AbortError"||(e==null?void 0:e.message)==="Request aborted"}Shopware.Component.override("sw-order-detail",{template:g,inject:["repositoryFactory","systemConfigApiService"],props:{orderId:{type:String,required:!1,default:null}},data(){return{isLoading:!0,paystackOrder:null,config:{}}},computed:{orderCriteria(){const e=this.$super("orderCriteria");return e.addAssociation("transactions.paymentMethod"),e.addAssociation("transactions.stateMachineState"),e.addAssociation("transactions.captures.refunds.stateMachineState"),e.addAssociation("transactions.captures.stateMachineState"),e},orderRepository(){return this.repositoryFactory.create("order")},isPaystackPayment(){var e,t;return(t=(e=this.paystackOrder)==null?void 0:e.transactions)!=null&&t.length?this.paystackOrder.transactions.some(a=>{var n;return((n=a.paymentMethod)==null?void 0:n.handlerIdentifier)===k}):!1}},watch:{orderId(){this.fetchOrder()}},created(){this.fetchOrder()},methods:{async fetchOrder(){var e;if(!this.orderId){this.isLoading=!1;return}this.isLoading=!0;try{this.paystackOrder=await this.orderRepository.get(this.orderId,Shopware.Context.api,this.orderCriteria),(e=this.paystackOrder)!=null&&e.salesChannelId&&(this.config=await this.systemConfigApiService.getValues("KommandhubPaystackSW.config",this.paystackOrder.salesChannelId))}catch(t){if(l(t))return;console.error("[Paystack] Failed to load order details:",(t==null?void 0:t.message)??t)}finally{this.isLoading=!1}}}});const A=`{% block sw_order_document_card %} {% block kommandhub_paystack_detail_card %} {% block kommandhub_paystack_detail_card_banner %} {% block kommandhub_paystack_detail_card_banner_wrapper %}
{% block kommandhub_paystack_detail_card_banner_icon %} Paystack logo {% endblock %} {% block kommandhub_paystack_detail_card_banner_title %}

{{ $t('kommandhub-paystack-detail.header') }}

{% endblock %}
{% endblock %} {% endblock %} {% block kommandhub_paystack_detail_card_grid %} {% endblock %}
{% endblock %} {% block kommandhub_paystack_detail_captures_card %} {% endblock %} {% block kommandhub_paystack_detail_refunds_list_modal %} {% block kommandhub_paystack_detail_refunds_list_grid %} {% block kommandhub_paystack_detail_refunds_list_grid_table %} {% endblock %} {% endblock %} {% block kommandhub_paystack_detail_refunds_list_modal_footer %} {% endblock %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal %} {% block kommandhub_paystack_detail_refund_modal_content %} {% block kommandhub_paystack_detail_refund_modal_form %} {% block kommandhub_paystack_detail_refund_modal_amount_field %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_currency_field %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_customer_note_field %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_merchant_note_field %} {% endblock %} {% endblock %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_footer %} {% endblock %} {% endblock %} {% endblock %}`,R="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAGEklEQVR4nOzd3WuW9x3H8c+daB4MZokxGoPJ1Di3mT2wOWQDPdkYA3e2gw1Bd7Cxk7GV1hb6QE89KhTqQaHFgwqlpdKKLX1AKEq1lZYSrB5oa4tVW+LTrUbjQx40d0k9SH24E1P8+P1e5f36Cz7cvL28uPK77nuGOn8n4F6riR6AHybCggVhwYKwYEFYsCAsWBAWLAgLFoQFC8KCBWHBgrBgQViwICxYEBYsCAsWhAULwoIFYcGCsGBBWLAgLFgQFiwICxaEBQvCggVhwYKwYEFYsCAsWBAWLAgLFoQFC8KCBWHBgrBgQViwICxYEBYsCAsWhAULwoIFYcGCsGBBWLAgLFgQFiwICxaEBYsZ0QPuQnunlq9Qw6zoHQkMX9WhfTr1VfSOqZVS/3Rvc6v+/YQWdEfvSOZMvzZv1Ply9I7J1Gp2Z/SGKpqa9egmtbRF78inabZ+/2f1vTd+Acsq8T3W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R/xb5hllav0ZJe1ed73DA6rC8/1Z63dfli9JR0cj9u+PUftPYB1eS+rFYq2rZZH70bvSOXxE/eF3/7xQ35H7uXSlq+Qv1H8z+0vJ8SXwzW/j96wXT8/b/RC3LJGtbs1oK9DN3YpM5F0SMSyRpWc0v0gumb2xG9IJGsYRVRiQ9zAp8FLAgLFoQFC8KCBWHBgrBgQViwICxYENa9UxmLXpBI1rAGB6IXTF/5ZPSCRLKGdfG8LpyNHjEdV6+o/2j0iESyhiXppU3RC6Zj67PRC3JJfNBvoKzT/frFyuxn/W6cIN33fvSOXHIfTb5x5n3VGi3+mWbWRU+5zbVRHf+cM+93lD4sFFPieywUGWHBgrBgQViwICxYEBYsCAsWhAULwoIFYcGCsGBBWLAgLFgQFiwICxaEBQvCggVhwYKwYEFYsCAsWBAWLAgLFoQFC8KCBWHBgrBgQViwICxYEBYsCAsWhAULwoIFYcGCsGBBWLAgLFgQFiwICxaEBQvCggVhwYKwYEFYsCAsWBAWLAgLFt8EAAD//+L72rm8xd4DAAAAAElFTkSuQmCC",C={JPY:0,XOF:0,XAF:0,KMF:0,GNF:0,CLP:0,RWF:0,UGX:0,BHD:3,IQD:3,JOD:3,KWD:3,LYD:3,OMR:3,TND:3},w=["completed","in_progress"],v="failed";function u(e){return C[e]??2}function p(e,t){return Number(Number(e??0).toFixed(u(t)))}function S(e,t){return Number(e??50)/10**u(t)}function T(e){return e.reduce((t,a)=>{var n,r;return w.includes((n=a.stateMachineState)==null?void 0:n.technicalName)?t+Number(((r=a.amount)==null?void 0:r.totalPrice)??0):t},0)}function L({transactionAmount:e,captures:t=[],refunds:a=[],currency:n}){const r=T(a);if(t.length===0)return p(Math.max(0,Number(e??0)-r),n);const o=t.reduce((s,i)=>{var d,c;return((d=i.stateMachineState)==null?void 0:d.technicalName)!==v?s+Number(((c=i.amount)==null?void 0:c.totalPrice)??0):s},0);return p(Math.max(0,o-r),n)}const{Store:F,Mixin:P}=Shopware,{Criteria:h}=Shopware.Data;Shopware.Component.register("kommandhub-paystack-detail",{template:A,mixins:[P.getByName("notification")],metaInfo(){return{title:this.$t("kommandhub-paystack-detail.title")}},inject:["repositoryFactory","paystackRefundService","systemConfigApiService","acl"],data(){return{showRefundModal:!1,refundAmount:null,refundCurrency:null,customerNote:null,merchantNote:null,isRefundLoading:!1,isRefundSuccess:!1,activeTransaction:null,activeCapture:null,showRefundsListModal:!1,captures:[],refunds:[],isLoading:!1,config:{}}},computed:{orderRepository(){return this.repositoryFactory.create("order")},order(){var e;return(e=F.get("swOrderDetail"))==null?void 0:e.order},orderChanges(){var e;return!this.order||!((e=this.order)!=null&&e.id)||!this.orderRepository?!1:this.orderRepository.hasChanges(this.order)},transactionCaptureRepository(){return this.repositoryFactory.create("order_transaction_capture")},paystackTransaction(){var e;return!this.order||!((e=this.order)!=null&&e.transactions)?null:this.order.transactions.find(t=>{var a;return((a=t.paymentMethod)==null?void 0:a.handlerIdentifier)===k||t.customFields&&t.customFields.paystack_reference})},isTransactionRefunded(){var e,t;return((t=(e=this.paystackTransaction)==null?void 0:e.stateMachineState)==null?void 0:t.technicalName)==="refunded"},paystackTransactionData(){var e,t,a,n,r,o,s,i;return(e=this.paystackTransaction)!=null&&e.id?[{id:this.paystackTransaction.id,amount:(t=this.paystackTransaction.customFields)==null?void 0:t.paystack_amount,currency:(a=this.paystackTransaction.customFields)==null?void 0:a.paystack_currency,channel:(n=this.paystackTransaction.customFields)==null?void 0:n.paystack_payment_type,reference:(r=this.paystackTransaction.customFields)==null?void 0:r.paystack_reference,transactionId:(o=this.paystackTransaction.customFields)==null?void 0:o.paystack_transaction_id,fee:(s=this.paystackTransaction.customFields)==null?void 0:s.paystack_transaction_fee,verifiedAt:(i=this.paystackTransaction.customFields)==null?void 0:i.paystack_verified_at,state:this.paystackTransaction.stateMachineState}]:[]},paystackTransactionColumns(){return[{property:"amount",label:"kommandhub-paystack-detail.summary.chargedAmount",primary:!0},{property:"reference",label:"kommandhub-paystack-detail.grid.reference"},{property:"transactionId",label:"kommandhub-paystack-detail.grid.transactionId"},{property:"fee",label:"kommandhub-paystack-detail.grid.processingFee"},{property:"state",label:"kommandhub-paystack-detail.grid.state"},{property:"verifiedAt",label:"kommandhub-paystack-detail.grid.verifiedAt"}]},paystackCaptureColumns(){return[{property:"amount",label:"kommandhub-paystack-detail.captures.grid.amount",primary:!0},{property:"state",label:"kommandhub-paystack-detail.captures.grid.state"},{property:"externalReference",label:"kommandhub-paystack-detail.captures.grid.externalReference"},{property:"createdAt",label:"kommandhub-paystack-detail.captures.grid.createdAt"}]},paystackRefundColumns(){return[{property:"amount",label:"kommandhub-paystack-detail.refunds.grid.amount",primary:!0},{property:"state",label:"kommandhub-paystack-detail.refunds.grid.state"},{property:"externalReference",label:"kommandhub-paystack-detail.refunds.grid.externalReference"},{property:"reason",label:"kommandhub-paystack-detail.refunds.grid.reason"},{property:"createdAt",label:"kommandhub-paystack-detail.refunds.grid.createdAt"}]},activeCurrency(){var e,t;return this.refundCurrency||((t=(e=this.paystackTransaction)==null?void 0:e.customFields)==null?void 0:t.paystack_currency)},maxRefundableAmount(){var e;return this.paystackTransaction?L({transactionAmount:Number(((e=this.paystackTransaction.customFields)==null?void 0:e.paystack_amount)??0),captures:this.captures,refunds:this.refunds,currency:this.activeCurrency}):0},canRefund(){return this.refundEnabled&&this.acl.can("paystack.refund")&&!this.isTransactionRefunded&&this.maxRefundableAmount>=this.minRefundableAmount},paystackRefunds(){var e;return(e=this.activeCapture)!=null&&e.id?this.refunds.filter(t=>t.captureId===this.activeCapture.id):this.refunds},currencyFilter(){return Shopware.Filter.getByName("currency")},paystackIcon(){return R},refundEnabled(){return this.config["KommandhubPaystackSW.config.refundEnabled"]!==!1},minPaystackRefundAmount(){return this.config["KommandhubPaystackSW.config.minimumRefundAmount"]??50},minRefundableAmount(){return S(this.minPaystackRefundAmount,this.activeCurrency)},refundAmountDigits(){return u(this.activeCurrency)}},watch:{paystackTransaction:{immediate:!0,handler(e){e!=null&&e.id&&this.loadCapturesAndRefunds()}},"order.salesChannelId":{immediate:!0,handler(e){e&&this.loadConfig(e)}}},methods:{async loadConfig(e){this.config=await this.systemConfigApiService.getValues("KommandhubPaystackSW.config",e)},transactionCaptureCriteria(e){const t=new h;return t.addFilter(h.equals("orderTransactionId",e)),t.addAssociation("stateMachineState"),t.addAssociation("refunds"),t.addAssociation("refunds.stateMachineState"),t},async loadCapturesAndRefunds(){var e;if(!(!((e=this.paystackTransaction)!=null&&e.id)||this.isLoading)){this.isLoading=!0;try{const a=(await this.transactionCaptureRepository.search(this.transactionCaptureCriteria(this.paystackTransaction.id),Shopware.Context.api)).map(r=>{var o,s,i;return{...r,state:((s=(o=r.stateMachineState)==null?void 0:o.translated)==null?void 0:s.name)||((i=r.stateMachineState)==null?void 0:i.name)||""}}),n=[];a.forEach(r=>{var o;(o=r.refunds)!=null&&o.length&&r.refunds.forEach(s=>{var i,d,c;n.push({...s,state:((d=(i=s.stateMachineState)==null?void 0:i.translated)==null?void 0:d.name)||((c=s.stateMachineState)==null?void 0:c.name)||""})})}),this.captures=a,this.refunds=n}catch(t){if(l(t))return;this.createNotificationError({message:t.message})}finally{this.isLoading=!1}}},onOpenRefundModal(){var e;this.activeTransaction=this.paystackTransaction,this.activeCapture=null,this.refundCurrency=(e=this.paystackTransaction.customFields)==null?void 0:e.paystack_currency,this.refundAmount=this.maxRefundableAmount,this.showRefundModal=!0},onOpenRefundsListModal(e){this.activeCapture=e,this.showRefundsListModal=!0},onCloseRefundsListModal(){this.activeCapture=null,this.showRefundsListModal=!1},onCloseRefundModal(){this.showRefundModal=!1,this.activeTransaction=null,this.refundAmount=null,this.refundCurrency=null,this.customerNote=null,this.merchantNote=null},onConfirmRefund(){var t,a;if(this.refundAmountthis.maxRefundableAmount){this.createNotificationError({message:this.$t("kommandhub-paystack-detail.refund.errorAmountTooHigh",{maxAmount:this.currencyFilter(this.maxRefundableAmount,this.refundCurrency)})});return}this.isRefundLoading=!0;const e={transaction:(t=this.activeTransaction.customFields)==null?void 0:t.paystack_reference,orderTransactionId:this.activeTransaction.id,orderTransactionCaptureId:(a=this.activeCapture)==null?void 0:a.id,amount:this.refundAmount,currency:this.refundCurrency,customer_note:this.customerNote,merchant_note:this.merchantNote};this.paystackRefundService.refund(e).then(async()=>{this.isRefundSuccess=!0,await this.loadCapturesAndRefunds()}).catch(n=>{var s,i;if(l(n))return;const r=(s=n.response)==null?void 0:s.data;let o=(r==null?void 0:r.error)||n.message;(i=r==null?void 0:r.meta)!=null&&i.nextStep&&(o+=` ${r.meta.nextStep}`),this.createNotificationError({message:o})}).finally(()=>{this.isRefundLoading=!1})},onRefundFinished(){this.isRefundSuccess=!1,this.onCloseRefundModal()}}});Shopware.Locale.extend("fr-FR",f);Shopware.Locale.extend("de-DE",b);Shopware.Locale.extend("en-GB",y);Shopware.Service().register("paystackRefundService",e=>{const t=Shopware.Application.getContainer("init");return new _(t.httpClient,e.loginService)});Shopware.Module.register("kommandhub-paystack-detail",{routeMiddleware(e,t){if(t.name==="sw.order.detail"){const a="kommandhub.paystack.detail";t.children.some(n=>n.name===a)||t.children.push({name:a,path:"kommandhub/paystack",component:"kommandhub-paystack-detail",meta:{parentPath:"sw.order.detail",privilege:"order.viewer"},props:{default:n=>({orderId:n.params.id.toLowerCase()})}})}e(t)}}); -//# sourceMappingURL=kommandhub-paystack-s-w-DpuWP_xG.js.map +const f={"kommandhub-paystack-detail":{title:"Paystack",summary:{chargedAmount:"Montant débité",paymentChannel:"Canal de paiement"},grid:{reference:"Référence",transactionId:"ID de transaction",processingFee:"Frais de traitement",state:"Statut",verifiedAt:"Vérifié à",refund:"Remboursement",captures:"Captures",refunds:"Remboursements"},refund:{modalTitle:"Traiter le remboursement",listModalTitle:"Remboursements",amountLabel:"Montant du remboursement",amountPlaceholder:"Entrez le montant à rembourser",amountHelpText:"Le montant sera converti dans la plus petite unité monétaire (ex: kobo).",currencyLabel:"Devise",customerNoteLabel:"Note client",customerNotePlaceholder:"Note du marchand au client",merchantNoteLabel:"Note marchand",merchantNotePlaceholder:"Note du marchand pour lui-même",confirmButton:"Traiter le remboursement",errorAmountTooHigh:"Le montant du remboursement ne peut pas dépasser {maxAmount}.",errorAmountTooLow:"Le montant du remboursement doit être d'au moins {minAmount}."},captures:{grid:{amount:"Montant",state:"Statut",externalReference:"Référence externe",createdAt:"Créé le"}},refunds:{grid:{amount:"Montant",state:"Statut",externalReference:"Référence externe",reason:"Raison",createdAt:"Créé le"}},header:"Transactions Paystack",emptyState:{title:"Aucune transaction Paystack trouvée",subline:"Cette commande n'a pas été traitée via Paystack ou les détails de la transaction ne sont pas disponibles."}},"sw-order":{detail:{tabPaystack:"Paystack"}},"sw-privileges":{additional_permissions:{paystack:{label:"Paystack",refund:"Effectuer des remboursements Paystack"}}}},y={"kommandhub-paystack-detail":{title:"Paystack",summary:{chargedAmount:"Abgerechneter Betrag",paymentChannel:"Zahlungskanal"},grid:{reference:"Referenz",transactionId:"Transaktions-ID",processingFee:"Bearbeitungsgebühr",state:"Status",verifiedAt:"Verifiziert am",refund:"Rückerstattung",captures:"Erfassungen",refunds:"Rückerstattungen"},refund:{modalTitle:"Rückerstattung bearbeiten",listModalTitle:"Rückerstattungen",amountLabel:"Rückerstattungsbetrag",amountPlaceholder:"Geben Sie den zu erstattenden Betrag ein",amountHelpText:"Der Betrag wird in die kleinste Währungseinheit umgerechnet (z. B. Kobo).",currencyLabel:"Währung",customerNoteLabel:"Kundennotiz",customerNotePlaceholder:"Notiz vom Händler an den Kunden",merchantNoteLabel:"Händlernotiz",merchantNotePlaceholder:"Notiz vom Händler an sich selbst",confirmButton:"Rückerstattung bearbeiten",errorAmountTooHigh:"Der Rückerstattungsbetrag darf {maxAmount} nicht überschreiten.",errorAmountTooLow:"Der Rückerstattungsbetrag muss mindestens {minAmount} betragen."},captures:{grid:{amount:"Betrag",state:"Status",externalReference:"Externe Referenz",createdAt:"Erstellt am"}},refunds:{grid:{amount:"Betrag",state:"Status",externalReference:"Externe Referenz",reason:"Grund",createdAt:"Erstellt am"}},header:"Paystack-Transaktionen",emptyState:{title:"Keine Paystack-Transaktion gefunden",subline:"Diese Bestellung wurde nicht über Paystack abgewickelt oder die Transaktionsdetails sind nicht verfügbar."}},"sw-order":{detail:{tabPaystack:"Paystack"}},"sw-privileges":{additional_permissions:{paystack:{label:"Paystack",refund:"Paystack-Rückerstattungen durchführen"}}}},b={"kommandhub-paystack-detail":{title:"Paystack",summary:{chargedAmount:"Charged Amount",paymentChannel:"Payment Channel"},grid:{reference:"Reference",transactionId:"Transaction ID",processingFee:"Processing Fee",state:"Status",verifiedAt:"Verified At",refund:"Refund",captures:"Captures",refunds:"Refunds"},refund:{modalTitle:"Process Refund",listModalTitle:"Refunds",amountLabel:"Refund Amount",amountPlaceholder:"Enter amount to refund",amountHelpText:"The amount will be converted to the smallest currency unit (e.g. kobo).",currencyLabel:"Currency",customerNoteLabel:"Customer Note",customerNotePlaceholder:"Note from the merchant to the customer",merchantNoteLabel:"Merchant Note",merchantNotePlaceholder:"Note from the merchant to themselves",confirmButton:"Process Refund",errorAmountTooHigh:"The refund amount cannot exceed {maxAmount}.",errorAmountTooLow:"The refund amount must be at least {minAmount}."},captures:{grid:{amount:"Amount",state:"Status",externalReference:"External Reference",createdAt:"Created At"}},refunds:{grid:{amount:"Amount",state:"Status",externalReference:"External Reference",reason:"Reason",createdAt:"Created At"}},header:"Paystack Transactions",emptyState:{title:"No Paystack Transaction Found",subline:"This order was not processed via Paystack or the transaction details are unavailable."}},"sw-order":{detail:{tabPaystack:"Paystack"}},"sw-privileges":{additional_permissions:{paystack:{label:"Paystack",refund:"Process Paystack refunds"}}}},{Classes:m}=Shopware;class _ extends m.ApiService{constructor(t,a,n="paystack"){super(t,a,n),this.name="paystackRefundService"}refund(t){return this.httpClient.post("_action/paystack/refund",t,{headers:this.getBasicHeaders()}).then(a=>m.ApiService.handleResponse(a))}}Shopware.Service("privileges").addPrivilegeMappingEntry({category:"additional_permissions",parent:null,key:"paystack",roles:{refund:{privileges:[],dependencies:["order.editor"]}}});const g=`{% block sw_order_detail_content_tabs_extension %} {% block sw_order_detail_content_tabs_paystack %} {% block sw_order_detail_content_tabs_paystack_item %} {% block sw_order_detail_content_tabs_paystack_label %} {{ $t('sw-order.detail.tabPaystack') }} {% endblock %} {% endblock %} {% endblock %} {% block sw_order_detail_content_tabs_paystack_parent %} {% parent %} {% endblock %} {% endblock %}`,h="Kommandhub\\PaystackSW\\Checkout\\Payment\\Handler\\PaystackPaymentHandler";function l(e){return(e==null?void 0:e.code)==="ECONNABORTED"||(e==null?void 0:e.name)==="AbortError"||(e==null?void 0:e.message)==="Request aborted"}Shopware.Component.override("sw-order-detail",{template:g,inject:["repositoryFactory","systemConfigApiService"],props:{orderId:{type:String,required:!1,default:null}},data(){return{isLoading:!0,paystackOrder:null,config:{}}},computed:{orderCriteria(){const e=this.$super("orderCriteria");return e.addAssociation("transactions.paymentMethod"),e.addAssociation("transactions.stateMachineState"),e.addAssociation("transactions.captures.refunds.stateMachineState"),e.addAssociation("transactions.captures.stateMachineState"),e},orderRepository(){return this.repositoryFactory.create("order")},isPaystackPayment(){var e,t;return(t=(e=this.paystackOrder)==null?void 0:e.transactions)!=null&&t.length?this.paystackOrder.transactions.some(a=>{var n;return((n=a.paymentMethod)==null?void 0:n.handlerIdentifier)===h}):!1}},watch:{orderId(){this.fetchOrder()}},created(){this.fetchOrder()},methods:{async fetchOrder(){var e;if(!this.orderId){this.isLoading=!1;return}this.isLoading=!0;try{this.paystackOrder=await this.orderRepository.get(this.orderId,Shopware.Context.api,this.orderCriteria),(e=this.paystackOrder)!=null&&e.salesChannelId&&(this.config=await this.systemConfigApiService.getValues("KommandhubPaystackSW.config",this.paystackOrder.salesChannelId))}catch(t){if(l(t))return;console.error("[Paystack] Failed to load order details:",(t==null?void 0:t.message)??t)}finally{this.isLoading=!1}}}});const R=`{% block sw_order_document_card %} {% block kommandhub_paystack_detail_card %} {% block kommandhub_paystack_detail_card_banner %} {% block kommandhub_paystack_detail_card_banner_wrapper %}
{% block kommandhub_paystack_detail_card_banner_icon %} Paystack logo {% endblock %} {% block kommandhub_paystack_detail_card_banner_title %}

{{ $t('kommandhub-paystack-detail.header') }}

{% endblock %}
{% endblock %} {% endblock %} {% block kommandhub_paystack_detail_card_grid %} {% endblock %}
{% endblock %} {% block kommandhub_paystack_detail_captures_card %} {% endblock %} {% block kommandhub_paystack_detail_refunds_list_modal %} {% block kommandhub_paystack_detail_refunds_list_grid %} {% block kommandhub_paystack_detail_refunds_list_grid_table %} {% endblock %} {% endblock %} {% block kommandhub_paystack_detail_refunds_list_modal_footer %} {% endblock %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal %} {% block kommandhub_paystack_detail_refund_modal_content %} {% block kommandhub_paystack_detail_refund_modal_form %} {% block kommandhub_paystack_detail_refund_modal_amount_field %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_currency_field %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_customer_note_field %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_merchant_note_field %} {% endblock %} {% endblock %} {% endblock %} {% block kommandhub_paystack_detail_refund_modal_footer %} {% endblock %} {% endblock %} {% endblock %}`,A="/bundles/kommandhubpaystacksw/administration/assets/icon-DCLC8I4X.png",w={JPY:0,XOF:0,XAF:0,KMF:0,GNF:0,CLP:0,RWF:0,UGX:0,BHD:3,IQD:3,JOD:3,KWD:3,LYD:3,OMR:3,TND:3},C=["completed","in_progress"],v="failed";function u(e){return w[e]??2}function p(e,t){return Number(Number(e??0).toFixed(u(t)))}function T(e,t){return Number(e??50)/10**u(t)}function S(e){return e.reduce((t,a)=>{var n,r;return C.includes((n=a.stateMachineState)==null?void 0:n.technicalName)?t+Number(((r=a.amount)==null?void 0:r.totalPrice)??0):t},0)}function P({transactionAmount:e,captures:t=[],refunds:a=[],currency:n}){const r=S(a);if(t.length===0)return p(Math.max(0,Number(e??0)-r),n);const o=t.reduce((s,i)=>{var d,c;return((d=i.stateMachineState)==null?void 0:d.technicalName)!==v?s+Number(((c=i.amount)==null?void 0:c.totalPrice)??0):s},0);return p(Math.max(0,o-r),n)}const{Store:N,Mixin:x}=Shopware,{Criteria:k}=Shopware.Data;Shopware.Component.register("kommandhub-paystack-detail",{template:R,mixins:[x.getByName("notification")],metaInfo(){return{title:this.$t("kommandhub-paystack-detail.title")}},inject:["repositoryFactory","paystackRefundService","systemConfigApiService","acl"],data(){return{showRefundModal:!1,refundAmount:null,refundCurrency:null,customerNote:null,merchantNote:null,isRefundLoading:!1,isRefundSuccess:!1,activeTransaction:null,activeCapture:null,showRefundsListModal:!1,captures:[],refunds:[],isLoading:!1,config:{}}},computed:{orderRepository(){return this.repositoryFactory.create("order")},order(){var e;return(e=N.get("swOrderDetail"))==null?void 0:e.order},orderChanges(){var e;return!this.order||!((e=this.order)!=null&&e.id)||!this.orderRepository?!1:this.orderRepository.hasChanges(this.order)},transactionCaptureRepository(){return this.repositoryFactory.create("order_transaction_capture")},paystackTransaction(){var e;return!this.order||!((e=this.order)!=null&&e.transactions)?null:this.order.transactions.find(t=>{var a;return((a=t.paymentMethod)==null?void 0:a.handlerIdentifier)===h||t.customFields&&t.customFields.paystack_reference})},isTransactionRefunded(){var e,t;return((t=(e=this.paystackTransaction)==null?void 0:e.stateMachineState)==null?void 0:t.technicalName)==="refunded"},paystackTransactionData(){var e,t,a,n,r,o,s,i;return(e=this.paystackTransaction)!=null&&e.id?[{id:this.paystackTransaction.id,amount:(t=this.paystackTransaction.customFields)==null?void 0:t.paystack_amount,currency:(a=this.paystackTransaction.customFields)==null?void 0:a.paystack_currency,channel:(n=this.paystackTransaction.customFields)==null?void 0:n.paystack_payment_type,reference:(r=this.paystackTransaction.customFields)==null?void 0:r.paystack_reference,transactionId:(o=this.paystackTransaction.customFields)==null?void 0:o.paystack_transaction_id,fee:(s=this.paystackTransaction.customFields)==null?void 0:s.paystack_transaction_fee,verifiedAt:(i=this.paystackTransaction.customFields)==null?void 0:i.paystack_verified_at,state:this.paystackTransaction.stateMachineState}]:[]},paystackTransactionColumns(){return[{property:"amount",label:"kommandhub-paystack-detail.summary.chargedAmount",primary:!0},{property:"reference",label:"kommandhub-paystack-detail.grid.reference"},{property:"transactionId",label:"kommandhub-paystack-detail.grid.transactionId"},{property:"fee",label:"kommandhub-paystack-detail.grid.processingFee"},{property:"state",label:"kommandhub-paystack-detail.grid.state"},{property:"verifiedAt",label:"kommandhub-paystack-detail.grid.verifiedAt"}]},paystackCaptureColumns(){return[{property:"amount",label:"kommandhub-paystack-detail.captures.grid.amount",primary:!0},{property:"state",label:"kommandhub-paystack-detail.captures.grid.state"},{property:"externalReference",label:"kommandhub-paystack-detail.captures.grid.externalReference"},{property:"createdAt",label:"kommandhub-paystack-detail.captures.grid.createdAt"}]},paystackRefundColumns(){return[{property:"amount",label:"kommandhub-paystack-detail.refunds.grid.amount",primary:!0},{property:"state",label:"kommandhub-paystack-detail.refunds.grid.state"},{property:"externalReference",label:"kommandhub-paystack-detail.refunds.grid.externalReference"},{property:"reason",label:"kommandhub-paystack-detail.refunds.grid.reason"},{property:"createdAt",label:"kommandhub-paystack-detail.refunds.grid.createdAt"}]},activeCurrency(){var e,t;return this.refundCurrency||((t=(e=this.paystackTransaction)==null?void 0:e.customFields)==null?void 0:t.paystack_currency)},maxRefundableAmount(){var e;return this.paystackTransaction?P({transactionAmount:Number(((e=this.paystackTransaction.customFields)==null?void 0:e.paystack_amount)??0),captures:this.captures,refunds:this.refunds,currency:this.activeCurrency}):0},canRefund(){return this.refundEnabled&&this.acl.can("paystack.refund")&&!this.isTransactionRefunded&&this.maxRefundableAmount>=this.minRefundableAmount},paystackRefunds(){var e;return(e=this.activeCapture)!=null&&e.id?this.refunds.filter(t=>t.captureId===this.activeCapture.id):this.refunds},currencyFilter(){return Shopware.Filter.getByName("currency")},paystackIcon(){return A},refundEnabled(){return this.config["KommandhubPaystackSW.config.refundEnabled"]!==!1},minPaystackRefundAmount(){return this.config["KommandhubPaystackSW.config.minimumRefundAmount"]??50},minRefundableAmount(){return T(this.minPaystackRefundAmount,this.activeCurrency)},refundAmountDigits(){return u(this.activeCurrency)}},watch:{paystackTransaction:{immediate:!0,handler(e){e!=null&&e.id&&this.loadCapturesAndRefunds()}},"order.salesChannelId":{immediate:!0,handler(e){e&&this.loadConfig(e)}}},methods:{async loadConfig(e){this.config=await this.systemConfigApiService.getValues("KommandhubPaystackSW.config",e)},transactionCaptureCriteria(e){const t=new k;return t.addFilter(k.equals("orderTransactionId",e)),t.addAssociation("stateMachineState"),t.addAssociation("refunds"),t.addAssociation("refunds.stateMachineState"),t},async loadCapturesAndRefunds(){var e;if(!(!((e=this.paystackTransaction)!=null&&e.id)||this.isLoading)){this.isLoading=!0;try{const a=(await this.transactionCaptureRepository.search(this.transactionCaptureCriteria(this.paystackTransaction.id),Shopware.Context.api)).map(r=>{var o,s,i;return{...r,state:((s=(o=r.stateMachineState)==null?void 0:o.translated)==null?void 0:s.name)||((i=r.stateMachineState)==null?void 0:i.name)||""}}),n=[];a.forEach(r=>{var o;(o=r.refunds)!=null&&o.length&&r.refunds.forEach(s=>{var i,d,c;n.push({...s,state:((d=(i=s.stateMachineState)==null?void 0:i.translated)==null?void 0:d.name)||((c=s.stateMachineState)==null?void 0:c.name)||""})})}),this.captures=a,this.refunds=n}catch(t){if(l(t))return;this.createNotificationError({message:t.message})}finally{this.isLoading=!1}}},onOpenRefundModal(){var e;this.activeTransaction=this.paystackTransaction,this.activeCapture=null,this.refundCurrency=(e=this.paystackTransaction.customFields)==null?void 0:e.paystack_currency,this.refundAmount=this.maxRefundableAmount,this.showRefundModal=!0},onOpenRefundsListModal(e){this.activeCapture=e,this.showRefundsListModal=!0},onCloseRefundsListModal(){this.activeCapture=null,this.showRefundsListModal=!1},onCloseRefundModal(){this.showRefundModal=!1,this.activeTransaction=null,this.refundAmount=null,this.refundCurrency=null,this.customerNote=null,this.merchantNote=null},onConfirmRefund(){var t,a;if(this.refundAmountthis.maxRefundableAmount){this.createNotificationError({message:this.$t("kommandhub-paystack-detail.refund.errorAmountTooHigh",{maxAmount:this.currencyFilter(this.maxRefundableAmount,this.refundCurrency)})});return}this.isRefundLoading=!0;const e={transaction:(t=this.activeTransaction.customFields)==null?void 0:t.paystack_reference,orderTransactionId:this.activeTransaction.id,orderTransactionCaptureId:(a=this.activeCapture)==null?void 0:a.id,amount:this.refundAmount,currency:this.refundCurrency,customer_note:this.customerNote,merchant_note:this.merchantNote};this.paystackRefundService.refund(e).then(async()=>{this.isRefundSuccess=!0,await this.loadCapturesAndRefunds()}).catch(n=>{var s,i;if(l(n))return;const r=(s=n.response)==null?void 0:s.data;let o=(r==null?void 0:r.error)||n.message;(i=r==null?void 0:r.meta)!=null&&i.nextStep&&(o+=` ${r.meta.nextStep}`),this.createNotificationError({message:o})}).finally(()=>{this.isRefundLoading=!1})},onRefundFinished(){this.isRefundSuccess=!1,this.onCloseRefundModal()}}});Shopware.Locale.extend("fr-FR",f);Shopware.Locale.extend("de-DE",y);Shopware.Locale.extend("en-GB",b);Shopware.Service().register("paystackRefundService",e=>{const t=Shopware.Application.getContainer("init");return new _(t.httpClient,e.loginService)});Shopware.Module.register("kommandhub-paystack-detail",{routeMiddleware(e,t){if(t.name==="sw.order.detail"){const a="kommandhub.paystack.detail";t.children.some(n=>n.name===a)||t.children.push({name:a,path:"kommandhub/paystack",component:"kommandhub-paystack-detail",meta:{parentPath:"sw.order.detail",privilege:"order.viewer"},props:{default:n=>({orderId:n.params.id.toLowerCase()})}})}e(t)}}); +//# sourceMappingURL=kommandhub-paystack-s-w-CbnlwT5p.js.map diff --git a/src/Resources/public/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js.map b/src/Resources/public/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js.map new file mode 100644 index 0000000..fa97b94 --- /dev/null +++ b/src/Resources/public/administration/assets/kommandhub-paystack-s-w-CbnlwT5p.js.map @@ -0,0 +1 @@ +{"version":3,"file":"kommandhub-paystack-s-w-CbnlwT5p.js","sources":["../../../app/administration/src/service/paystack-refund.service.js","../../../app/administration/src/acl/index.js","../../../app/administration/src/module/sw-order/page/sw-order-detail/sw-order-detail.html.twig","../../../app/administration/src/util/paystack.js","../../../app/administration/src/module/sw-order/page/sw-order-detail/index.js","../../../app/administration/src/view/kommandhub-paystack-detail/kommandhub-paystack-detail.html.twig","../../../app/administration/src/view/kommandhub-paystack-detail/icon.png","../../../app/administration/src/service/refund-calculator.js","../../../app/administration/src/view/kommandhub-paystack-detail/index.js","../../../app/administration/src/main.js"],"sourcesContent":["const { Classes } = Shopware;\n\nclass PaystackRefundService extends Classes.ApiService {\n constructor(httpClient, loginService, apiEndpoint = 'paystack') {\n super(httpClient, loginService, apiEndpoint);\n this.name = 'paystackRefundService';\n }\n\n refund(payload) {\n return this.httpClient.post(\n '_action/paystack/refund',\n payload,\n {\n headers: this.getBasicHeaders(),\n }\n ).then((response) => {\n return Classes.ApiService.handleResponse(response);\n });\n }\n}\n\nexport default PaystackRefundService;\n","/**\n * Registers a dedicated \"Paystack refund\" admin permission so it can be granted\n * to roles independently of the generic order editor privilege. Appears as a\n * checkbox under Settings > Users & permissions > Roles > Additional\n * permissions. The composite identifier `paystack.refund` is what the refund\n * action (client) and the refund route (server `_acl`) check against.\n */\nShopware.Service('privileges').addPrivilegeMappingEntry({\n category: 'additional_permissions',\n parent: null,\n key: 'paystack',\n roles: {\n refund: {\n // Depends on the order editor role, which already grants the order\n // and transaction read/update privileges the refund action needs.\n // The permission is a pure gate for the refund action itself.\n privileges: [],\n dependencies: ['order.editor'],\n },\n },\n});\n","{% block sw_order_detail_content_tabs_extension %}\n {% block sw_order_detail_content_tabs_paystack %}\n {% block sw_order_detail_content_tabs_paystack_item %}\n \n {% block sw_order_detail_content_tabs_paystack_label %}\n {{ $t('sw-order.detail.tabPaystack') }}\n {% endblock %}\n \n {% endblock %}\n {% endblock %}\n\n {% block sw_order_detail_content_tabs_paystack_parent %}\n {% parent %}\n {% endblock %}\n{% endblock %}\n","/**\n * Fully-qualified class name of the Shopware payment handler. Must stay in sync\n * with src/Checkout/Payment/Handler/PaystackPaymentHandler.php. Kept in one\n * place so a namespace change is a single-line fix rather than a silent breakage\n * across multiple components.\n */\nexport const PAYSTACK_HANDLER_IDENTIFIER =\n 'Kommandhub\\\\PaystackSW\\\\Checkout\\\\Payment\\\\Handler\\\\PaystackPaymentHandler';\n\n/**\n * Whether an error represents an aborted/cancelled HTTP request, which should be\n * swallowed silently rather than surfaced to the user.\n *\n * @param {*} error\n * @returns {boolean}\n */\nexport function isAbortError(error) {\n return error?.code === 'ECONNABORTED'\n || error?.name === 'AbortError'\n || error?.message === 'Request aborted';\n}\n","import template from './sw-order-detail.html.twig';\nimport { PAYSTACK_HANDLER_IDENTIFIER, isAbortError } from '../../../../util/paystack';\n\n\nShopware.Component.override('sw-order-detail', {\n template,\n\n inject: [\n 'repositoryFactory',\n 'systemConfigApiService',\n ],\n\n props: {\n orderId: {\n type: String,\n required: false,\n default: null,\n },\n },\n\n data() {\n return {\n isLoading: true,\n paystackOrder: null,\n config: {},\n };\n },\n\n computed: {\n /**\n * Extend the default order criteria and load\n * payment method associations for transaction checks.\n *\n * @returns {Criteria}\n */\n orderCriteria() {\n const criteria = this.$super('orderCriteria');\n\n criteria.addAssociation('transactions.paymentMethod');\n criteria.addAssociation('transactions.stateMachineState');\n criteria.addAssociation('transactions.captures.refunds.stateMachineState');\n criteria.addAssociation('transactions.captures.stateMachineState');\n\n return criteria;\n },\n\n /**\n * Order repository.\n *\n * @returns {Repository}\n */\n orderRepository() {\n return this.repositoryFactory.create('order');\n },\n\n /**\n * Determines whether the order contains\n * a Paystack transaction.\n *\n * @returns {boolean}\n */\n isPaystackPayment() {\n if (!this.paystackOrder?.transactions?.length) {\n return false;\n }\n\n return this.paystackOrder.transactions.some(\n (transaction) =>\n transaction.paymentMethod?.handlerIdentifier === PAYSTACK_HANDLER_IDENTIFIER\n );\n },\n },\n\n watch: {\n orderId() {\n void this.fetchOrder();\n },\n },\n\n created() {\n void this.fetchOrder();\n },\n\n methods: {\n /**\n * Load the order including transaction and payment method associations.\n *\n * @returns {Promise}\n */\n async fetchOrder() {\n if (!this.orderId) {\n this.isLoading = false;\n return;\n }\n\n this.isLoading = true;\n\n try {\n this.paystackOrder = await this.orderRepository.get(\n this.orderId,\n Shopware.Context.api,\n this.orderCriteria\n );\n\n if (this.paystackOrder?.salesChannelId) {\n this.config = await this.systemConfigApiService.getValues(\n 'KommandhubPaystackSW.config',\n this.paystackOrder.salesChannelId\n );\n }\n } catch (error) {\n if (isAbortError(error)) {\n return;\n }\n\n console.error('[Paystack] Failed to load order details:', error?.message ?? error);\n } finally {\n this.isLoading = false;\n }\n },\n },\n});\n","{% block sw_order_document_card %}\n {% block kommandhub_paystack_detail_card %}\n \n {% block kommandhub_paystack_detail_card_banner %}\n {% block kommandhub_paystack_detail_card_banner_wrapper %}\n \n {% block kommandhub_paystack_detail_card_banner_icon %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_card_banner_title %}\n

\n {{ $t('kommandhub-paystack-detail.header') }}\n

\n {% endblock %}\n \n {% endblock %}\n {% endblock %}\n\n {% block kommandhub_paystack_detail_card_grid %}\n \n {% endblock %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_captures_card %}\n \n \n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refunds_list_modal %}\n \n {% block kommandhub_paystack_detail_refunds_list_grid %}\n {% block kommandhub_paystack_detail_refunds_list_grid_table %}\n \n \n\n \n\n \n \n {% endblock %}\n {% endblock %}\n\n {% block kommandhub_paystack_detail_refunds_list_modal_footer %}\n \n {% endblock %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal %}\n \n {% block kommandhub_paystack_detail_refund_modal_content %}\n {% block kommandhub_paystack_detail_refund_modal_form %}\n \n {% block kommandhub_paystack_detail_refund_modal_amount_field %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal_currency_field %}\n \n {% endblock %}\n \n\n {% block kommandhub_paystack_detail_refund_modal_customer_note_field %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal_merchant_note_field %}\n \n {% endblock %}\n {% endblock %}\n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal_footer %}\n \n {% endblock %}\n \n {% endblock %}\n{% endblock %}\n","export default \"__VITE_ASSET__CKQMVLPb__\"","/**\n * Pure refund math for the Paystack admin UI.\n *\n * No Shopware dependencies, so it can be unit-tested in isolation (see\n * refund-calculator.spec.js). The currency-decimal table mirrors the backend\n * PaystackCurrencyHelper — keep the two in sync.\n */\n\nconst CURRENCY_DECIMALS = {\n JPY: 0, XOF: 0, XAF: 0, KMF: 0, GNF: 0, CLP: 0, RWF: 0, UGX: 0,\n BHD: 3, IQD: 3, JOD: 3, KWD: 3, LYD: 3, OMR: 3, TND: 3,\n};\n\nconst ACTIVE_REFUND_STATES = ['completed', 'in_progress'];\nconst FAILED_CAPTURE_STATE = 'failed';\n\n/**\n * Number of minor-unit decimals for a currency (defaults to 2).\n *\n * @param {string} currency\n * @returns {number}\n */\nexport function currencyDecimals(currency) {\n return CURRENCY_DECIMALS[currency] ?? 2;\n}\n\n/**\n * Rounds a major-unit amount to its currency's precision.\n *\n * @param {number} value\n * @param {string} currency\n * @returns {number}\n */\nexport function roundToCurrency(value, currency) {\n return Number(Number(value ?? 0).toFixed(currencyDecimals(currency)));\n}\n\n/**\n * Minimum refundable amount in major units, derived from a minor-unit config\n * value (Paystack's minimum refund is expressed in minor units).\n *\n * @param {number} minMinorUnits\n * @param {string} currency\n * @returns {number}\n */\nexport function minRefundableAmount(minMinorUnits, currency) {\n return Number(minMinorUnits ?? 50) / (10 ** currencyDecimals(currency));\n}\n\nfunction sumActiveRefunds(refunds) {\n return refunds.reduce((total, refund) => {\n return ACTIVE_REFUND_STATES.includes(refund.stateMachineState?.technicalName)\n ? total + Number(refund.amount?.totalPrice ?? 0)\n : total;\n }, 0);\n}\n\n/**\n * Maximum refundable amount in major units.\n *\n * Base is the sum of non-failed captures, or the original transaction amount\n * when no captures exist yet, minus refunds already completed or in progress.\n *\n * @param {Object} params\n * @param {number} params.transactionAmount original transaction amount (major units)\n * @param {Array} [params.captures]\n * @param {Array} [params.refunds]\n * @param {string} params.currency\n * @returns {number}\n */\nexport function maxRefundableAmount({ transactionAmount, captures = [], refunds = [], currency }) {\n const refunded = sumActiveRefunds(refunds);\n\n if (captures.length === 0) {\n return roundToCurrency(Math.max(0, Number(transactionAmount ?? 0) - refunded), currency);\n }\n\n const activeCaptures = captures.reduce((total, capture) => {\n return capture.stateMachineState?.technicalName !== FAILED_CAPTURE_STATE\n ? total + Number(capture.amount?.totalPrice ?? 0)\n : total;\n }, 0);\n\n return roundToCurrency(Math.max(0, activeCaptures - refunded), currency);\n}\n","import template from './kommandhub-paystack-detail.html.twig';\nimport './kommandhub-paystack-detail.scss';\nimport icon from './icon.png';\nimport { PAYSTACK_HANDLER_IDENTIFIER, isAbortError } from '../../util/paystack';\nimport {\n maxRefundableAmount as calcMaxRefundable,\n minRefundableAmount as calcMinRefundable,\n currencyDecimals,\n} from '../../service/refund-calculator';\n\nconst { Store, Mixin } = Shopware;\nconst { Criteria } = Shopware.Data;\n\nShopware.Component.register('kommandhub-paystack-detail', {\n template,\n\n mixins: [\n Mixin.getByName('notification'),\n ],\n\n /** @private */\n metaInfo() {\n return {\n title: this.$t('kommandhub-paystack-detail.title'),\n };\n },\n\n inject: [\n 'repositoryFactory',\n 'paystackRefundService',\n 'systemConfigApiService',\n 'acl',\n ],\n\n /** @private */\n data() {\n return {\n showRefundModal: false,\n refundAmount: null,\n refundCurrency: null,\n customerNote: null,\n merchantNote: null,\n isRefundLoading: false,\n isRefundSuccess: false,\n activeTransaction: null,\n activeCapture: null,\n showRefundsListModal: false,\n\n captures: [],\n refunds: [],\n isLoading: false,\n config: {},\n };\n },\n\n computed: {\n /**\n * Order repository.\n *\n * @returns {Repository}\n */\n orderRepository() {\n return this.repositoryFactory.create('order');\n },\n\n /**\n * Returns the order object from the swOrderDetail store.\n *\n * @returns {Object}\n */\n order() {\n return Store.get('swOrderDetail')?.order;\n },\n\n /**\n * Checks if the order has any unsaved changes.\n *\n * @returns {Boolean}\n */\n orderChanges() {\n if (!this.order || !this.order?.id || !this.orderRepository) {\n return false;\n }\n\n return this.orderRepository.hasChanges(this.order);\n },\n\n /**\n * Returns the repository for order transaction captures.\n *\n * @returns {Object}\n */\n transactionCaptureRepository() {\n return this.repositoryFactory.create('order_transaction_capture');\n },\n\n /**\n * Finds the Paystack transaction within the order's transactions.\n *\n * @returns {Object|null}\n */\n paystackTransaction() {\n if (!this.order || !this.order?.transactions) {\n return null;\n }\n\n return this.order.transactions.find((transaction) => {\n return transaction.paymentMethod?.handlerIdentifier === PAYSTACK_HANDLER_IDENTIFIER\n || (transaction.customFields && transaction.customFields.paystack_reference);\n });\n },\n\n /**\n * Returns whether the current transaction is fully refunded.\n *\n * @returns {Boolean}\n */\n isTransactionRefunded() {\n return this.paystackTransaction?.stateMachineState?.technicalName === 'refunded';\n },\n\n /**\n * Transforms the Paystack transaction into a data grid compatible format.\n *\n * @returns {Array}\n */\n paystackTransactionData() {\n if (!this.paystackTransaction?.id) {\n return [];\n }\n\n return [{\n id: this.paystackTransaction.id,\n amount: this.paystackTransaction.customFields?.paystack_amount,\n currency: this.paystackTransaction.customFields?.paystack_currency,\n channel: this.paystackTransaction.customFields?.paystack_payment_type,\n reference: this.paystackTransaction.customFields?.paystack_reference,\n transactionId: this.paystackTransaction.customFields?.paystack_transaction_id,\n fee: this.paystackTransaction.customFields?.paystack_transaction_fee,\n verifiedAt: this.paystackTransaction.customFields?.paystack_verified_at,\n state: this.paystackTransaction.stateMachineState,\n }];\n },\n\n /**\n * Column configuration for the Paystack transaction grid.\n *\n * @returns {Array}\n */\n paystackTransactionColumns() {\n return [\n {\n property: 'amount',\n label: 'kommandhub-paystack-detail.summary.chargedAmount',\n primary: true,\n },\n {\n property: 'reference',\n label: 'kommandhub-paystack-detail.grid.reference',\n },\n {\n property: 'transactionId',\n label: 'kommandhub-paystack-detail.grid.transactionId',\n },\n {\n property: 'fee',\n label: 'kommandhub-paystack-detail.grid.processingFee',\n },\n {\n property: 'state',\n label: 'kommandhub-paystack-detail.grid.state',\n },\n {\n property: 'verifiedAt',\n label: 'kommandhub-paystack-detail.grid.verifiedAt',\n },\n ];\n },\n\n /**\n * Column configuration for the capture grid.\n *\n * @returns {Array}\n */\n paystackCaptureColumns() {\n return [\n {\n property: 'amount',\n label: 'kommandhub-paystack-detail.captures.grid.amount',\n primary: true,\n },\n {\n property: 'state',\n label: 'kommandhub-paystack-detail.captures.grid.state',\n },\n {\n property: 'externalReference',\n label: 'kommandhub-paystack-detail.captures.grid.externalReference',\n },\n {\n property: 'createdAt',\n label: 'kommandhub-paystack-detail.captures.grid.createdAt',\n },\n ];\n },\n\n /**\n * Column configuration for the refunds grid.\n *\n * @returns {Array}\n */\n paystackRefundColumns() {\n return [\n {\n property: 'amount',\n label: 'kommandhub-paystack-detail.refunds.grid.amount',\n primary: true,\n },\n {\n property: 'state',\n label: 'kommandhub-paystack-detail.refunds.grid.state',\n },\n {\n property: 'externalReference',\n label: 'kommandhub-paystack-detail.refunds.grid.externalReference',\n },\n {\n property: 'reason',\n label: 'kommandhub-paystack-detail.refunds.grid.reason',\n },\n {\n property: 'createdAt',\n label: 'kommandhub-paystack-detail.refunds.grid.createdAt',\n },\n ];\n },\n\n /**\n * The currency used for refund calculations, falling back to the\n * transaction's stored currency before the modal sets it.\n *\n * @returns {String|undefined}\n */\n activeCurrency() {\n return this.refundCurrency || this.paystackTransaction?.customFields?.paystack_currency;\n },\n\n /**\n * Calculates the maximum refundable amount (major units).\n *\n * @returns {Number}\n */\n maxRefundableAmount() {\n if (!this.paystackTransaction) {\n return 0;\n }\n\n return calcMaxRefundable({\n transactionAmount: Number(this.paystackTransaction.customFields?.paystack_amount ?? 0),\n captures: this.captures,\n refunds: this.refunds,\n currency: this.activeCurrency,\n });\n },\n\n /**\n * Whether a refund can currently be initiated: feature enabled, user has\n * the privilege, transaction not fully refunded, and a positive balance\n * that clears the Paystack minimum.\n *\n * @returns {Boolean}\n */\n canRefund() {\n return this.refundEnabled\n && this.acl.can('paystack.refund')\n && !this.isTransactionRefunded\n && this.maxRefundableAmount >= this.minRefundableAmount;\n },\n\n /**\n * Returns the filtered list of refunds based on the active capture.\n *\n * @returns {Array}\n */\n paystackRefunds() {\n if (this.activeCapture?.id) {\n return this.refunds.filter(refund => refund.captureId === this.activeCapture.id);\n }\n\n return this.refunds;\n },\n\n /**\n * Returns the currency filter.\n *\n * @returns {Function}\n */\n currencyFilter() {\n return Shopware.Filter.getByName('currency');\n },\n\n /**\n * Returns the Paystack icon.\n *\n * @returns {String}\n */\n paystackIcon() {\n return icon;\n },\n /**\n * Returns whether refunds are enabled.\n *\n * @returns {Boolean}\n */\n refundEnabled() {\n return this.config['KommandhubPaystackSW.config.refundEnabled'] !== false;\n },\n /**\n * Returns the minimum refund amount for Paystack (in minor units).\n *\n * @returns {Number}\n */\n minPaystackRefundAmount() {\n return this.config['KommandhubPaystackSW.config.minimumRefundAmount'] ?? 50;\n },\n /**\n * Returns the minimum refund amount in major units.\n *\n * @returns {Number}\n */\n minRefundableAmount() {\n return calcMinRefundable(this.minPaystackRefundAmount, this.activeCurrency);\n },\n\n /**\n * Decimal precision for the refund amount field, per active currency.\n *\n * @returns {Number}\n */\n refundAmountDigits() {\n return currencyDecimals(this.activeCurrency);\n },\n },\n\n /** @private */\n watch: {\n paystackTransaction: {\n immediate: true,\n handler(transaction) {\n if (transaction?.id) {\n void this.loadCapturesAndRefunds();\n }\n },\n },\n // Config depends on the order's sales channel, which the swOrderDetail\n // store may populate after this component is created; load reactively.\n 'order.salesChannelId': {\n immediate: true,\n handler(salesChannelId) {\n if (salesChannelId) {\n void this.loadConfig(salesChannelId);\n }\n },\n },\n },\n\n methods: {\n /**\n * Loads plugin configuration for the given sales channel.\n *\n * @param {String} salesChannelId\n * @returns {Promise}\n */\n async loadConfig(salesChannelId) {\n this.config = await this.systemConfigApiService.getValues(\n 'KommandhubPaystackSW.config',\n salesChannelId\n );\n },\n /**\n * Creates search criteria for fetching captures associated with a transaction.\n *\n * @param {String} transactionId\n * @returns {Criteria}\n */\n transactionCaptureCriteria(transactionId) {\n const criteria = new Criteria();\n\n criteria.addFilter(\n Criteria.equals('orderTransactionId', transactionId)\n );\n\n criteria.addAssociation('stateMachineState');\n criteria.addAssociation('refunds');\n criteria.addAssociation('refunds.stateMachineState');\n\n return criteria;\n },\n\n /**\n * Fetches captures and their associated refunds for the current Paystack transaction.\n *\n * @async\n * @returns {Promise}\n */\n async loadCapturesAndRefunds() {\n // Re-entrancy guard: the paystackTransaction watcher can fire while a\n // load is already in flight — avoid the concurrent double request.\n if (!this.paystackTransaction?.id || this.isLoading) {\n return;\n }\n\n this.isLoading = true;\n\n try {\n const captureResult = await this.transactionCaptureRepository.search(\n this.transactionCaptureCriteria(this.paystackTransaction.id),\n Shopware.Context.api\n );\n\n const captures = captureResult.map((capture) => ({\n ...capture,\n state: capture.stateMachineState?.translated?.name\n || capture.stateMachineState?.name\n || '',\n }));\n\n const refunds = [];\n\n captures.forEach((capture) => {\n if (!capture.refunds?.length) {\n return;\n }\n\n capture.refunds.forEach((refund) => {\n refunds.push({\n ...refund,\n state: refund.stateMachineState?.translated?.name\n || refund.stateMachineState?.name\n || '',\n });\n });\n });\n\n this.captures = captures;\n this.refunds = refunds;\n } catch (error) {\n if (isAbortError(error)) {\n return;\n }\n\n this.createNotificationError({\n message: error.message,\n });\n } finally {\n this.isLoading = false;\n }\n },\n\n /**\n * Opens the refund modal for the current transaction.\n *\n * The refund is always transaction-level here (the only entry point is\n * the transaction grid), so no capture is selected. `canRefund`\n * guarantees maxRefundableAmount >= minRefundableAmount, so prefilling\n * the maximum is always a valid starting amount.\n */\n onOpenRefundModal() {\n this.activeTransaction = this.paystackTransaction;\n this.activeCapture = null;\n this.refundCurrency = this.paystackTransaction.customFields?.paystack_currency;\n this.refundAmount = this.maxRefundableAmount;\n this.showRefundModal = true;\n },\n\n /**\n * Opens the refund list modal for the selected capture.\n *\n * @param {Object} item\n */\n onOpenRefundsListModal(item) {\n this.activeCapture = item;\n this.showRefundsListModal = true;\n },\n\n /**\n * Closes the refund list modal and resets active capture.\n */\n onCloseRefundsListModal() {\n this.activeCapture = null;\n this.showRefundsListModal = false;\n },\n\n /**\n * Closes the refund modal and resets refund-related data.\n */\n onCloseRefundModal() {\n this.showRefundModal = false;\n this.activeTransaction = null;\n this.refundAmount = null;\n this.refundCurrency = null;\n this.customerNote = null;\n this.merchantNote = null;\n },\n\n /**\n * Initiates the refund process through the Paystack refund service.\n */\n onConfirmRefund() {\n if (this.refundAmount < this.minRefundableAmount) {\n this.createNotificationError({\n message: this.$t('kommandhub-paystack-detail.refund.errorAmountTooLow', {\n minAmount: this.currencyFilter(this.minRefundableAmount, this.refundCurrency),\n }),\n });\n return;\n }\n\n if (this.refundAmount > this.maxRefundableAmount) {\n this.createNotificationError({\n message: this.$t('kommandhub-paystack-detail.refund.errorAmountTooHigh', {\n maxAmount: this.currencyFilter(this.maxRefundableAmount, this.refundCurrency),\n }),\n });\n return;\n }\n\n this.isRefundLoading = true;\n\n const payload = {\n transaction: this.activeTransaction.customFields?.paystack_reference,\n orderTransactionId: this.activeTransaction.id,\n orderTransactionCaptureId: this.activeCapture?.id,\n // Major units; server converts to minor units per currency decimals.\n amount: this.refundAmount,\n currency: this.refundCurrency,\n customer_note: this.customerNote,\n merchant_note: this.merchantNote,\n };\n\n this.paystackRefundService.refund(payload)\n .then(async () => {\n this.isRefundSuccess = true;\n await this.loadCapturesAndRefunds();\n })\n .catch((error) => {\n if (isAbortError(error)) {\n return;\n }\n\n const errorData = error.response?.data;\n let message = errorData?.error || error.message;\n\n if (errorData?.meta?.nextStep) {\n message += ` ${errorData.meta.nextStep}`;\n }\n\n this.createNotificationError({\n message,\n });\n })\n .finally(() => {\n this.isRefundLoading = false;\n });\n },\n\n /**\n * Handles the completion of the refund process.\n */\n onRefundFinished() {\n this.isRefundSuccess = false;\n this.onCloseRefundModal();\n },\n },\n});\n","import frFR from './snippet/fr-FR.json';\nimport deDE from './snippet/de-DE.json';\nimport enGB from './snippet/en-GB.json';\n\nShopware.Locale.extend('fr-FR', frFR);\nShopware.Locale.extend('de-DE', deDE);\nShopware.Locale.extend('en-GB', enGB);\n\nimport PaystackRefundService from './service/paystack-refund.service';\n\nShopware.Service().register('paystackRefundService', (container) => {\n const initContainer = Shopware.Application.getContainer('init');\n return new PaystackRefundService(initContainer.httpClient, container.loginService);\n});\n\nimport './acl';\nimport './module/sw-order/page/sw-order-detail'\nimport './view/kommandhub-paystack-detail'\n\nShopware.Module.register('kommandhub-paystack-detail', {\n routeMiddleware(next, currentRoute) {\n if (currentRoute.name === 'sw.order.detail') {\n const paystackRoute = 'kommandhub.paystack.detail';\n\n if (!currentRoute.children.some(child => child.name === paystackRoute)) {\n currentRoute.children.push({\n name: paystackRoute,\n path: 'kommandhub/paystack',\n component: 'kommandhub-paystack-detail',\n meta: {\n parentPath: 'sw.order.detail',\n privilege: 'order.viewer',\n },\n props: {\n default: ($route) => {\n return { orderId: $route.params.id.toLowerCase() };\n },\n },\n });\n }\n }\n next(currentRoute);\n }\n});"],"names":["Classes","PaystackRefundService","httpClient","loginService","apiEndpoint","payload","response","template$1","PAYSTACK_HANDLER_IDENTIFIER","isAbortError","error","template","criteria","_b","_a","transaction","icon","CURRENCY_DECIMALS","ACTIVE_REFUND_STATES","FAILED_CAPTURE_STATE","currencyDecimals","currency","roundToCurrency","value","minRefundableAmount","minMinorUnits","sumActiveRefunds","refunds","total","refund","maxRefundableAmount","transactionAmount","captures","refunded","activeCaptures","capture","Store","Mixin","Criteria","_c","_d","_e","_f","_g","_h","calcMaxRefundable","calcMinRefundable","salesChannelId","transactionId","item","errorData","message","frFR","deDE","enGB","container","initContainer","next","currentRoute","paystackRoute","child","$route"],"mappings":"4mJAAM,CAAE,QAAAA,CAAO,EAAK,SAEpB,MAAMC,UAA8BD,EAAQ,UAAW,CACnD,YAAYE,EAAYC,EAAcC,EAAc,WAAY,CAC5D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AY,aAAa,MAAM,EAC9D,OAAO,IAAIvD,EAAsBuD,EAAc,WAAYD,EAAU,YAAY,CACrF,CAAC,EAMD,SAAS,OAAO,SAAS,6BAA8B,CACnD,gBAAgBE,EAAMC,EAAc,CAChC,GAAIA,EAAa,OAAS,kBAAmB,CACzC,MAAMC,EAAgB,6BAEjBD,EAAa,SAAS,KAAKE,GAASA,EAAM,OAASD,CAAa,GACjED,EAAa,SAAS,KAAK,CACvB,KAAMC,EACN,KAAM,sBACN,UAAW,6BACX,KAAM,CACF,WAAY,kBACZ,UAAW,cACnC,EACoB,MAAO,CACH,QAAUE,IACC,CAAE,QAASA,EAAO,OAAO,GAAG,YAAW,CAAE,EAE5E,CACA,CAAiB,CAEjB,CACQJ,EAAKC,CAAY,CACzB,CACA,CAAC"} \ No newline at end of file diff --git a/src/Resources/public/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js.map b/src/Resources/public/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js.map deleted file mode 100644 index 009725c..0000000 --- a/src/Resources/public/administration/assets/kommandhub-paystack-s-w-DpuWP_xG.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"kommandhub-paystack-s-w-DpuWP_xG.js","sources":["../../../app/administration/src/service/paystack-refund.service.js","../../../app/administration/src/acl/index.js","../../../app/administration/src/module/sw-order/page/sw-order-detail/sw-order-detail.html.twig","../../../app/administration/src/util/paystack.js","../../../app/administration/src/module/sw-order/page/sw-order-detail/index.js","../../../app/administration/src/view/kommandhub-paystack-detail/kommandhub-paystack-detail.html.twig","../../../app/administration/src/view/kommandhub-paystack-detail/icon.png","../../../app/administration/src/service/refund-calculator.js","../../../app/administration/src/view/kommandhub-paystack-detail/index.js","../../../app/administration/src/main.js"],"sourcesContent":["const { Classes } = Shopware;\n\nclass PaystackRefundService extends Classes.ApiService {\n constructor(httpClient, loginService, apiEndpoint = 'paystack') {\n super(httpClient, loginService, apiEndpoint);\n this.name = 'paystackRefundService';\n }\n\n refund(payload) {\n return this.httpClient.post(\n '_action/paystack/refund',\n payload,\n {\n headers: this.getBasicHeaders(),\n }\n ).then((response) => {\n return Classes.ApiService.handleResponse(response);\n });\n }\n}\n\nexport default PaystackRefundService;\n","/**\n * Registers a dedicated \"Paystack refund\" admin permission so it can be granted\n * to roles independently of the generic order editor privilege. Appears as a\n * checkbox under Settings > Users & permissions > Roles > Additional\n * permissions. The composite identifier `paystack.refund` is what the refund\n * action (client) and the refund route (server `_acl`) check against.\n */\nShopware.Service('privileges').addPrivilegeMappingEntry({\n category: 'additional_permissions',\n parent: null,\n key: 'paystack',\n roles: {\n refund: {\n // Depends on the order editor role, which already grants the order\n // and transaction read/update privileges the refund action needs.\n // The permission is a pure gate for the refund action itself.\n privileges: [],\n dependencies: ['order.editor'],\n },\n },\n});\n","{% block sw_order_detail_content_tabs_extension %}\n {% block sw_order_detail_content_tabs_paystack %}\n {% block sw_order_detail_content_tabs_paystack_item %}\n \n {% block sw_order_detail_content_tabs_paystack_label %}\n {{ $t('sw-order.detail.tabPaystack') }}\n {% endblock %}\n \n {% endblock %}\n {% endblock %}\n\n {% block sw_order_detail_content_tabs_paystack_parent %}\n {% parent %}\n {% endblock %}\n{% endblock %}\n","/**\n * Fully-qualified class name of the Shopware payment handler. Must stay in sync\n * with src/Checkout/Payment/Handler/PaystackPaymentHandler.php. Kept in one\n * place so a namespace change is a single-line fix rather than a silent breakage\n * across multiple components.\n */\nexport const PAYSTACK_HANDLER_IDENTIFIER =\n 'Kommandhub\\\\PaystackSW\\\\Checkout\\\\Payment\\\\Handler\\\\PaystackPaymentHandler';\n\n/**\n * Whether an error represents an aborted/cancelled HTTP request, which should be\n * swallowed silently rather than surfaced to the user.\n *\n * @param {*} error\n * @returns {boolean}\n */\nexport function isAbortError(error) {\n return error?.code === 'ECONNABORTED'\n || error?.name === 'AbortError'\n || error?.message === 'Request aborted';\n}\n","import template from './sw-order-detail.html.twig';\nimport { PAYSTACK_HANDLER_IDENTIFIER, isAbortError } from '../../../../util/paystack';\n\n\nShopware.Component.override('sw-order-detail', {\n template,\n\n inject: [\n 'repositoryFactory',\n 'systemConfigApiService',\n ],\n\n props: {\n orderId: {\n type: String,\n required: false,\n default: null,\n },\n },\n\n data() {\n return {\n isLoading: true,\n paystackOrder: null,\n config: {},\n };\n },\n\n computed: {\n /**\n * Extend the default order criteria and load\n * payment method associations for transaction checks.\n *\n * @returns {Criteria}\n */\n orderCriteria() {\n const criteria = this.$super('orderCriteria');\n\n criteria.addAssociation('transactions.paymentMethod');\n criteria.addAssociation('transactions.stateMachineState');\n criteria.addAssociation('transactions.captures.refunds.stateMachineState');\n criteria.addAssociation('transactions.captures.stateMachineState');\n\n return criteria;\n },\n\n /**\n * Order repository.\n *\n * @returns {Repository}\n */\n orderRepository() {\n return this.repositoryFactory.create('order');\n },\n\n /**\n * Determines whether the order contains\n * a Paystack transaction.\n *\n * @returns {boolean}\n */\n isPaystackPayment() {\n if (!this.paystackOrder?.transactions?.length) {\n return false;\n }\n\n return this.paystackOrder.transactions.some(\n (transaction) =>\n transaction.paymentMethod?.handlerIdentifier === PAYSTACK_HANDLER_IDENTIFIER\n );\n },\n },\n\n watch: {\n orderId() {\n void this.fetchOrder();\n },\n },\n\n created() {\n void this.fetchOrder();\n },\n\n methods: {\n /**\n * Load the order including transaction and payment method associations.\n *\n * @returns {Promise}\n */\n async fetchOrder() {\n if (!this.orderId) {\n this.isLoading = false;\n return;\n }\n\n this.isLoading = true;\n\n try {\n this.paystackOrder = await this.orderRepository.get(\n this.orderId,\n Shopware.Context.api,\n this.orderCriteria\n );\n\n if (this.paystackOrder?.salesChannelId) {\n this.config = await this.systemConfigApiService.getValues(\n 'KommandhubPaystackSW.config',\n this.paystackOrder.salesChannelId\n );\n }\n } catch (error) {\n if (isAbortError(error)) {\n return;\n }\n\n console.error('[Paystack] Failed to load order details:', error?.message ?? error);\n } finally {\n this.isLoading = false;\n }\n },\n },\n});\n","{% block sw_order_document_card %}\n {% block kommandhub_paystack_detail_card %}\n \n {% block kommandhub_paystack_detail_card_banner %}\n {% block kommandhub_paystack_detail_card_banner_wrapper %}\n \n {% block kommandhub_paystack_detail_card_banner_icon %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_card_banner_title %}\n

\n {{ $t('kommandhub-paystack-detail.header') }}\n

\n {% endblock %}\n \n {% endblock %}\n {% endblock %}\n\n {% block kommandhub_paystack_detail_card_grid %}\n \n {% endblock %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_captures_card %}\n \n \n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refunds_list_modal %}\n \n {% block kommandhub_paystack_detail_refunds_list_grid %}\n {% block kommandhub_paystack_detail_refunds_list_grid_table %}\n \n \n\n \n\n \n \n {% endblock %}\n {% endblock %}\n\n {% block kommandhub_paystack_detail_refunds_list_modal_footer %}\n \n {% endblock %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal %}\n \n {% block kommandhub_paystack_detail_refund_modal_content %}\n {% block kommandhub_paystack_detail_refund_modal_form %}\n \n {% block kommandhub_paystack_detail_refund_modal_amount_field %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal_currency_field %}\n \n {% endblock %}\n \n\n {% block kommandhub_paystack_detail_refund_modal_customer_note_field %}\n \n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal_merchant_note_field %}\n \n {% endblock %}\n {% endblock %}\n {% endblock %}\n\n {% block kommandhub_paystack_detail_refund_modal_footer %}\n \n {% endblock %}\n \n {% endblock %}\n{% endblock %}\n","export default \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAGEklEQVR4nOzd3WuW9x3H8c+daB4MZokxGoPJ1Di3mT2wOWQDPdkYA3e2gw1Bd7Cxk7GV1hb6QE89KhTqQaHFgwqlpdKKLX1AKEq1lZYSrB5oa4tVW+LTrUbjQx40d0k9SH24E1P8+P1e5f36Cz7cvL28uPK77nuGOn8n4F6riR6AHybCggVhwYKwYEF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bhT3ThXPSUqhLfY61/KNWLcrmUSlq3IXrEZLKG1dSs9qyX0iRa2jRnXvSIqrKG1dIWvaAIMn0LyC2yhoW7UZP3D/OEBQvCggVhwYKwYEFYsCAsWBAWLAgLFoRVZJVK9IKqsoZ1eTB6QRGcOx29oKqsYQ2UaWsKw0M6cSx6RFVZw5L06nPRC3Lbtjl6wWQSH/Q706+hq1r2K05l3cGOV7R3R/SIyeQ+mixpzjz96W/q6eWA8riRYR05qF3bx//V5ZY+LBRT4nssFBlhwYKwYEFYsCAsWKR/xb5hllav0ZJe1ed73DA6rC8/1Z63dfli9JR0cj9u+PUftPYB1eS+rFYq2rZZH70bvSOXxE/eF3/7xQ35H7uXSlq+Qv1H8z+0vJ8SXwzW/j96wXT8/b/RC3LJGtbs1oK9DN3YpM5F0SMSyRpWc0v0gumb2xG9IJGsYRVRiQ9zAp8FLAgLFoQFC8KCBWHBgrBgQViwICxYENa9UxmLXpBI1rAGB6IXTF/5ZPSCRLKGdfG8LpyNHjEdV6+o/2j0iESyhiXppU3RC6Zj67PRC3JJfNBvoKzT/frFyuxn/W6cIN33fvSOXHIfTb5x5n3VGi3+mWbWRU+5zbVRHf+cM+93lD4sFFPieywUGWHBgrBgQViwICxYEBYsCAsWhAULwoIFYcGCsGBBWLAgLFgQFiwICxaEBQvCggVhwYKwYEFYsCAsWBAWLAgLFoQFC8KCBWHBgrBgQViwICxYEBYsCAsWhAULwoIFYcGCsGBBWLAgLFgQFiwICxaEBQvCggVhwYKwYEFYsCAsWBAWLAgLFt8EAAD//+L72rm8xd4DAAAAAElFTkSuQmCC\"","/**\n * Pure refund math for the Paystack admin UI.\n *\n * No Shopware dependencies, so it can be unit-tested in isolation (see\n * refund-calculator.spec.js). The currency-decimal table mirrors the backend\n * PaystackCurrencyHelper — keep the two in sync.\n */\n\nconst CURRENCY_DECIMALS = {\n JPY: 0, XOF: 0, XAF: 0, KMF: 0, GNF: 0, CLP: 0, RWF: 0, UGX: 0,\n BHD: 3, IQD: 3, JOD: 3, KWD: 3, LYD: 3, OMR: 3, TND: 3,\n};\n\nconst ACTIVE_REFUND_STATES = ['completed', 'in_progress'];\nconst FAILED_CAPTURE_STATE = 'failed';\n\n/**\n * Number of minor-unit decimals for a currency (defaults to 2).\n *\n * @param {string} currency\n * @returns {number}\n */\nexport function currencyDecimals(currency) {\n return CURRENCY_DECIMALS[currency] ?? 2;\n}\n\n/**\n * Rounds a major-unit amount to its currency's precision.\n *\n * @param {number} value\n * @param {string} currency\n * @returns {number}\n */\nexport function roundToCurrency(value, currency) {\n return Number(Number(value ?? 0).toFixed(currencyDecimals(currency)));\n}\n\n/**\n * Minimum refundable amount in major units, derived from a minor-unit config\n * value (Paystack's minimum refund is expressed in minor units).\n *\n * @param {number} minMinorUnits\n * @param {string} currency\n * @returns {number}\n */\nexport function minRefundableAmount(minMinorUnits, currency) {\n return Number(minMinorUnits ?? 50) / (10 ** currencyDecimals(currency));\n}\n\nfunction sumActiveRefunds(refunds) {\n return refunds.reduce((total, refund) => {\n return ACTIVE_REFUND_STATES.includes(refund.stateMachineState?.technicalName)\n ? total + Number(refund.amount?.totalPrice ?? 0)\n : total;\n }, 0);\n}\n\n/**\n * Maximum refundable amount in major units.\n *\n * Base is the sum of non-failed captures, or the original transaction amount\n * when no captures exist yet, minus refunds already completed or in progress.\n *\n * @param {Object} params\n * @param {number} params.transactionAmount original transaction amount (major units)\n * @param {Array} [params.captures]\n * @param {Array} [params.refunds]\n * @param {string} params.currency\n * @returns {number}\n */\nexport function maxRefundableAmount({ transactionAmount, captures = [], refunds = [], currency }) {\n const refunded = sumActiveRefunds(refunds);\n\n if (captures.length === 0) {\n return roundToCurrency(Math.max(0, Number(transactionAmount ?? 0) - refunded), currency);\n }\n\n const activeCaptures = captures.reduce((total, capture) => {\n return capture.stateMachineState?.technicalName !== FAILED_CAPTURE_STATE\n ? total + Number(capture.amount?.totalPrice ?? 0)\n : total;\n }, 0);\n\n return roundToCurrency(Math.max(0, activeCaptures - refunded), currency);\n}\n","import template from './kommandhub-paystack-detail.html.twig';\nimport './kommandhub-paystack-detail.scss';\nimport icon from './icon.png';\nimport { PAYSTACK_HANDLER_IDENTIFIER, isAbortError } from '../../util/paystack';\nimport {\n maxRefundableAmount as calcMaxRefundable,\n minRefundableAmount as calcMinRefundable,\n currencyDecimals,\n} from '../../service/refund-calculator';\n\nconst { Store, Mixin } = Shopware;\nconst { Criteria } = Shopware.Data;\n\nShopware.Component.register('kommandhub-paystack-detail', {\n template,\n\n mixins: [\n Mixin.getByName('notification'),\n ],\n\n /** @private */\n metaInfo() {\n return {\n title: this.$t('kommandhub-paystack-detail.title'),\n };\n },\n\n inject: [\n 'repositoryFactory',\n 'paystackRefundService',\n 'systemConfigApiService',\n 'acl',\n ],\n\n /** @private */\n data() {\n return {\n showRefundModal: false,\n refundAmount: null,\n refundCurrency: null,\n customerNote: null,\n merchantNote: null,\n isRefundLoading: false,\n isRefundSuccess: false,\n activeTransaction: null,\n activeCapture: null,\n showRefundsListModal: false,\n\n captures: [],\n refunds: [],\n isLoading: false,\n config: {},\n };\n },\n\n computed: {\n /**\n * Order repository.\n *\n * @returns {Repository}\n */\n orderRepository() {\n return this.repositoryFactory.create('order');\n },\n\n /**\n * Returns the order object from the swOrderDetail store.\n *\n * @returns {Object}\n */\n order() {\n return Store.get('swOrderDetail')?.order;\n },\n\n /**\n * Checks if the order has any unsaved changes.\n *\n * @returns {Boolean}\n */\n orderChanges() {\n if (!this.order || !this.order?.id || !this.orderRepository) {\n return false;\n }\n\n return this.orderRepository.hasChanges(this.order);\n },\n\n /**\n * Returns the repository for order transaction captures.\n *\n * @returns {Object}\n */\n transactionCaptureRepository() {\n return this.repositoryFactory.create('order_transaction_capture');\n },\n\n /**\n * Finds the Paystack transaction within the order's transactions.\n *\n * @returns {Object|null}\n */\n paystackTransaction() {\n if (!this.order || !this.order?.transactions) {\n return null;\n }\n\n return this.order.transactions.find((transaction) => {\n return transaction.paymentMethod?.handlerIdentifier === PAYSTACK_HANDLER_IDENTIFIER\n || (transaction.customFields && transaction.customFields.paystack_reference);\n });\n },\n\n /**\n * Returns whether the current transaction is fully refunded.\n *\n * @returns {Boolean}\n */\n isTransactionRefunded() {\n return this.paystackTransaction?.stateMachineState?.technicalName === 'refunded';\n },\n\n /**\n * Transforms the Paystack transaction into a data grid compatible format.\n *\n * @returns {Array}\n */\n paystackTransactionData() {\n if (!this.paystackTransaction?.id) {\n return [];\n }\n\n return [{\n id: this.paystackTransaction.id,\n amount: this.paystackTransaction.customFields?.paystack_amount,\n currency: this.paystackTransaction.customFields?.paystack_currency,\n channel: this.paystackTransaction.customFields?.paystack_payment_type,\n reference: this.paystackTransaction.customFields?.paystack_reference,\n transactionId: this.paystackTransaction.customFields?.paystack_transaction_id,\n fee: this.paystackTransaction.customFields?.paystack_transaction_fee,\n verifiedAt: this.paystackTransaction.customFields?.paystack_verified_at,\n state: this.paystackTransaction.stateMachineState,\n }];\n },\n\n /**\n * Column configuration for the Paystack transaction grid.\n *\n * @returns {Array}\n */\n paystackTransactionColumns() {\n return [\n {\n property: 'amount',\n label: 'kommandhub-paystack-detail.summary.chargedAmount',\n primary: true,\n },\n {\n property: 'reference',\n label: 'kommandhub-paystack-detail.grid.reference',\n },\n {\n property: 'transactionId',\n label: 'kommandhub-paystack-detail.grid.transactionId',\n },\n {\n property: 'fee',\n label: 'kommandhub-paystack-detail.grid.processingFee',\n },\n {\n property: 'state',\n label: 'kommandhub-paystack-detail.grid.state',\n },\n {\n property: 'verifiedAt',\n label: 'kommandhub-paystack-detail.grid.verifiedAt',\n },\n ];\n },\n\n /**\n * Column configuration for the capture grid.\n *\n * @returns {Array}\n */\n paystackCaptureColumns() {\n return [\n {\n property: 'amount',\n label: 'kommandhub-paystack-detail.captures.grid.amount',\n primary: true,\n },\n {\n property: 'state',\n label: 'kommandhub-paystack-detail.captures.grid.state',\n },\n {\n property: 'externalReference',\n label: 'kommandhub-paystack-detail.captures.grid.externalReference',\n },\n {\n property: 'createdAt',\n label: 'kommandhub-paystack-detail.captures.grid.createdAt',\n },\n ];\n },\n\n /**\n * Column configuration for the refunds grid.\n *\n * @returns {Array}\n */\n paystackRefundColumns() {\n return [\n {\n property: 'amount',\n label: 'kommandhub-paystack-detail.refunds.grid.amount',\n primary: true,\n },\n {\n property: 'state',\n label: 'kommandhub-paystack-detail.refunds.grid.state',\n },\n {\n property: 'externalReference',\n label: 'kommandhub-paystack-detail.refunds.grid.externalReference',\n },\n {\n property: 'reason',\n label: 'kommandhub-paystack-detail.refunds.grid.reason',\n },\n {\n property: 'createdAt',\n label: 'kommandhub-paystack-detail.refunds.grid.createdAt',\n },\n ];\n },\n\n /**\n * The currency used for refund calculations, falling back to the\n * transaction's stored currency before the modal sets it.\n *\n * @returns {String|undefined}\n */\n activeCurrency() {\n return this.refundCurrency || this.paystackTransaction?.customFields?.paystack_currency;\n },\n\n /**\n * Calculates the maximum refundable amount (major units).\n *\n * @returns {Number}\n */\n maxRefundableAmount() {\n if (!this.paystackTransaction) {\n return 0;\n }\n\n return calcMaxRefundable({\n transactionAmount: Number(this.paystackTransaction.customFields?.paystack_amount ?? 0),\n captures: this.captures,\n refunds: this.refunds,\n currency: this.activeCurrency,\n });\n },\n\n /**\n * Whether a refund can currently be initiated: feature enabled, user has\n * the privilege, transaction not fully refunded, and a positive balance\n * that clears the Paystack minimum.\n *\n * @returns {Boolean}\n */\n canRefund() {\n return this.refundEnabled\n && this.acl.can('paystack.refund')\n && !this.isTransactionRefunded\n && this.maxRefundableAmount >= this.minRefundableAmount;\n },\n\n /**\n * Returns the filtered list of refunds based on the active capture.\n *\n * @returns {Array}\n */\n paystackRefunds() {\n if (this.activeCapture?.id) {\n return this.refunds.filter(refund => refund.captureId === this.activeCapture.id);\n }\n\n return this.refunds;\n },\n\n /**\n * Returns the currency filter.\n *\n * @returns {Function}\n */\n currencyFilter() {\n return Shopware.Filter.getByName('currency');\n },\n\n /**\n * Returns the Paystack icon.\n *\n * @returns {String}\n */\n paystackIcon() {\n return icon;\n },\n /**\n * Returns whether refunds are enabled.\n *\n * @returns {Boolean}\n */\n refundEnabled() {\n return this.config['KommandhubPaystackSW.config.refundEnabled'] !== false;\n },\n /**\n * Returns the minimum refund amount for Paystack (in minor units).\n *\n * @returns {Number}\n */\n minPaystackRefundAmount() {\n return this.config['KommandhubPaystackSW.config.minimumRefundAmount'] ?? 50;\n },\n /**\n * Returns the minimum refund amount in major units.\n *\n * @returns {Number}\n */\n minRefundableAmount() {\n return calcMinRefundable(this.minPaystackRefundAmount, this.activeCurrency);\n },\n\n /**\n * Decimal precision for the refund amount field, per active currency.\n *\n * @returns {Number}\n */\n refundAmountDigits() {\n return currencyDecimals(this.activeCurrency);\n },\n },\n\n /** @private */\n watch: {\n paystackTransaction: {\n immediate: true,\n handler(transaction) {\n if (transaction?.id) {\n void this.loadCapturesAndRefunds();\n }\n },\n },\n // Config depends on the order's sales channel, which the swOrderDetail\n // store may populate after this component is created; load reactively.\n 'order.salesChannelId': {\n immediate: true,\n handler(salesChannelId) {\n if (salesChannelId) {\n void this.loadConfig(salesChannelId);\n }\n },\n },\n },\n\n methods: {\n /**\n * Loads plugin configuration for the given sales channel.\n *\n * @param {String} salesChannelId\n * @returns {Promise}\n */\n async loadConfig(salesChannelId) {\n this.config = await this.systemConfigApiService.getValues(\n 'KommandhubPaystackSW.config',\n salesChannelId\n );\n },\n /**\n * Creates search criteria for fetching captures associated with a transaction.\n *\n * @param {String} transactionId\n * @returns {Criteria}\n */\n transactionCaptureCriteria(transactionId) {\n const criteria = new Criteria();\n\n criteria.addFilter(\n Criteria.equals('orderTransactionId', transactionId)\n );\n\n criteria.addAssociation('stateMachineState');\n criteria.addAssociation('refunds');\n criteria.addAssociation('refunds.stateMachineState');\n\n return criteria;\n },\n\n /**\n * Fetches captures and their associated refunds for the current Paystack transaction.\n *\n * @async\n * @returns {Promise}\n */\n async loadCapturesAndRefunds() {\n // Re-entrancy guard: the paystackTransaction watcher can fire while a\n // load is already in flight — avoid the concurrent double request.\n if (!this.paystackTransaction?.id || this.isLoading) {\n return;\n }\n\n this.isLoading = true;\n\n try {\n const captureResult = await this.transactionCaptureRepository.search(\n this.transactionCaptureCriteria(this.paystackTransaction.id),\n Shopware.Context.api\n );\n\n const captures = captureResult.map((capture) => ({\n ...capture,\n state: capture.stateMachineState?.translated?.name\n || capture.stateMachineState?.name\n || '',\n }));\n\n const refunds = [];\n\n captures.forEach((capture) => {\n if (!capture.refunds?.length) {\n return;\n }\n\n capture.refunds.forEach((refund) => {\n refunds.push({\n ...refund,\n state: refund.stateMachineState?.translated?.name\n || refund.stateMachineState?.name\n || '',\n });\n });\n });\n\n this.captures = captures;\n this.refunds = refunds;\n } catch (error) {\n if (isAbortError(error)) {\n return;\n }\n\n this.createNotificationError({\n message: error.message,\n });\n } finally {\n this.isLoading = false;\n }\n },\n\n /**\n * Opens the refund modal for the current transaction.\n *\n * The refund is always transaction-level here (the only entry point is\n * the transaction grid), so no capture is selected. `canRefund`\n * guarantees maxRefundableAmount >= minRefundableAmount, so prefilling\n * the maximum is always a valid starting amount.\n */\n onOpenRefundModal() {\n this.activeTransaction = this.paystackTransaction;\n this.activeCapture = null;\n this.refundCurrency = this.paystackTransaction.customFields?.paystack_currency;\n this.refundAmount = this.maxRefundableAmount;\n this.showRefundModal = true;\n },\n\n /**\n * Opens the refund list modal for the selected capture.\n *\n * @param {Object} item\n */\n onOpenRefundsListModal(item) {\n this.activeCapture = item;\n this.showRefundsListModal = true;\n },\n\n /**\n * Closes the refund list modal and resets active capture.\n */\n onCloseRefundsListModal() {\n this.activeCapture = null;\n this.showRefundsListModal = false;\n },\n\n /**\n * Closes the refund modal and resets refund-related data.\n */\n onCloseRefundModal() {\n this.showRefundModal = false;\n this.activeTransaction = null;\n this.refundAmount = null;\n this.refundCurrency = null;\n this.customerNote = null;\n this.merchantNote = null;\n },\n\n /**\n * Initiates the refund process through the Paystack refund service.\n */\n onConfirmRefund() {\n if (this.refundAmount < this.minRefundableAmount) {\n this.createNotificationError({\n message: this.$t('kommandhub-paystack-detail.refund.errorAmountTooLow', {\n minAmount: this.currencyFilter(this.minRefundableAmount, this.refundCurrency),\n }),\n });\n return;\n }\n\n if (this.refundAmount > this.maxRefundableAmount) {\n this.createNotificationError({\n message: this.$t('kommandhub-paystack-detail.refund.errorAmountTooHigh', {\n maxAmount: this.currencyFilter(this.maxRefundableAmount, this.refundCurrency),\n }),\n });\n return;\n }\n\n this.isRefundLoading = true;\n\n const payload = {\n transaction: this.activeTransaction.customFields?.paystack_reference,\n orderTransactionId: this.activeTransaction.id,\n orderTransactionCaptureId: this.activeCapture?.id,\n // Major units; server converts to minor units per currency decimals.\n amount: this.refundAmount,\n currency: this.refundCurrency,\n customer_note: this.customerNote,\n merchant_note: this.merchantNote,\n };\n\n this.paystackRefundService.refund(payload)\n .then(async () => {\n this.isRefundSuccess = true;\n await this.loadCapturesAndRefunds();\n })\n .catch((error) => {\n if (isAbortError(error)) {\n return;\n }\n\n const errorData = error.response?.data;\n let message = errorData?.error || error.message;\n\n if (errorData?.meta?.nextStep) {\n message += ` ${errorData.meta.nextStep}`;\n }\n\n this.createNotificationError({\n message,\n });\n })\n .finally(() => {\n this.isRefundLoading = false;\n });\n },\n\n /**\n * Handles the completion of the refund process.\n */\n onRefundFinished() {\n this.isRefundSuccess = false;\n this.onCloseRefundModal();\n },\n },\n});\n","import frFR from './snippet/fr-FR.json';\nimport deDE from './snippet/de-DE.json';\nimport enGB from './snippet/en-GB.json';\n\nShopware.Locale.extend('fr-FR', frFR);\nShopware.Locale.extend('de-DE', deDE);\nShopware.Locale.extend('en-GB', enGB);\n\nimport PaystackRefundService from './service/paystack-refund.service';\n\nShopware.Service().register('paystackRefundService', (container) => {\n const initContainer = Shopware.Application.getContainer('init');\n return new PaystackRefundService(initContainer.httpClient, container.loginService);\n});\n\nimport './acl';\nimport './module/sw-order/page/sw-order-detail'\nimport './view/kommandhub-paystack-detail'\n\nShopware.Module.register('kommandhub-paystack-detail', {\n routeMiddleware(next, currentRoute) {\n if (currentRoute.name === 'sw.order.detail') {\n const paystackRoute = 'kommandhub.paystack.detail';\n\n if (!currentRoute.children.some(child => child.name === paystackRoute)) {\n currentRoute.children.push({\n name: paystackRoute,\n path: 'kommandhub/paystack',\n component: 'kommandhub-paystack-detail',\n meta: {\n parentPath: 'sw.order.detail',\n privilege: 'order.viewer',\n },\n props: {\n default: ($route) => {\n return { orderId: $route.params.id.toLowerCase() };\n },\n },\n });\n }\n }\n next(currentRoute);\n }\n});"],"names":["Classes","PaystackRefundService","httpClient","loginService","apiEndpoint","payload","response","template$1","PAYSTACK_HANDLER_IDENTIFIER","isAbortError","error","template","criteria","_b","_a","transaction","icon","CURRENCY_DECIMALS","ACTIVE_REFUND_STATES","FAILED_CAPTURE_STATE","currencyDecimals","currency","roundToCurrency","value","minRefundableAmount","minMinorUnits","sumActiveRefunds","refunds","total","refund","maxRefundableAmount","transactionAmount","captures","refunded","activeCaptures","capture","Store","Mixin","Criteria","_c","_d","_e","_f","_g","_h","calcMaxRefundable","calcMinRefundable","salesChannelId","transactionId","item","errorData","message","frFR","deDE","enGB","container","initContainer","next","currentRoute","paystackRoute","child","$route"],"mappings":"4mJAAM,CAAE,QAAAA,CAAO,EAAK,SAEpB,MAAMC,UAA8BD,EAAQ,UAAW,CACnD,YAAYE,EAAYC,EAAcC,EAAc,WAAY,CAC5D,MAAMF,EAAYC,EAAcC,CAAW,EAC3C,KAAK,KAAO,uBACpB,CAEI,OAAOC,EAAS,CACZ,OAAO,KAAK,WAAW,KACnB,0BACAA,EACA,CACI,QAAS,KAAK,gBAAe,CAC7C,CACA,EAAU,KAAMC,GACGN,EAAQ,WAAW,eAAeM,CAAQ,CACpD,CACT,CACA,CCZA,SAAS,QAAQ,YAAY,EAAE,yBAAyB,CACpD,SAAU,yBACV,OAAQ,KACR,IAAK,WACL,MAAO,CACH,OAAQ,CAIJ,WAAY,CAAA,EACZ,aAAc,CAAC,cAAc,CACzC,CACA,CACA,CAAC,ECpBD,MAAAC,EAAe,8nBCMFC,EACT,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,YAAW,CAAE,EAE5E,CACA,CAAiB,CAEjB,CACQJ,EAAKC,CAAY,CACzB,CACA,CAAC"} \ No newline at end of file diff --git a/src/Resources/views/storefront/page/account/bank.html.twig b/src/Resources/views/storefront/page/account/bank.html.twig index 73618f4..61a2d5a 100644 --- a/src/Resources/views/storefront/page/account/bank.html.twig +++ b/src/Resources/views/storefront/page/account/bank.html.twig @@ -1,45 +1,45 @@ -{% block page_account_overview_bank_details %} - {% block page_account_overview_bank_details_visibility %} +{% block page_account_overview_paystack_bank_details %} + {% block page_account_overview_paystack_bank_details_visibility %} {% if config('KommandhubPaystackSW.config.collectBankData') %} - {% block page_account_overview_bank_details_wrapper %} + {% block page_account_overview_paystack_bank_details_wrapper %}