Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
472c3ae9dd | ||
|
|
ad9fb9acf6 | ||
|
|
83e0536332 | ||
|
|
c33dce0abd | ||
|
|
cdd91f8d7c | ||
|
|
b55c80d150 | ||
|
|
b1fe4edb9e | ||
|
|
8ac6bc5863 |
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@ -1 +1,2 @@
|
||||
# These are supported funding model platforms
|
||||
custom: https://btcpayserver.org/donate/
|
||||
|
||||
38
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: File a bug report
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Your BTCPay Environment (please complete the following information):**
|
||||
- BTCPay Server Version [available in the right bottom corner of footer]
|
||||
- Deployment Method: [e.g. Docker, Manual, Third-Party-hoist]
|
||||
- Browser [e.g. chrome, safari]
|
||||
|
||||
**Logs (if applicable)**
|
||||
Basic logs can be found in Server Settings > Logs. More logs https://docs.btcpayserver.org/Troubleshooting/#2-looking-through-the-logs
|
||||
|
||||
**Setup Parameters**
|
||||
If you're reporting a deployment issue run `. btcpay-setup.sh -i` and paste your the parameters by obscuring private information.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
79
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
79
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
@ -1,79 +0,0 @@
|
||||
name: 🐛 Bug Report
|
||||
description: File a bug report
|
||||
title: "[Bug]: "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### ❗️ Read this before submitting your bug report:
|
||||
- **Provide as much detail as possible** - error logs, screenshots, your exact configuration. If the issue cannot be reproduced, it cannot be fixed.
|
||||
- **Avoid reporting "error 500" or "white page" errors** - this is a universal error message that does not provide enough information to qualify the issue. Enable debug mode in the Performance section of PrestaShop or manually in `/config/defines.inc.php` and try again. You should get a proper error message.
|
||||
- Thank you for taking the time to fill out this bug report!
|
||||
- type: textarea
|
||||
id: version
|
||||
attributes:
|
||||
label: What is your BTCPay Server version?
|
||||
description: You can see the version in the footer's bottom right corner
|
||||
placeholder: I'm running BTCPay v1.X.X.X
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: deployment
|
||||
attributes:
|
||||
label: How did you deploy BTCPay Server?
|
||||
description: Docker, manual, third-party host? Read more on deployment methods [here](https://docs.btcpayserver.org/Deployment/)
|
||||
placeholder: I'm running BTCPay Server on a...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: module-version
|
||||
attributes:
|
||||
label: What is version of the PrestaShop plugin are you using?
|
||||
description: You can see the version in the header of the configuration page or in the module list
|
||||
placeholder: I'm running BTCPay v1.X.X.X
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: What happened?
|
||||
description: A clear and concise description of what the bug is.
|
||||
placeholder: Tell us what you see!
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: How did you encounter this bug?
|
||||
description: Step by step describe how did you encounter the bug?
|
||||
placeholder: 1. I clicked X 2. Then I clicked Y 3. See error
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logoutput
|
||||
attributes:
|
||||
label: Relevant log output
|
||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. PrestaShop logs can be found in Advanced Parameters > Logs.
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: browser
|
||||
attributes:
|
||||
label: What browser do you use (if useful)?
|
||||
description: Provide your browser and it's version. If you replicated issues on multiple browsers, let us know which ones.
|
||||
placeholder: For example Safari 15.00, Chrome 10.0, Tor, Edge, etc
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: additonal
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: Feel free to provide additional information. Screenshots are always helpful.
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Are you sure this is a bug report?
|
||||
description: By submitting this report, you agree that this is not a support or a feature request. For general questions please read our [documentation](https://docs.btcpayserver.org). You can ask questions [on our community chat](https://chat.btcpayserver.org)
|
||||
options:
|
||||
- label: I confirm this is a bug report
|
||||
required: true
|
||||
18
.github/ISSUE_TEMPLATE/config.yml
vendored
18
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,17 +1,5 @@
|
||||
blank_issues_enabled: true
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💡 Request a feature
|
||||
url: https://github.com/btcpayserver/prestashop-plugin/discussions/categories/ideas-feature-requests
|
||||
about: Submit a feature request or vote on ideas posted by others. Features with most upvotes become roadmap candidates
|
||||
- name: 🧑💻 Ask a technical question
|
||||
url: https://github.com/btcpayserver/prestashop-plugin/discussions/new?category=technical-support
|
||||
about: If you're experiencing a technical problem post it to our community support forum
|
||||
- name: 📝 Official Documentation
|
||||
url: https://docs.btcpayserver.org
|
||||
about: Check our documentation for answers to common questions
|
||||
- name: 💬 Community Support Chat
|
||||
- name: Community Support Chat
|
||||
url: https://chat.btcpayserver.org/
|
||||
about: Ask general questions and get community support in real-time
|
||||
- name: 🙏 PrestaShop Support
|
||||
url: https://www.prestashop-project.org/support/
|
||||
about: Read up on how you can get support for your PrestaShop store
|
||||
about: Ask general questions and get community support in real-time.
|
||||
|
||||
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a new feature or enhancement
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Sketch/Image/Wireframe/Mockup**
|
||||
If applicable provide examples, wireframes, sketches or images to better explain your idea.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<!-----------------------------------------------------------------------------
|
||||
Thank you for contributing to the BTCPay plugin!
|
||||
|
||||
Please take the time to edit the "Answers" rows below with the necessary information.
|
||||
------------------------------------------------------------------------------>
|
||||
|
||||
| Questions | Answers
|
||||
| ------------- | -------------------------------------------------------
|
||||
| Description? | Please be specific when describing the PR. <br> Every detail helps: versions, browser/server configuration, specific module/theme, etc. Feel free to add more information below this table.
|
||||
| Type? | bug fix / improvement / new feature / refacto / critical
|
||||
| BC breaks? | yes / no
|
||||
| Deprecations? | yes / no
|
||||
| Fixed ticket? | Fixes btcpayserver/prestashop-plugin#{issue number here}.
|
||||
| How to test? | Please indicate how to best verify that this PR is correct.
|
||||
|
||||
<!-- Click the form's "Preview" button to make sure the table is functional in GitHub. Thank you! -->
|
||||
33
.github/dependabot.yml
vendored
33
.github/dependabot.yml
vendored
@ -1,40 +1,9 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Ensure root composer is up-to-date
|
||||
- package-ecosystem: composer
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
open-pull-requests-limit: 5
|
||||
reviewers:
|
||||
- BitcoinMitchell
|
||||
labels:
|
||||
- dependencies
|
||||
|
||||
# Ensure module composer is up-to-date
|
||||
- package-ecosystem: composer
|
||||
directory: /modules/btcpay
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
open-pull-requests-limit: 5
|
||||
reviewers:
|
||||
- BitcoinMitchell
|
||||
labels:
|
||||
- dependencies
|
||||
|
||||
# Ensure workflows are up-to-date
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/.github/workflows"
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
open-pull-requests-limit: 5
|
||||
reviewers:
|
||||
- BitcoinMitchell
|
||||
open-pull-requests-limit: 10
|
||||
labels:
|
||||
- dependencies
|
||||
|
||||
35
.github/pull_request_template.md
vendored
35
.github/pull_request_template.md
vendored
@ -1,35 +0,0 @@
|
||||
# Description
|
||||
|
||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
|
||||
|
||||
- Fixes # (issue)
|
||||
- Depends on # (issue or pr)
|
||||
|
||||
# Type of change
|
||||
|
||||
Please delete options that are not relevant.
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] Refactor (non-breaking change which improves the codebase)
|
||||
|
||||
# How Has This Been Tested?
|
||||
|
||||
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
|
||||
|
||||
- [ ] Test A
|
||||
- [ ] Test B
|
||||
|
||||
**Test Configuration**:
|
||||
* BTCPay Server version:
|
||||
* PrestaShop version:
|
||||
* PHP version:
|
||||
|
||||
# Checklist:
|
||||
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] I have checked my code and corrected any misspellings
|
||||
39
.github/workflows/dependencies.yml
vendored
Normal file
39
.github/workflows/dependencies.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: "Validate"
|
||||
|
||||
on: [ "pull_request" ]
|
||||
|
||||
jobs:
|
||||
security:
|
||||
name: "Local PHP Security Checker (PHP ${{ matrix.php-versions }})"
|
||||
runs-on: "ubuntu-latest"
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: [ '7.3', '7.4', '8.0', '8.1' ]
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v3"
|
||||
- name: "Setup PHP, with composer and extensions"
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
php-version: "${{ matrix.php-versions }}"
|
||||
extensions: "mbstring, xml, ctype, iconv, intl, gd"
|
||||
tools: "composer:v2"
|
||||
- name: "Get composer cache directory"
|
||||
id: "composer-cache"
|
||||
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
|
||||
- name: "Cache composer dependencies"
|
||||
uses: "actions/cache@v3"
|
||||
with:
|
||||
path: "${{ steps.composer-cache.outputs.dir }}"
|
||||
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}"
|
||||
restore-keys: "${{ runner.os }}-composer-"
|
||||
- name: "Validate composer"
|
||||
run: "composer validate"
|
||||
- name: "Install Composer dependencies"
|
||||
run: "composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader"
|
||||
|
||||
# Ensure our dependencies are fine
|
||||
- name: "Local PHP Security Checker"
|
||||
uses: "docker://pplotka/local-php-security-checker-github-actions:v1.0.0"
|
||||
with:
|
||||
path: "./modules/btcpay/composer.lock"
|
||||
35
.github/workflows/release.yml
vendored
35
.github/workflows/release.yml
vendored
@ -4,33 +4,28 @@ on:
|
||||
push:
|
||||
tags: [ 'v*' ] # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
linting:
|
||||
name: "Release a new ZIP"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@c2d88d3ecc89a9ef08eebf45d9637801dcee7eb5" # v6.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
uses: "actions/checkout@v2"
|
||||
- name: "Setup PHP, with composer and extensions"
|
||||
uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2.36.0
|
||||
uses: "shivammathur/setup-php@v2" # https://github.com/shivammathur/setup-php
|
||||
with:
|
||||
php-version: "8.0"
|
||||
php-version: "7.3"
|
||||
extensions: "mbstring, xml, ctype, iconv, intl, gd"
|
||||
tools: "composer:v2"
|
||||
- name: "Get composer cache directory"
|
||||
id: "composer-cache"
|
||||
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
|
||||
- name: "Cache composer dependencies"
|
||||
uses: "actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
|
||||
uses: "actions/cache@v3"
|
||||
with:
|
||||
path: "${{ steps.composer-cache.outputs.dir }}"
|
||||
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}"
|
||||
restore-keys: "${{ runner.os }}-composer-"
|
||||
lookup-only: true
|
||||
- name: "Validate composer"
|
||||
run: "composer validate"
|
||||
- name: "Install Composer dependencies"
|
||||
@ -40,14 +35,24 @@ jobs:
|
||||
- name: "Make zip"
|
||||
run: "make"
|
||||
|
||||
# Make a release from the tag and upload the zip
|
||||
# Make a release from the tag
|
||||
- name: "Create Release"
|
||||
id: "create_release"
|
||||
uses: "softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b" # v2.5.0
|
||||
uses: "actions/create-release@v1"
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # This token is provided by Actions, you do not need to create your own token
|
||||
with:
|
||||
tag_name: "${{ github.ref }}"
|
||||
release_name: "Release ${{ github.ref }}"
|
||||
|
||||
# Upload the zip to the release
|
||||
- name: "Upload Release Asset"
|
||||
id: "upload-release-asset"
|
||||
uses: "actions/upload-release-asset@v1"
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
with:
|
||||
name: "Release ${{ github.ref_name }}"
|
||||
files: "./build/btcpay.zip"
|
||||
fail_on_unmatched_files: true
|
||||
generate_release_notes: true
|
||||
upload_url: "${{ steps.create_release.outputs.upload_url }}" # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: "./build/btcpay.zip"
|
||||
asset_name: "btcpay.zip"
|
||||
asset_content_type: "application/zip"
|
||||
|
||||
26
.github/workflows/security.yml
vendored
26
.github/workflows/security.yml
vendored
@ -1,26 +0,0 @@
|
||||
name: GitHub Actions Security Analysis with zizmor 🌈
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
branches: ["**"]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
zizmor:
|
||||
name: Run zizmor 🌈
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
security-events: write
|
||||
contents: read # only needed for private repos
|
||||
actions: read # only needed for private repos
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@c2d88d3ecc89a9ef08eebf45d9637801dcee7eb5 # v6.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run zizmor 🌈
|
||||
uses: zizmorcore/zizmor-action@e639db99335bc9038abc0e066dfcd72e23d26fb4 # v0.3.0
|
||||
21
.github/workflows/validate.yml
vendored
21
.github/workflows/validate.yml
vendored
@ -1,14 +1,6 @@
|
||||
name: "Validate"
|
||||
|
||||
on:
|
||||
push:
|
||||
paths: [ 'modules/**' ]
|
||||
branches: [ '6.x' ]
|
||||
tags: [ 'v*' ]
|
||||
pull_request:
|
||||
paths: [ 'modules/**' ]
|
||||
|
||||
permissions: {}
|
||||
on: [ "pull_request" ]
|
||||
|
||||
jobs:
|
||||
linting:
|
||||
@ -16,14 +8,12 @@ jobs:
|
||||
runs-on: "ubuntu-latest"
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: [ '8.0', '8.1' ]
|
||||
php-versions: [ '7.3', '7.4', '8.0', '8.1' ]
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@c2d88d3ecc89a9ef08eebf45d9637801dcee7eb5" # v6.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
uses: "actions/checkout@v3"
|
||||
- name: "Setup PHP, with composer and extensions"
|
||||
uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2.36.0
|
||||
uses: "shivammathur/setup-php@v2" # https://github.com/shivammathur/setup-php
|
||||
with:
|
||||
php-version: "${{ matrix.php-versions }}"
|
||||
extensions: "mbstring, xml, ctype, iconv, intl, gd"
|
||||
@ -32,12 +22,11 @@ jobs:
|
||||
id: "composer-cache"
|
||||
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
|
||||
- name: "Cache composer dependencies"
|
||||
uses: "actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
|
||||
uses: "actions/cache@v3"
|
||||
with:
|
||||
path: "${{ steps.composer-cache.outputs.dir }}"
|
||||
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}"
|
||||
restore-keys: "${{ runner.os }}-composer-"
|
||||
lookup-only: true
|
||||
- name: "Validate composer"
|
||||
run: "composer validate"
|
||||
- name: "Install Composer dependencies"
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,12 +14,11 @@ btcpay.zip
|
||||
.phpcs-cache
|
||||
|
||||
# Ignore developer specific docker-compose
|
||||
docker-compose.override.yml
|
||||
docker-compose.yml
|
||||
|
||||
# Ignore files in the module that are added via `make`
|
||||
/modules/btcpay/LICENSE
|
||||
/modules/btcpay/README.md
|
||||
/modules/btcpay/docs/README.md
|
||||
|
||||
# We dont care about the lib/vendor folder
|
||||
/modules/btcpay/lib/
|
||||
|
||||
@ -1 +0,0 @@
|
||||
8.0
|
||||
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2025 btcpayserver
|
||||
Copyright (c) 2017-2023 btcpayserver
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
52
Makefile
52
Makefile
@ -3,10 +3,9 @@ MODULE_FOLDER := "./modules"
|
||||
|
||||
BUILD_FOLDER := "./build"
|
||||
ZIP_NAME := "${MODULE}.zip"
|
||||
ZIP_DEBUG_NAME := "${MODULE}_debug.zip"
|
||||
MODULE_OUT := "${BUILD_FOLDER}/${ZIP_NAME}"
|
||||
|
||||
.PHONY: all build install update upgrade clean lint lint-fix
|
||||
.PHONY: all build install upgrade clean lint lint-fix
|
||||
|
||||
all: build
|
||||
|
||||
@ -28,68 +27,25 @@ build: ## Build the bastard binary file
|
||||
# Copy the license to the module
|
||||
@cp ./LICENSE "$(MODULE_FOLDER)/$(MODULE)"
|
||||
|
||||
# Copy the README to the module root and docs
|
||||
# Copy the README to the module
|
||||
@cp ./README.md "$(MODULE_FOLDER)/$(MODULE)"
|
||||
@cp ./README.md "$(MODULE_FOLDER)/$(MODULE)/docs"
|
||||
|
||||
# Zip the module
|
||||
@cd $(MODULE_FOLDER) \
|
||||
&& zip -r $(ZIP_NAME) $(MODULE) \
|
||||
&& mv $(ZIP_NAME) "../$(BUILD_FOLDER)"
|
||||
|
||||
debug: ## Build the bastard binary file as debug file
|
||||
# Installing all dependencies
|
||||
@cd "$(MODULE_FOLDER)/$(MODULE)" \
|
||||
&& composer install
|
||||
|
||||
# Dump autoloader
|
||||
@cd "$(MODULE_FOLDER)/$(MODULE)" \
|
||||
&& composer dump-autoload -o
|
||||
|
||||
# Removing the old ZIP if present
|
||||
@rm -f $(MODULE_OUT)
|
||||
|
||||
# Make the build folder
|
||||
@mkdir -p $(BUILD_FOLDER)
|
||||
|
||||
# Copy the license to the module
|
||||
@cp ./LICENSE "$(MODULE_FOLDER)/$(MODULE)"
|
||||
|
||||
# Copy the README to the module
|
||||
@cp ./README.md "$(MODULE_FOLDER)/$(MODULE)"
|
||||
|
||||
# Zip the module
|
||||
@cd $(MODULE_FOLDER) \
|
||||
&& zip -r $(ZIP_DEBUG_NAME) $(MODULE) \
|
||||
&& mv $(ZIP_DEBUG_NAME) "../$(BUILD_FOLDER)"
|
||||
|
||||
bump: ## Bump all package versions
|
||||
# Bump all root dependencies
|
||||
@composer install
|
||||
|
||||
# Bump all module dependencies
|
||||
@cd "$(MODULE_FOLDER)/$(MODULE)" \
|
||||
&& composer install
|
||||
|
||||
install: ## Install everything for development
|
||||
# Installing all root dependencies
|
||||
@composer install
|
||||
composer install
|
||||
|
||||
# Installing all module dependencies
|
||||
@cd "$(MODULE_FOLDER)/$(MODULE)" \
|
||||
&& composer install
|
||||
|
||||
update: ## Update all dependencies (including development)
|
||||
# Upgrading all root dependencies
|
||||
@composer update
|
||||
|
||||
# Upgrading all module dependencies
|
||||
@cd "$(MODULE_FOLDER)/$(MODULE)" \
|
||||
&& composer update
|
||||
|
||||
upgrade: ## Upgrade all dependencies (including development)
|
||||
# Upgrading all root dependencies
|
||||
@composer upgrade
|
||||
composer upgrade
|
||||
|
||||
# Upgrading all module dependencies
|
||||
@cd "$(MODULE_FOLDER)/$(MODULE)" \
|
||||
|
||||
98
README.md
98
README.md
@ -1,48 +1,23 @@
|
||||
# BTCPay Server - Prestashop Plugin
|
||||
# Prestashop Plugin
|
||||
|
||||

|
||||
[](https://github.com/btcpayserver/prestashop-plugin/pulse)
|
||||
[](https://github.com/btcpayserver/prestashop-plugin/actions)
|
||||
[](https://github.com/btcpayserver/prestashop-plugin/blob/5.x/LICENSE)
|
||||
[](https://github.com/btcpayserver/prestashop-plugin/graphs/contributors)
|
||||
|
||||
<h3 align="center">
|
||||
Accept Bitcoin payments within PrestaShop
|
||||
</h3>
|
||||
[](https://github.com/btcpayserver/prestashop-plugin/releases)
|
||||
[](https://github.com/btcpayserver/prestashop-plugin/releases)
|
||||
|
||||
<div align="center">
|
||||
<p>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/pulse"><img src="https://img.shields.io/maintenance/yes/2025?style=flat-square" alt="Maintained"/></a>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/actions"><img src="https://img.shields.io/github/actions/workflow/status/btcpayserver/prestashop-plugin/validate.yml?style=flat-square" alt="GitHub Workflow Status"/></a>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/blob/6.x/LICENSE"><img src="https://img.shields.io/github/license/btcpayserver/prestashop-plugin?color=brightgreen&style=flat-square" alt="GitHub License"/></a>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin#contributing"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs are welcome"/></a>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/graphs/contributors"><img src="https://img.shields.io/github/contributors-anon/btcpayserver/prestashop-plugin?style=flat-square" alt="GitHub contributors"/></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/releases"><img src="https://img.shields.io/github/v/release/btcpayserver/prestashop-plugin?sort=semver&style=flat-square" alt="GitHub release (latest SemVer)"/></a>
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/releases"><img src="https://img.shields.io/github/downloads/btcpayserver/prestashop-plugin/total?style=flat-square" alt="GitHub all releases"/></a>
|
||||
</p>
|
||||
</div>
|
||||
This is a Bitcoin payment plugin for PrestaShop using BTCPay server. [BTCPay Server](https://btcpayserver.org) is a free and open source server for merchants wanting to accept Bitcoin for their business.
|
||||
|
||||
<div align="center">
|
||||
<sub>"This is lies, my trust in you is broken, I will make you obsolete" 💚
|
||||
</a>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/issues/new/choose">Report a bug</a>
|
||||
·
|
||||
<a href="https://github.com/btcpayserver/prestashop-plugin/discussions/new/choose">Request a feature</a>
|
||||
·
|
||||
<a href="https://docs.btcpayserver.org/FAQ/">FAQ</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Requirements
|
||||
## Requirements
|
||||
|
||||
Please ensure that you meet the following requirements before installing this plugin.
|
||||
|
||||
- You are using PHP 8.0 or higher
|
||||
- Your PrestaShop is version 8.0/9.0 or higher.
|
||||
- Your BTCPay Server is version 1.7.0 or higher
|
||||
- You are using PHP 7.3.0 or higher
|
||||
- Your PrestaShop is version 1.7.8.0 or higher.
|
||||
- PrestaShop 8.0 support has not yet been added/tested.
|
||||
- Your BTCPay Server is version 1.3.0 or higher
|
||||
- The PDO, curl, gd, intl, json, and mbstring PHP extensions are available
|
||||
- You have a BTCPay Server, either [self-hosted](https://docs.btcpayserver.org/Deployment/) or [hosted by a third party](https://docs.btcpayserver.org/Deployment/ThirdPartyHosting/)
|
||||
- [You've a registered account on the instance](https://docs.btcpayserver.org/RegisterAccount)
|
||||
@ -50,45 +25,48 @@ Please ensure that you meet the following requirements before installing this pl
|
||||
- [You've a wallet connected to your store](https://docs.btcpayserver.org/WalletSetup)
|
||||
|
||||
### Tested successfully
|
||||
- Prestashop v8.0, v8.0.1, v8.0.4, v8.1.0, v8.1.3, v8.1.4, v8.2.1, v9.0.0
|
||||
- BTCPay server v1.7.0, v1.7.3.0, v1.12.5, v1.13.0, v1.13.5, v2.1.5, v2.2.1
|
||||
- BTCPay server v2 is supported as of module version v6.3.0.
|
||||
- Prestashop version 1.7.8.x up to 1.7.8.7
|
||||
- BTCPay server version 1.3.4 up to 1.6.12.0
|
||||
|
||||
### Multistore
|
||||
## Multistore
|
||||
|
||||
As of right now the module is **not** compatible with Prestashop's multistore feature. Any help to resolve this is very much welcomed. Please see the relevant [discussion](https://github.com/btcpayserver/prestashop-plugin/discussions/130).
|
||||
As of right now the module is **not** compatible with Prestashop's multistore feature.
|
||||
|
||||
## 📗 Documentation
|
||||
## Documentation
|
||||
|
||||
Please check out our [official website](https://btcpayserver.org/), [complete documentation](https://docs.btcpayserver.org/) and [FAQ](https://docs.btcpayserver.org/FAQ/) for more details.
|
||||
Please check out our [official website](https://btcpayserver.org/), our [complete documentation](https://docs.btcpayserver.org/) and [FAQ](https://docs.btcpayserver.org/FAQ/) for more details.
|
||||
|
||||
If you have trouble using BTCPay Server, consider joining [communities listed on the official website](https://btcpayserver.org/#communityCTA) to get help from other contributors. Only create a [GitHub issue](https://github.com/btcpayserver/prestashop-plugin/issues/new/choose) for technical issues you can't resolve through other channels or feature requests you've validated with other members of the community.
|
||||
If you have trouble using BTCPay, consider joining [communities listed on official website](https://btcpayserver.org/#communityCTA) to get help from BTCPay community members. Only file [Github issue](https://github.com/btcpayserver/prestashop-plugin/issues) for technical issues you can't resolve through other channels or feature requests you've validated with other members of community.
|
||||
|
||||
## 🚀 Quick Start Guide
|
||||
Main community chat is located on [Mattermost](https://chat.btcpayserver.org/).
|
||||
|
||||
### Quick Start Guide
|
||||
|
||||
To get up and running with our plugin quickly, see the [PrestaShop Guide on our documentation website](https://docs.btcpayserver.org/PrestaShop/).
|
||||
|
||||
## 🧑💻 Versioning
|
||||
## Versioning
|
||||
|
||||
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [releases within this repository](https://github.com/btcpayserver/prestashop-plugin/releases).
|
||||
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the
|
||||
[tags on this repository](https://github.com/btcpayserver/prestashop-plugin/tags).
|
||||
|
||||
## 🤝 Contributing
|
||||
## Contributing
|
||||
|
||||
BTCPay Server is built and maintained entirely by volunteer contributors around the internet. We welcome and appreciate new contributions.
|
||||
[](https://twitter.com/btcpayserver)
|
||||
[](https://chat.btcpayserver.org/btcpayserver)
|
||||
|
||||
Contributors looking to help out, before opening a pull request, please join [our community chat](https://chat.btcpayserver.org/) or [start a GitHub discussion](https://github.com/btcpayserver/btcpayserver/discussions) to get early feedback, discuss the best ways to tackle the problem, and ensure there is no work duplication.
|
||||
BTCPay is built and maintained entirely by volunteer contributors around the internet. We welcome and appreciate new contributions.
|
||||
|
||||
### 🔧 Development
|
||||
Contributors looking to help out, before opening a pull request, please [create an issue](https://github.com/btcpayserver/prestashop-plugin/issues/new/choose)
|
||||
or join [our community chat](https://chat.btcpayserver.org) to get early feedback, discuss best ways to tackle the problem and to ensure there is no work duplication.
|
||||
|
||||
We recommend using [PrestaShop Kickstarter](https://github.com/PrestaShopCorp/docker-compose-kickstarter) (which supports [ngrok](https://ngrok.com/)) and a dockerized [BTCPay Server instance](https://github.com/btcpayserver/btcpayserver-docker/blob/master/Production/docker-compose.btc.yml) (or [an online testnet instance](https://testnet.demo.btcpayserver.org/)) for testing locally.
|
||||
## PrestaShop Support
|
||||
|
||||
## 🏪 PrestaShop Support
|
||||
PrestaShop support can be found through it's official channels.
|
||||
|
||||
PrestaShop support can be found through its official channels.
|
||||
* [Homepage](https://www.prestashop.com)
|
||||
* [Documentation](https://doc.prestashop.com)
|
||||
* [Support Forums](https://www.prestashop.com/forums)
|
||||
|
||||
* [Documentation](https://docs.prestashop-project.org/v.8-documentation) - contains answers to commonly asked questions and provides instructions for almost everything. Including setup, management, etc.
|
||||
* [Support Forums](https://www.prestashop.com/forums) - the official Prestashop forum is a good place to find further answers and ask Prestashop related questions.
|
||||
|
||||
## 📝 License
|
||||
## License
|
||||
|
||||
BTCPay Server software, logo and designs are provided under [MIT License](LICENSE).
|
||||
|
||||
75
SECURITY.md
75
SECURITY.md
@ -1,74 +1,7 @@
|
||||
# Reporting a potential Vulnerability.
|
||||
<!-- Short intro. -->
|
||||
We take the security of our project seriously, and we encourage responsible disclosure of any vulnerabilities that may be found. To facilitate this process, we have established the following vulnerability reporting process.
|
||||
Security issues and bugs should be reported privately, via email. To report a security issue, please send an email to **security@btcpayserver.org** (not for support).
|
||||
|
||||
We appreciate your efforts to disclose your findings responsibly.
|
||||
You will receive a reply indicating the next steps in handling your report. If for some reason you do not receive a reply within 24 hours, please follow up via email to ensure the original message was received.
|
||||
|
||||
##### 1. Reporting Channel
|
||||
If you believe you have discovered a vulnerability in our project, please email us at `security@btcpayserver.org`. Alternatively, you may report the vulnerability to us through [huntr.dev](https://huntr.dev/repos/btcpayserver/btcpayserver/).
|
||||
After the initial reply to your report, you will be informed of the progress towards a fix and full announcement. You may be asked to provide additional information or guidance.
|
||||
|
||||
Please allow for up to 2 business days for an acknowledgement of receipt. If you receive no response within 2 business days, please follow up via email to ensure the original message was received.
|
||||
|
||||
Upon review of your report, you may be asked to provide additional information or guidance.
|
||||
|
||||
<!--TODO: If available, add link to PGP key used to read security report emails.-->
|
||||
|
||||
##### 2. In-Scope
|
||||
<!-- What's in scope? Any repo in our org for example. -->
|
||||
We welcome reports of vulnerabilities in repositories owned by the [BTCPay Server GitHub Organization](https://github.com/btcpayserver). This includes any issues related to the confidentiality, integrity, or availability of systems or data in these systems.
|
||||
|
||||
##### 3. Out of Scope
|
||||
<!-- What's out of scope? Thinking here about custom deployments, plugins that are not created by BTCPay (this includes kukks plugins that should be reported to him directly). -->
|
||||
1. Any BTCPay Server deployment that has been customized in any way. To facilitate reproducibility, please verify that the BTCPay Server instance is based on the un-altered source-code or [Docker deployment](https://docs.btcpayserver.org/Docker/).
|
||||
2. Any BTCPay Server plugin that is not authored by `btcpayserver` as stated by the author tag in-app.
|
||||
|
||||
##### 4. Preferred Reporting Template
|
||||
<!-- Template example to guide reporter into including specific info that we'd appreciate be included in the report. -->
|
||||
We encourage the use of a reporting template that includes a detailed description of the vulnerability, any evidence or proof of concept, and steps to reproduce the vulnerability.
|
||||
|
||||
Please find an example of an email template [at the end of this document](#7-reporting-template-example).
|
||||
|
||||
##### 5. Timeline for Remediation
|
||||
<!-- Tentative 90 business day timeline for resolution. This is a typical industry standard, but have included wording to include the fact that we're a team of volunteers, and that we cannot guarantee it. -->
|
||||
While we will work to remediate the reported vulnerability within 90 business days from the acknowledgment of the report, being a team of volunteers, we cannot guarantee this timeline to be accurate at all time.
|
||||
|
||||
We will provide regular updates to the reporter until the vulnerability is resolved.
|
||||
|
||||
##### 6. Timeline to Public Disclosure
|
||||
<!-- No tentative timeline, given it can differ based on multiple criteria, but we have to take into account the fact that a public disclosure of a full year is too much. Security by obscurity is rarely beneficial, especially for the uninformed end-users. -->
|
||||
We will work with the reporter to define a suitable timeline to public disclosure once the vulnerability is remediated.
|
||||
|
||||
<!--
|
||||
##### 7. More information
|
||||
For more information on our complete vulnerability response process, please see our [documentation]()
|
||||
-->
|
||||
|
||||
##### 7. Reporting Template Example
|
||||
<!-- Simple template for users to take as example for vulnerability reporting. Contains the basic minimum information that we need to assess promptly a report. -->
|
||||
|
||||
Feel free to use the below template to report a vulnerability.
|
||||
|
||||
```
|
||||
Subject: Vulnerability Report - BTCPay Server
|
||||
|
||||
Dear BTCPay Server team,
|
||||
I am writing to report a security vulnerability that I have identified in BTCPay Server. I believe this vulnerability poses a significant threat to the security of the project and its users.
|
||||
|
||||
Here are the details of the vulnerability:
|
||||
|
||||
* Vulnerability description: [Provide a clear and concise description of the vulnerability]
|
||||
* Impact: [Describe the potential impact of the vulnerability, ie. any potential consequences for the project, its users, or any third parties]
|
||||
* Affected version(s): [Specify which version(s) of the project are affected by the vulnerability]
|
||||
* Steps to reproduce & Proof of Concept: [Provide a step-by-step guide to reproduce the vulnerability, including any screenshots and code snippets you feel would help]
|
||||
* Severity: [Provide your assessment of the severity of the vulnerability, using a scale such as Warning/Low/Medium/High/Critical]
|
||||
* Mitigation or Fix: [Provide your recommendation for a solution or mitigation strategy for the vulnerability]
|
||||
|
||||
If needed, I [agree/do not agree] to be invited into a Github private fork for the purpose of helping resolve this vulnerability. [Please include a link to your github profile]
|
||||
|
||||
Please let me know if you need any further information or if you would like to discuss this vulnerability in more detail.
|
||||
|
||||
Thank you for your attention to this matter.
|
||||
|
||||
Sincerely,
|
||||
[Your Name/Handle]
|
||||
```
|
||||
We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
# Upgrading from 5.0 to 6.0
|
||||
|
||||
Prestashop modules come with an auto-upgrade feature which will be used to upgrade your currently running plugin. This documents serves as a reference for what has been changed.
|
||||
|
||||
## Requirements
|
||||
|
||||
The module requirements have been changed to:
|
||||
- You are using PHP 8.0 or higher
|
||||
- Your PrestaShop is version 8.0 or higher.
|
||||
- Your BTCPay Server is version 1.7.0 or higher
|
||||
179
composer.json
179
composer.json
@ -20,9 +20,8 @@
|
||||
"source": "https://github.com/btcpayserver/prestashop-plugin"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"php": ">=7.3.0",
|
||||
"ext-PDO": "*",
|
||||
"ext-bcmath": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-fileinfo": "*",
|
||||
@ -32,109 +31,91 @@
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-zip": "*",
|
||||
"composer/installers": "^1.12.0"
|
||||
"composer/installers": "^v1.9.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
|
||||
"ergebnis/composer-normalize": "^2.43.0",
|
||||
"ezyang/htmlpurifier": "dev-master as 4.17.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.4.0",
|
||||
"lcobucci/jwt": "dev-3.4.6-patch as 3.4.6",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^v0.7.2",
|
||||
"ergebnis/composer-normalize": "^v2.20.0",
|
||||
"ezyang/htmlpurifier": "dev-master as v4.14.0",
|
||||
"friendsofphp/php-cs-fixer": "^v3.4",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpoffice/phpspreadsheet": "^1.29.1",
|
||||
"prestashop/autoindex": "^2.1",
|
||||
"prestashop/php-dev-tools": "^5",
|
||||
"prestashop/prestashop": "^8.1.7",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3",
|
||||
"prestashop/php-dev-tools": "^v4.2.1",
|
||||
"prestashop/prestashop": "dev-develop",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"slevomat/coding-standard": "^8.15.0",
|
||||
"squizlabs/php_codesniffer": "^3.10.2"
|
||||
"slevomat/coding-standard": "^v7.2.1",
|
||||
"squizlabs/php_codesniffer": "^v3.7.1"
|
||||
},
|
||||
"replace": {
|
||||
"prestashop/blockreassurance": "^5.1.4",
|
||||
"prestashop/blockwishlist": "^3",
|
||||
"prestashop/classic": "^2.0.0-beta",
|
||||
"prestashop/contactform": "^4.3.0",
|
||||
"prestashop/dashactivity": "^2",
|
||||
"prestashop/dashgoals": "^2",
|
||||
"prestashop/dashproducts": "^2",
|
||||
"prestashop/dashtrends": "^2",
|
||||
"prestashop/gamification": "^2.4.0",
|
||||
"prestashop/graphnvd3": "^2",
|
||||
"prestashop/gridhtml": "^2",
|
||||
"prestashop/gsitemap": "^4",
|
||||
"prestashop/pagesnotfound": "^2",
|
||||
"prestashop/productcomments": "^7.0",
|
||||
"prestashop/ps_banner": "^2",
|
||||
"prestashop/ps_bestsellers": "^1.0",
|
||||
"prestashop/ps_brandlist": "^1.0",
|
||||
"prestashop/ps_cashondelivery": "^2.0",
|
||||
"prestashop/ps_categoryproducts": "^1.0",
|
||||
"prestashop/ps_categorytree": "^2",
|
||||
"prestashop/ps_checkpayment": "^2",
|
||||
"prestashop/ps_contactinfo": "^3.2",
|
||||
"prestashop/ps_crossselling": "^2.0",
|
||||
"prestashop/ps_currencyselector": "^2",
|
||||
"prestashop/ps_customeraccountlinks": "^3",
|
||||
"prestashop/ps_customersignin": "^2",
|
||||
"prestashop/ps_customtext": "^4",
|
||||
"prestashop/ps_dataprivacy": "^2.0",
|
||||
"prestashop/ps_distributionapiclient": "^1.0.1",
|
||||
"prestashop/ps_emailalerts": "^3.0",
|
||||
"prestashop/ps_emailsubscription": "^2.7.0",
|
||||
"prestashop/ps_facetedsearch": "^3.7.1",
|
||||
"prestashop/ps_faviconnotificationbo": "^2",
|
||||
"prestashop/ps_featuredproducts": "^2",
|
||||
"prestashop/ps_googleanalytics": "^5.0",
|
||||
"prestashop/ps_imageslider": "^3",
|
||||
"prestashop/ps_languageselector": "^2",
|
||||
"prestashop/ps_linklist": "^6",
|
||||
"prestashop/ps_mainmenu": "^2",
|
||||
"prestashop/ps_newproducts": "^1.0",
|
||||
"prestashop/ps_searchbar": "^2",
|
||||
"prestashop/ps_sharebuttons": "^2",
|
||||
"prestashop/ps_shoppingcart": "^3",
|
||||
"prestashop/ps_socialfollow": "^2",
|
||||
"prestashop/ps_specials": "^1.0",
|
||||
"prestashop/ps_supplierlist": "^1.0",
|
||||
"prestashop/ps_themecusto": "^1",
|
||||
"prestashop/ps_viewedproduct": "^1.2",
|
||||
"prestashop/ps_wirepayment": "^2",
|
||||
"prestashop/psgdpr": "^1.0",
|
||||
"prestashop/statsbestcategories": "^2",
|
||||
"prestashop/statsbestcustomers": "^2",
|
||||
"prestashop/statsbestmanufacturers": "^2",
|
||||
"prestashop/statsbestproducts": "^2",
|
||||
"prestashop/statsbestsuppliers": "^2",
|
||||
"prestashop/statsbestvouchers": "^2",
|
||||
"prestashop/statscarrier": "^2",
|
||||
"prestashop/statscatalog": "^2",
|
||||
"prestashop/statscheckup": "^2",
|
||||
"prestashop/statsdata": "^2",
|
||||
"prestashop/statsforecast": "^2",
|
||||
"prestashop/statsnewsletter": "^2",
|
||||
"prestashop/statspersonalinfos": "^2",
|
||||
"prestashop/statsproduct": "^2",
|
||||
"prestashop/statsregistrations": "^2",
|
||||
"prestashop/statssales": "^2",
|
||||
"prestashop/statssearch": "^2",
|
||||
"prestashop/statsstock": "^2",
|
||||
"symfony/polyfill-mbstring": "*",
|
||||
"symfony/polyfill-php54": "*",
|
||||
"symfony/polyfill-php55": "^1.10",
|
||||
"symfony/polyfill-php56": "*",
|
||||
"symfony/polyfill-php70": "*",
|
||||
"symfony/polyfill-php71": "*",
|
||||
"symfony/polyfill-php72": "*",
|
||||
"symfony/polyfill-php73": "*",
|
||||
"symfony/polyfill-php74": "*"
|
||||
"prestashop/blockreassurance": "^v5.0",
|
||||
"prestashop/blockwishlist": "^v2.1.2",
|
||||
"prestashop/classic": "^v2.0.0-beta",
|
||||
"prestashop/contactform": "^v4.3.0",
|
||||
"prestashop/dashactivity": "^v2",
|
||||
"prestashop/dashgoals": "^v2",
|
||||
"prestashop/dashproducts": "^v2",
|
||||
"prestashop/dashtrends": "^v2",
|
||||
"prestashop/gamification": "^v2.4.0",
|
||||
"prestashop/graphnvd3": "^v2",
|
||||
"prestashop/gridhtml": "^v2",
|
||||
"prestashop/gsitemap": "^v4",
|
||||
"prestashop/pagesnotfound": "^v2",
|
||||
"prestashop/productcomments": "^v5.0.2",
|
||||
"prestashop/ps_banner": "^v2",
|
||||
"prestashop/ps_bestsellers": "^v1.0",
|
||||
"prestashop/ps_brandlist": "^v1.0",
|
||||
"prestashop/ps_cashondelivery": "^v2.0",
|
||||
"prestashop/ps_categoryproducts": "^v1.0",
|
||||
"prestashop/ps_categorytree": "^v2",
|
||||
"prestashop/ps_checkpayment": "^v2",
|
||||
"prestashop/ps_contactinfo": "^v3.2",
|
||||
"prestashop/ps_crossselling": "^v2.0",
|
||||
"prestashop/ps_currencyselector": "^v2",
|
||||
"prestashop/ps_customeraccountlinks": "^v3",
|
||||
"prestashop/ps_customersignin": "^v2",
|
||||
"prestashop/ps_customtext": "^v4",
|
||||
"prestashop/ps_dataprivacy": "^v2.0",
|
||||
"prestashop/ps_emailalerts": "^v2.0",
|
||||
"prestashop/ps_distributionapiclient": "^v1.0.1",
|
||||
"prestashop/ps_emailsubscription": "^v2.7.0",
|
||||
"prestashop/ps_facetedsearch": "^v3.7.1",
|
||||
"prestashop/ps_faviconnotificationbo": "^v2",
|
||||
"prestashop/ps_featuredproducts": "^v2",
|
||||
"prestashop/ps_googleanalytics": "^v4.0",
|
||||
"prestashop/ps_imageslider": "^v3",
|
||||
"prestashop/ps_languageselector": "^v2",
|
||||
"prestashop/ps_linklist": "^v5",
|
||||
"prestashop/ps_mainmenu": "^v2",
|
||||
"prestashop/ps_newproducts": "^v1.0",
|
||||
"prestashop/ps_searchbar": "^v2",
|
||||
"prestashop/ps_sharebuttons": "^v2",
|
||||
"prestashop/ps_shoppingcart": "^v2",
|
||||
"prestashop/ps_socialfollow": "^v2",
|
||||
"prestashop/ps_specials": "^v1.0",
|
||||
"prestashop/ps_supplierlist": "^v1.0",
|
||||
"prestashop/ps_themecusto": "^v1",
|
||||
"prestashop/ps_viewedproduct": "^v1.2",
|
||||
"prestashop/ps_wirepayment": "^v2",
|
||||
"prestashop/psgdpr": "^v1.0",
|
||||
"prestashop/statsbestcategories": "^v2",
|
||||
"prestashop/statsbestcustomers": "^v2",
|
||||
"prestashop/statsbestmanufacturers": "^v2",
|
||||
"prestashop/statsbestproducts": "^v2",
|
||||
"prestashop/statsbestsuppliers": "^v2",
|
||||
"prestashop/statsbestvouchers": "^v2",
|
||||
"prestashop/statscarrier": "^v2",
|
||||
"prestashop/statscatalog": "^v2",
|
||||
"prestashop/statscheckup": "^v2",
|
||||
"prestashop/statsdata": "^v2",
|
||||
"prestashop/statsforecast": "^v2",
|
||||
"prestashop/statsnewsletter": "^v2",
|
||||
"prestashop/statspersonalinfos": "^v2",
|
||||
"prestashop/statsproduct": "^v2",
|
||||
"prestashop/statsregistrations": "^v2",
|
||||
"prestashop/statssales": "^v2",
|
||||
"prestashop/statssearch": "^v2",
|
||||
"prestashop/statsstock": "^v2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/PrestaShop/jwt"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
@ -152,7 +133,7 @@
|
||||
"ergebnis/composer-normalize": true
|
||||
},
|
||||
"platform": {
|
||||
"php": "8.0"
|
||||
"php": "7.3"
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"prepend-autoloader": false,
|
||||
|
||||
3890
composer.lock
generated
3890
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -93,9 +93,27 @@ class AddressFormat extends AddressFormatCore
|
||||
class AdminAccessController extends AdminAccessControllerCore
|
||||
{
|
||||
}
|
||||
class AdminAddonsCatalogController extends AdminAddonsCatalogControllerCore
|
||||
{
|
||||
}
|
||||
class AdminAddressesController extends AdminAddressesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminAdminPreferencesController extends AdminAdminPreferencesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminAttachmentsController extends AdminAttachmentsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminAttributeGeneratorController extends AdminAttributeGeneratorControllerCore
|
||||
{
|
||||
}
|
||||
class AdminAttributesGroupsController extends AdminAttributesGroupsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminBackupController extends AdminBackupControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCarriersController extends AdminCarriersControllerCore
|
||||
{
|
||||
}
|
||||
@ -108,24 +126,60 @@ class AdminCartRulesController extends AdminCartRulesControllerCore
|
||||
class AdminCartsController extends AdminCartsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCategoriesController extends AdminCategoriesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCmsCategoriesController extends AdminCmsCategoriesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCmsContentController extends AdminCmsContentControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCmsController extends AdminCmsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminContactsController extends AdminContactsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminController extends AdminControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCountriesController extends AdminCountriesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCurrenciesController extends AdminCurrenciesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCustomerPreferencesController extends AdminCustomerPreferencesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCustomersController extends AdminCustomersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminCustomerThreadsController extends AdminCustomerThreadsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminDashboardController extends AdminDashboardControllerCore
|
||||
{
|
||||
}
|
||||
class AdminDeliverySlipController extends AdminDeliverySlipControllerCore
|
||||
{
|
||||
}
|
||||
class AdminEmailsController extends AdminEmailsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminEmployeesController extends AdminEmployeesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminFeaturesController extends AdminFeaturesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminGendersController extends AdminGendersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminGeolocationController extends AdminGeolocationControllerCore
|
||||
{
|
||||
}
|
||||
class AdminGroupsController extends AdminGroupsControllerCore
|
||||
{
|
||||
}
|
||||
@ -135,12 +189,36 @@ class AdminImagesController extends AdminImagesControllerCore
|
||||
class AdminImportController extends AdminImportControllerCore
|
||||
{
|
||||
}
|
||||
class AdminInformationController extends AdminInformationControllerCore
|
||||
{
|
||||
}
|
||||
class AdminInvoicesController extends AdminInvoicesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminLanguagesController extends AdminLanguagesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminLegacyLayoutController extends AdminLegacyLayoutControllerCore
|
||||
{
|
||||
}
|
||||
class AdminLocalizationController extends AdminLocalizationControllerCore
|
||||
{
|
||||
}
|
||||
class AdminLoginController extends AdminLoginControllerCore
|
||||
{
|
||||
}
|
||||
class AdminLogsController extends AdminLogsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminMaintenanceController extends AdminMaintenanceControllerCore
|
||||
{
|
||||
}
|
||||
class AdminManufacturersController extends AdminManufacturersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminMetaController extends AdminMetaControllerCore
|
||||
{
|
||||
}
|
||||
class AdminModulesController extends AdminModulesControllerCore
|
||||
{
|
||||
}
|
||||
@ -150,15 +228,51 @@ class AdminModulesPositionsController extends AdminModulesPositionsControllerCor
|
||||
class AdminNotFoundController extends AdminNotFoundControllerCore
|
||||
{
|
||||
}
|
||||
class AdminOrderMessageController extends AdminOrderMessageControllerCore
|
||||
{
|
||||
}
|
||||
class AdminOrderPreferencesController extends AdminOrderPreferencesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminOrdersController extends AdminOrdersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminOutstandingController extends AdminOutstandingControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPatternsController extends AdminPatternsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPaymentController extends AdminPaymentControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPaymentPreferencesController extends AdminPaymentPreferencesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPdfController extends AdminPdfControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPerformanceController extends AdminPerformanceControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPPreferencesController extends AdminPPreferencesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminPreferencesController extends AdminPreferencesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminProductsController extends AdminProductsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminProfilesController extends AdminProfilesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminQuickAccessesController extends AdminQuickAccessesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminReferrersController extends AdminReferrersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminRequestSqlController extends AdminRequestSqlControllerCore
|
||||
{
|
||||
}
|
||||
@ -171,6 +285,12 @@ class AdminSearchConfController extends AdminSearchConfControllerCore
|
||||
class AdminSearchController extends AdminSearchControllerCore
|
||||
{
|
||||
}
|
||||
class AdminSearchEnginesController extends AdminSearchEnginesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminShippingController extends AdminShippingControllerCore
|
||||
{
|
||||
}
|
||||
class AdminShopController extends AdminShopControllerCore
|
||||
{
|
||||
}
|
||||
@ -180,6 +300,9 @@ class AdminShopGroupController extends AdminShopGroupControllerCore
|
||||
class AdminShopUrlController extends AdminShopUrlControllerCore
|
||||
{
|
||||
}
|
||||
class AdminSlipController extends AdminSlipControllerCore
|
||||
{
|
||||
}
|
||||
class AdminSpecificPriceRuleController extends AdminSpecificPriceRuleControllerCore
|
||||
{
|
||||
}
|
||||
@ -192,24 +315,63 @@ class AdminStatsController extends AdminStatsControllerCore
|
||||
class AdminStatusesController extends AdminStatusesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminStockConfigurationController extends AdminStockConfigurationControllerCore
|
||||
{
|
||||
}
|
||||
class AdminStockCoverController extends AdminStockCoverControllerCore
|
||||
{
|
||||
}
|
||||
class AdminStockInstantStateController extends AdminStockInstantStateControllerCore
|
||||
{
|
||||
}
|
||||
class AdminStockManagementController extends AdminStockManagementControllerCore
|
||||
{
|
||||
}
|
||||
class AdminStockMvtController extends AdminStockMvtControllerCore
|
||||
{
|
||||
}
|
||||
class AdminStoresController extends AdminStoresControllerCore
|
||||
{
|
||||
}
|
||||
class AdminSuppliersController extends AdminSuppliersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminSupplyOrdersController extends AdminSupplyOrdersControllerCore
|
||||
{
|
||||
}
|
||||
class AdminTabsController extends AdminTabsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminTagsController extends AdminTagsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminTaxesController extends AdminTaxesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminTaxRulesGroupController extends AdminTaxRulesGroupControllerCore
|
||||
{
|
||||
}
|
||||
class AdminThemesCatalogController extends AdminThemesCatalogControllerCore
|
||||
{
|
||||
}
|
||||
class AdminThemesController extends AdminThemesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminTrackingController extends AdminTrackingControllerCore
|
||||
{
|
||||
}
|
||||
class AdminTranslationsController extends AdminTranslationsControllerCore
|
||||
{
|
||||
}
|
||||
class AdminWarehousesController extends AdminWarehousesControllerCore
|
||||
{
|
||||
}
|
||||
class AdminWebserviceController extends AdminWebserviceControllerCore
|
||||
{
|
||||
}
|
||||
class AdminZonesController extends AdminZonesControllerCore
|
||||
{
|
||||
}
|
||||
class Alias extends AliasCore
|
||||
{
|
||||
}
|
||||
@ -219,6 +381,9 @@ class Attachment extends AttachmentCore
|
||||
class AttachmentController extends AttachmentControllerCore
|
||||
{
|
||||
}
|
||||
class Attribute extends AttributeCore
|
||||
{
|
||||
}
|
||||
class AttributeGroup extends AttributeGroupCore
|
||||
{
|
||||
}
|
||||
@ -579,6 +744,9 @@ class OrderDetail extends OrderDetailCore
|
||||
class OrderDetailController extends OrderDetailControllerCore
|
||||
{
|
||||
}
|
||||
class OrderDiscount extends OrderDiscountCore
|
||||
{
|
||||
}
|
||||
class OrderFollowController extends OrderFollowControllerCore
|
||||
{
|
||||
}
|
||||
@ -648,6 +816,9 @@ class PhpEncryption extends PhpEncryptionCore
|
||||
class PhpEncryptionEngine extends PhpEncryptionEngineCore
|
||||
{
|
||||
}
|
||||
class PhpEncryptionLegacyEngine extends PhpEncryptionLegacyEngineCore
|
||||
{
|
||||
}
|
||||
class PrestaShopBackup extends PrestaShopBackupCore
|
||||
{
|
||||
}
|
||||
@ -702,6 +873,9 @@ class RangePrice extends RangePriceCore
|
||||
class RangeWeight extends RangeWeightCore
|
||||
{
|
||||
}
|
||||
class Referrer extends ReferrerCore
|
||||
{
|
||||
}
|
||||
class RequestSql extends RequestSqlCore
|
||||
{
|
||||
}
|
||||
@ -891,11 +1065,15 @@ class WebserviceSpecificManagementImages extends WebserviceSpecificManagementIma
|
||||
class WebserviceSpecificManagementSearch extends WebserviceSpecificManagementSearchCore
|
||||
{
|
||||
}
|
||||
class Windows extends WindowsCore
|
||||
{
|
||||
}
|
||||
class Zone extends ZoneCore
|
||||
{
|
||||
}
|
||||
|
||||
/* Class aliases */
|
||||
|
||||
class Autoload extends PrestaShopAutoload
|
||||
{
|
||||
}
|
||||
|
||||
@ -1,76 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Helper to connect to the running bitcoind (by default running regtest).
|
||||
|
||||
# Function to show usage instructions
|
||||
show_usage() {
|
||||
cat <<EOF
|
||||
Usage: bitcoin-cli-helper COMMAND [ARGS]
|
||||
|
||||
Commands:
|
||||
getnewaddress Generate a new address
|
||||
generatetoaddress BLOCKS ADDRESS Generate new blocks and send the reward to the specified address
|
||||
generate NUM_BLOCKS Generate a specified number of blocks
|
||||
settxfee FEE Set the transaction fee for this network
|
||||
sendtoaddress ADDRESS AMOUNT Send funds to an address
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check if a valid command is provided
|
||||
validate_command() {
|
||||
local valid_commands=("getnewaddress" "generatetoaddress" "generate" "settxfee" "sendtoaddress")
|
||||
local command=$1
|
||||
for valid_cmd in "${valid_commands[@]}"; do
|
||||
if [ "$valid_cmd" = "$command" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Validate the number of arguments
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Error: Missing command."
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the provided command is valid
|
||||
if ! validate_command "$1"; then
|
||||
echo "Error: Invalid command."
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute the command with docker
|
||||
if [ "$1" = "generate" ]; then
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Error: Missing number of blocks to generate."
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute it right away, as we must pass `-`
|
||||
docker exec prestashop_bitcoind bitcoin-cli -datadir="/data" -generate "$2"
|
||||
exit 0
|
||||
elif [ "$1" = "generatetoaddress" ]; then
|
||||
if [ "$#" -lt 3 ]; then
|
||||
echo "Error: Missing blocks to mine and/or address."
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$1" = "settxfee" ]; then
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Error: Missing transaction fee value."
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$1" = "sendtoaddress" ]; then
|
||||
if [ "$#" -lt 3 ]; then
|
||||
echo "Error: Missing address and/or amount to send."
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Execute the command with docker
|
||||
docker exec prestashop_bitcoind bitcoin-cli -datadir="/data" "$@"
|
||||
127
docker-compose.yml.dist
Normal file
127
docker-compose.yml.dist
Normal file
@ -0,0 +1,127 @@
|
||||
version: "3"
|
||||
services:
|
||||
btcpayserver:
|
||||
image: btcpayserver/btcpayserver:1.6.12
|
||||
expose:
|
||||
- "49392"
|
||||
environment:
|
||||
BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver
|
||||
BTCPAY_NETWORK: regtest
|
||||
BTCPAY_BIND: 0.0.0.0:49392
|
||||
BTCPAY_ROOTPATH: /
|
||||
BTCPAY_DEBUGLOG: btcpay.log
|
||||
BTCPAY_UPDATEURL: https://api.github.com/repos/btcpayserver/btcpayserver/releases/latest
|
||||
BTCPAY_DOCKERDEPLOYMENT: "true"
|
||||
BTCPAY_CHAINS: "btc"
|
||||
BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/
|
||||
volumes:
|
||||
- "btcpay_datadir:/datadir"
|
||||
- "nbxplorer_datadir:/root/.nbxplorer"
|
||||
- "btcpay_pluginsdir:/root/.btcpayserver/Plugins"
|
||||
ports:
|
||||
- "8888:49392"
|
||||
|
||||
bitcoind:
|
||||
container_name: btcpayserver_bitcoind
|
||||
image: btcpayserver/bitcoin:23.0
|
||||
environment:
|
||||
BITCOIN_NETWORK: regtest
|
||||
BITCOIN_WALLETDIR: "/walletdata"
|
||||
BITCOIN_EXTRA_ARGS: |-
|
||||
rpcport=43782
|
||||
rpcbind=0.0.0.0:43782
|
||||
rpcallowip=0.0.0.0/0
|
||||
port=39388
|
||||
whitelist=0.0.0.0/0
|
||||
maxmempool=500
|
||||
prune=50000
|
||||
expose:
|
||||
- "43782"
|
||||
- "39388"
|
||||
ports:
|
||||
- "18443:43782"
|
||||
volumes:
|
||||
- "bitcoin_datadir:/data"
|
||||
- "bitcoin_wallet_datadir:/walletdata"
|
||||
|
||||
nbxplorer:
|
||||
image: nicolasdorier/nbxplorer:2.3.39
|
||||
expose:
|
||||
- "32838"
|
||||
environment:
|
||||
NBXPLORER_NETWORK: regtest
|
||||
NBXPLORER_BIND: 0.0.0.0:32838
|
||||
NBXPLORER_TRIMEVENTS: 10000
|
||||
NBXPLORER_SIGNALFILESDIR: /datadir
|
||||
NBXPLORER_CHAINS: "btc"
|
||||
NBXPLORER_POSTGRES: User ID=postgres;Include Error Detail=true;Host=postgres;Port=5432
|
||||
NBXPLORER_BTCRPCURL: http://bitcoind:43782/
|
||||
NBXPLORER_BTCNODEENDPOINT: bitcoind:39388
|
||||
volumes:
|
||||
- "nbxplorer_datadir:/datadir"
|
||||
- "bitcoin_datadir:/root/.bitcoin"
|
||||
depends_on:
|
||||
- postgres
|
||||
|
||||
postgres:
|
||||
image: btcpayserver/postgres:13.7
|
||||
environment:
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
volumes:
|
||||
- "postgres_datadir:/var/lib/postgresql/data"
|
||||
|
||||
mariadb:
|
||||
image: bitnami/mariadb:10.7
|
||||
environment:
|
||||
- ALLOW_EMPTY_PASSWORD=yes
|
||||
- MARIADB_SKIP_TEST_DB=yes
|
||||
- MARIADB_USER=prestashop
|
||||
- MARIADB_PASSWORD=bitnami
|
||||
- MARIADB_DATABASE=prestashop
|
||||
volumes:
|
||||
- "mariadb_data:/bitnami/mariadb"
|
||||
ports:
|
||||
- "3305:3306"
|
||||
|
||||
prestashop:
|
||||
image: bitnami/prestashop:1.7
|
||||
ports:
|
||||
- "80:8080"
|
||||
- "443:8443"
|
||||
environment:
|
||||
- PRESTASHOP_HOST=127.0.0.1
|
||||
- PRESTASHOP_DATABASE_HOST=mariadb
|
||||
- PRESTASHOP_DATABASE_PORT_NUMBER=3306
|
||||
- PRESTASHOP_DATABASE_USER=prestashop
|
||||
- PRESTASHOP_DATABASE_PASSWORD=bitnami
|
||||
- PRESTASHOP_DATABASE_NAME=prestashop
|
||||
- PRESTASHOP_EMAIL=user@example.com
|
||||
- PRESTASHOP_PASSWORD=bitnami1
|
||||
volumes:
|
||||
- "prestashop_data:/bitnami/prestashop"
|
||||
depends_on:
|
||||
- mariadb
|
||||
- btcpayserver
|
||||
links:
|
||||
- mariadb
|
||||
- btcpayserver
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog:latest
|
||||
logging:
|
||||
driver: "none"
|
||||
ports:
|
||||
- "1025:1025"
|
||||
- "8025:8025"
|
||||
|
||||
volumes:
|
||||
btcpay_datadir:
|
||||
btcpay_pluginsdir:
|
||||
bitcoin_datadir:
|
||||
bitcoin_wallet_datadir:
|
||||
postgres_datadir:
|
||||
nbxplorer_datadir:
|
||||
mariadb_data:
|
||||
driver: local
|
||||
prestashop_data:
|
||||
driver: local
|
||||
@ -1,14 +0,0 @@
|
||||
# Apache 2.2
|
||||
<IfModule !mod_authz_core.c>
|
||||
<Files *.php>
|
||||
order allow,deny
|
||||
deny from all
|
||||
</Files>
|
||||
</IfModule>
|
||||
|
||||
# Apache 2.4
|
||||
<IfModule mod_authz_core.c>
|
||||
<Files *.php>
|
||||
Require all denied
|
||||
</Files>
|
||||
</IfModule>
|
||||
@ -7,13 +7,14 @@ use BTCPay\Installer\Hooks;
|
||||
use BTCPay\Installer\OrderStates;
|
||||
use BTCPay\Installer\Tables;
|
||||
use BTCPay\Installer\Webhook;
|
||||
use BTCPay\LegacyBitcoinPaymentRepository;
|
||||
use BTCPay\Repository\BitcoinPaymentRepository;
|
||||
use BTCPay\Repository\TableRepository;
|
||||
use BTCPay\Server\Client;
|
||||
use BTCPayServer\Exception\BTCPayException;
|
||||
use BTCPayServer\Exception\RequestException;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
use PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderPresenter;
|
||||
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
|
||||
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
@ -38,6 +39,16 @@ class BTCPay extends PaymentModule
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var BitcoinPaymentRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
@ -52,28 +63,27 @@ class BTCPay extends PaymentModule
|
||||
{
|
||||
$this->name = 'btcpay';
|
||||
$this->tab = 'payments_gateways';
|
||||
$this->version = '6.3.1';
|
||||
$this->version = '5.2.1';
|
||||
$this->author = 'BTCPay Server';
|
||||
$this->ps_versions_compliancy = ['min' => Constants::MINIMUM_PS_VERSION, 'max' => _PS_VERSION_];
|
||||
$this->controllers = ['payment', 'validation', 'webhook'];
|
||||
$this->is_eu_compatible = true;
|
||||
$this->bootstrap = true;
|
||||
$this->module_key = 'aec3ab8084e8e626bdcbda75d2ab39ee';
|
||||
|
||||
$this->currencies = true;
|
||||
$this->currencies_mode = 'radio';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->trans('BTCPay Server', [], 'Modules.Btcpay.Admin');
|
||||
$this->description = $this->trans('Accept crypto payments via BTCPay Server.', [], 'Modules.Btcpay.Front');
|
||||
$this->displayName = $this->trans('BTCPay Server', [], 'Modules.Btcpay.Admin');
|
||||
$this->description = $this->trans('Accept crypto payments via BTCPay Server.', [], 'Modules.Btcpay.Front');
|
||||
$this->confirmUninstall = $this->trans('Are you sure that you want to uninstall this module? Past purchases and order states will be kept, but your configuration will be removed.', [], 'Modules.Btcpay.Front');
|
||||
|
||||
$this->configuration = new Configuration();
|
||||
$this->versioning = new Versioning();
|
||||
$this->versioning = new Versioning();
|
||||
|
||||
// Process any and all alerts/warnings
|
||||
$this->displayModuleWarnings();
|
||||
// Process any and all warnings
|
||||
$this->warnings();
|
||||
}
|
||||
|
||||
public function install(): bool
|
||||
@ -118,8 +128,12 @@ class BTCPay extends PaymentModule
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create required tables
|
||||
$repository = new TableRepository($this->get('doctrine.dbal.default_connection'));
|
||||
if (null === ($repository = $this->getRepository())) {
|
||||
$this->addModuleErrors(['Expected a BitcoinPaymentRepository repository, but received NULL']);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($errors = (new Tables($repository))->install())) {
|
||||
$this->addModuleErrors($errors);
|
||||
$this->uninstall();
|
||||
@ -209,13 +223,11 @@ class BTCPay extends PaymentModule
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ensure the client is ready for use
|
||||
if (null === ($client = Client::createFromConfiguration($this->configuration)) || false === $client->isValid()) {
|
||||
return null;
|
||||
}
|
||||
// Get legacy repository
|
||||
$repository = new LegacyBitcoinPaymentRepository();
|
||||
|
||||
// Get the order
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByOrderID($params['id_order']))) {
|
||||
if (null === ($bitcoinPayment = $repository->getOneByOrderID($params['id_order']))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -240,12 +252,8 @@ class BTCPay extends PaymentModule
|
||||
|
||||
try {
|
||||
// Get the invoice and its payments
|
||||
$invoice = $client->invoice()->getInvoice($storeID, $invoiceId);
|
||||
|
||||
// Filter out methods without payments
|
||||
$paymentMethods = array_filter($client->invoice()->getPaymentMethods($storeID, $invoiceId), static function ($method) {
|
||||
return !empty($method->getPayments());
|
||||
});
|
||||
$invoice = $this->client()->invoice()->getInvoice($storeID, $invoiceId);
|
||||
$paymentMethods = $this->client()->invoice()->getPaymentMethods($storeID, $invoiceId);
|
||||
|
||||
// Has any payment been received
|
||||
$paymentReceived = array_reduce($paymentMethods, static function ($carry, $method) {
|
||||
@ -262,7 +270,7 @@ class BTCPay extends PaymentModule
|
||||
return $this->display(__FILE__, 'views/templates/admin/invoice_block.tpl');
|
||||
} catch (RequestException $exception) {
|
||||
// Log the exception
|
||||
PrestaShopLogger::addLog(\sprintf('[WARNING] Tried to load BTCPay Server invoice in hookDisplayAdminOrderMainBottom: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $exception->getCode(), 'Order', $bitcoinPayment->getOrderId());
|
||||
PrestaShopLogger::addLog(\sprintf('[WARNING] Tried to load BTCPay invoice in hookDisplayAdminOrderMainBottom: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $exception->getCode(), 'Order', $bitcoinPayment->getOrderId());
|
||||
|
||||
// Show that the invoice was not found
|
||||
return $this->display(__FILE__, 'views/templates/admin/invoice_missing_block.tpl');
|
||||
@ -287,35 +295,28 @@ class BTCPay extends PaymentModule
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get BTCPay URL or abort
|
||||
if (empty($serverUrl = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if we actually have an order
|
||||
$order = $params['order'];
|
||||
if (!$order instanceof Order) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If created by another module, return
|
||||
if ($order->module !== $this->name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we actually have an cart
|
||||
// Check if we actually have an order
|
||||
$cart = $params['cart'];
|
||||
if (!$cart instanceof Cart) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get BTCPay URL or abort
|
||||
if (empty($serverUrl = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ensure the client is ready for use
|
||||
if (null === ($client = Client::createFromConfiguration($this->configuration)) || false === $client->isValid()) {
|
||||
return null;
|
||||
}
|
||||
// Get legacy repository
|
||||
$repository = new LegacyBitcoinPaymentRepository();
|
||||
|
||||
// Get the order
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByOrderID($order->id))) {
|
||||
if (null === ($bitcoinPayment = $repository->getOneByOrderID($order->id))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -332,20 +333,34 @@ class BTCPay extends PaymentModule
|
||||
$this->context->smarty->assign([
|
||||
'serverURL' => $serverUrl,
|
||||
'storeCurrency' => Currency::getCurrencyInstance($cart->id_currency)->getSymbol(),
|
||||
'invoice' => $client->invoice()->getInvoice($storeID, $invoiceId),
|
||||
'paymentMethods' => $client->invoice()->getPaymentMethods($storeID, $invoiceId),
|
||||
'invoice' => $this->client()->invoice()->getInvoice($storeID, $invoiceId),
|
||||
'paymentMethods' => $this->client()->invoice()->getPaymentMethods($storeID, $invoiceId),
|
||||
]);
|
||||
|
||||
return $this->display(__FILE__, 'views/templates/hooks/order_detail.tpl');
|
||||
} catch (RequestException $exception) {
|
||||
// Log the exception
|
||||
PrestaShopLogger::addLog(\sprintf('[WARNING] Tried to load BTCPay Server invoice in hookDisplayOrderDetail: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $exception->getCode(), 'Order', $order->id);
|
||||
PrestaShopLogger::addLog(\sprintf('[WARNING] Tried to load BTCPay invoice in hookDisplayOrderDetail: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $exception->getCode(), 'Order', $order->id);
|
||||
|
||||
// If the invoice is gone just return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function hookDisplayPaymentEU(): array
|
||||
{
|
||||
// If the module is not active, abort
|
||||
if (!$this->active) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'cta_text' => $this->name,
|
||||
'logo' => Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/images/bitcoin.png'),
|
||||
'action' => $this->context->link->getModuleLink($this->name, 'payment', [], true),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks on prestashop payment returns
|
||||
*
|
||||
@ -370,7 +385,7 @@ class BTCPay extends PaymentModule
|
||||
}
|
||||
|
||||
// Get the order
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByOrderID($order->id))) {
|
||||
if (null === ($bitcoinPayment = (new LegacyBitcoinPaymentRepository())->getOneByOrderID($order->id))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -401,8 +416,8 @@ class BTCPay extends PaymentModule
|
||||
return [];
|
||||
}
|
||||
|
||||
// Ensure the client is ready for use
|
||||
if (null === ($client = Client::createFromConfiguration($this->configuration)) || false === $client->isValid()) {
|
||||
// If the API key is not valid, this module is not ready to be used
|
||||
if (false === $this->client()->isValid()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -411,10 +426,16 @@ class BTCPay extends PaymentModule
|
||||
|
||||
try {
|
||||
// If the server is not fully synced, do not show the option
|
||||
if (!$client->server()->getInfo()->isFullySynced()) {
|
||||
if (!$this->client()->server()->getInfo()->isFullySynced()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Prepare smarty
|
||||
$this->context->smarty->assign([
|
||||
'onChain' => $this->client()->onChain()->getPaymentMethods($storeID),
|
||||
'offChain' => $this->client()->offChain()->getPaymentMethods($storeID),
|
||||
]);
|
||||
|
||||
return [
|
||||
(new PaymentOption())
|
||||
->setModuleName($this->name)
|
||||
@ -461,7 +482,7 @@ class BTCPay extends PaymentModule
|
||||
}
|
||||
|
||||
// Get the order
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByCartID($cart->id))) {
|
||||
if (null === ($bitcoinPayment = (new LegacyBitcoinPaymentRepository())->getOneByCartID($cart->id))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -483,47 +504,47 @@ class BTCPay extends PaymentModule
|
||||
}
|
||||
}
|
||||
|
||||
private function displayModuleWarnings(): void
|
||||
private function client(): Client
|
||||
{
|
||||
// Try and create the client
|
||||
$client = Client::createFromConfiguration($this->configuration);
|
||||
if (null === $this->client) {
|
||||
$this->client = Client::createFromConfiguration($this->configuration);
|
||||
}
|
||||
|
||||
try {
|
||||
// Show warning if API key is missing or if we're not yet fully synced
|
||||
if (null === $client || empty($this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY))) {
|
||||
$this->warning = $this->trans('Your BTCPay Server store has not yet been linked, payment option is unavailable.', [], 'Modules.Btcpay.Admin');
|
||||
} elseif (!$client->server()->getInfo()->isFullySynced()) {
|
||||
$this->warning = $this->trans('One (or more) coins are not yet synced, payment option will be unavailable until the sync has finished.', [], 'Modules.Btcpay.Admin');
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
private function getRepository(): ?BitcoinPaymentRepository
|
||||
{
|
||||
if (null === $this->repository) {
|
||||
try {
|
||||
$this->repository = $this->get('prestashop.module.btcpay.repository');
|
||||
} catch (Throwable $e) {
|
||||
if (null !== ($container = SymfonyContainer::getInstance())) {
|
||||
$this->repository = new BitcoinPaymentRepository($container->get('doctrine.dbal.default_connection'), $container->getParameter('database_prefix'));
|
||||
}
|
||||
}
|
||||
} catch (BTCPayException $exception) {
|
||||
// Log the exception
|
||||
PrestaShopLogger::addLog(\sprintf('[WARNING] BTCPay Server configuration is no longer valid, resetting host and API key. Error: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $exception->getCode());
|
||||
|
||||
// Show a warning
|
||||
$this->warning = $this->trans('Your BTCPay Server configuration is no longer valid, please setup module again.', [], 'Modules.Btcpay.Admin');
|
||||
|
||||
// Reset configuration
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_HOST, Constants::CONFIGURATION_DEFAULT_HOST);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
// Bail
|
||||
return;
|
||||
} catch (\Throwable $exception) {
|
||||
// Log the exception
|
||||
PrestaShopLogger::addLog(\sprintf('[WARNING] Could not parse server information: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $exception->getCode());
|
||||
|
||||
// Bail
|
||||
return;
|
||||
}
|
||||
|
||||
// API key/sync warnings are more important than a new version, if a warning is set, return now
|
||||
if (!empty($this->warning)) {
|
||||
return;
|
||||
return $this->repository;
|
||||
}
|
||||
|
||||
private function warnings(): void
|
||||
{
|
||||
$warnings = [];
|
||||
|
||||
// Show alert if API key is missing
|
||||
if (empty($this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY))) {
|
||||
$warnings[] = $this->trans('No API key has been set yet', [], 'Modules.Btcpay.Admin');
|
||||
}
|
||||
|
||||
// Otherwise, add a warning on version upgrade
|
||||
// Show alert for version upgrade
|
||||
if (null !== ($latest = $this->versioning->latest()) && $latest->newer($this->version)) {
|
||||
$this->warning = $this->trans(\sprintf('There is a new version available for this plugin: %s.', $latest->getTagName()), [], 'Modules.Btcpay.Admin');
|
||||
$warnings[] = $this->trans(\sprintf('There is a new version available for %s (%s).', $this->displayName, $latest->getTagName()), [], 'Modules.Btcpay.Admin');
|
||||
}
|
||||
|
||||
$this->warning = \implode(' - ', $warnings);
|
||||
foreach ($warnings as $warning) {
|
||||
$this->adminDisplayWarning($warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,34 +17,31 @@
|
||||
"source": "https://github.com/btcpayserver/prestashop-plugin"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"php": ">=7.3.0",
|
||||
"ext-PDO": "*",
|
||||
"ext-bcmath": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-intl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"btcpayserver/btcpayserver-greenfield-php": "^2.8.1",
|
||||
"composer/semver": "^3.4.2",
|
||||
"stechstudio/backoff": "^1.4"
|
||||
"btcpayserver/btcpayserver-greenfield-php": "^1.3.6",
|
||||
"composer/semver": "^3.3",
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"http-interop/http-factory-guzzle": "^1.2",
|
||||
"knplabs/github-api": "^3.8",
|
||||
"stechstudio/backoff": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"ergebnis/composer-normalize": "^2.43",
|
||||
"ergebnis/composer-normalize": "^2.20",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"symfony/debug-bundle": "~5.4.40",
|
||||
"symfony/var-dumper": "~5.4.43"
|
||||
"symfony/debug-bundle": "^4.4.37",
|
||||
"symfony/var-dumper": "^4.4.47"
|
||||
},
|
||||
"replace": {
|
||||
"symfony/polyfill-mbstring": "*",
|
||||
"symfony/polyfill-php54": "*",
|
||||
"symfony/polyfill-php55": "^1.10",
|
||||
"symfony/polyfill-php56": "*",
|
||||
"symfony/polyfill-php70": "*",
|
||||
"symfony/polyfill-php71": "*",
|
||||
"symfony/polyfill-php72": "*",
|
||||
"symfony/polyfill-php73": "*",
|
||||
"symfony/polyfill-php74": "*"
|
||||
"symfony/polyfill-php73": "*"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"autoload": {
|
||||
@ -58,11 +55,10 @@
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"ergebnis/composer-normalize": true,
|
||||
"php-http/discovery": true
|
||||
"ergebnis/composer-normalize": true
|
||||
},
|
||||
"platform": {
|
||||
"php": "8.0"
|
||||
"php": "7.3"
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"prepend-autoloader": false,
|
||||
|
||||
3229
modules/btcpay/composer.lock
generated
3229
modules/btcpay/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>btcpay</name>
|
||||
<displayName><![CDATA[BTCPay Server]]></displayName>
|
||||
<version><![CDATA[6.1.0]]></version>
|
||||
<description><![CDATA[Accept crypto payments via BTCPay Server.]]></description>
|
||||
<author><![CDATA[BTCPay Server]]></author>
|
||||
<tab><![CDATA[payments_gateways]]></tab>
|
||||
<confirmUninstall><![CDATA[Are you sure that you want to uninstall this module? Past purchases and order states will be kept, but your configuration will be removed.]]></confirmUninstall>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
<name>btcpay</name>
|
||||
<displayName><![CDATA[BTCPay]]></displayName>
|
||||
<version><![CDATA[5.2.0]]></version>
|
||||
<description><![CDATA[Accept crypto payments via BTCPay Server.]]></description>
|
||||
<author><![CDATA[BTCPayServer]]></author>
|
||||
<tab><![CDATA[payments_gateways]]></tab>
|
||||
<confirmUninstall><![CDATA[Are you sure that you want to uninstall this module? Past purchases and order states will be kept, but your configuration will be removed.]]></confirmUninstall>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
<limited_countries/>
|
||||
</module>
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -2,24 +2,16 @@ admin_btcpay_configure:
|
||||
path: /btcpay/configure
|
||||
methods: [GET]
|
||||
defaults:
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::viewAction'
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::editAction'
|
||||
_legacy_controller: AdminConfigureBTCPay
|
||||
_legacy_link: AdminConfigureBTCPay
|
||||
_disable_module_prefix: true
|
||||
|
||||
admin_btcpay_configure_server_process:
|
||||
admin_btcpay_configure_process:
|
||||
path: /btcpay/configure
|
||||
methods: [GET, POST]
|
||||
defaults:
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::editServerSettingsAction'
|
||||
_legacy_controller: AdminConfigureBTCPay
|
||||
_disable_module_prefix: true
|
||||
|
||||
admin_btcpay_configure_general_process:
|
||||
path: /btcpay/configure/general
|
||||
methods: [GET, POST]
|
||||
defaults:
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::editGeneralSettingsAction'
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::editProcessAction'
|
||||
_legacy_controller: AdminConfigureBTCPay
|
||||
_disable_module_prefix: true
|
||||
|
||||
@ -27,6 +19,7 @@ admin_btcpay_validate:
|
||||
path: /btcpay/api-key/validate
|
||||
methods: [GET, POST]
|
||||
defaults:
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::validateAPIKeyAction'
|
||||
_controller: 'BTCPay\Controller\Admin\Improve\Payment\ConfigureController::validateAction'
|
||||
_legacy_controller: AdminConfigureBTCPay
|
||||
_disable_module_prefix: true
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ services:
|
||||
class: BTCPay
|
||||
|
||||
# Repositories
|
||||
prestashop.module.btcpay.repository.install:
|
||||
class: BTCPay\Repository\TableRepository
|
||||
prestashop.module.btcpay.repository:
|
||||
class: BTCPay\Repository\BitcoinPaymentRepository
|
||||
arguments:
|
||||
- '@doctrine.dbal.default_connection'
|
||||
- '%database_prefix%'
|
||||
@ -19,46 +19,27 @@ services:
|
||||
arguments:
|
||||
- '@prestashop.module.btcpay'
|
||||
- '@validator'
|
||||
- '@prestashop.module.btcpay.form_handler.server'
|
||||
- '@prestashop.module.btcpay.form_handler.general'
|
||||
- '@prestashop.module.btcpay.form_handler'
|
||||
|
||||
# Form data provider
|
||||
prestashop.module.btcpay.form.server.provider:
|
||||
class: BTCPay\Form\ServerFormDataProvider
|
||||
prestashop.module.btcpay.form.general.provider:
|
||||
class: BTCPay\Form\GeneralFormDataProvider
|
||||
prestashop.module.btcpay.form.configure.provider:
|
||||
class: BTCPay\Form\ConfigureFormDataProvider
|
||||
|
||||
# Form type
|
||||
prestashop.module.btcpay.form.type.server:
|
||||
class: BTCPay\Form\Type\ServerType
|
||||
prestashop.module.btcpay.form.type.configure:
|
||||
class: BTCPay\Form\Type\ConfigureType
|
||||
parent: 'form.type.translatable.aware'
|
||||
public: true
|
||||
tags: [{ name: form.type }]
|
||||
|
||||
prestashop.module.btcpay.form.type.general:
|
||||
class: BTCPay\Form\Type\GeneralType
|
||||
parent: 'form.type.translatable.aware'
|
||||
public: true
|
||||
tags: [{ name: form.type }]
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
# Form handler
|
||||
prestashop.module.btcpay.form_handler.server:
|
||||
class: PrestaShop\PrestaShop\Core\Form\Handler
|
||||
prestashop.module.btcpay.form_handler:
|
||||
class: PrestaShop\PrestaShop\Core\Form\FormHandler
|
||||
arguments:
|
||||
$formFactory: '@Symfony\Component\Form\FormFactoryInterface'
|
||||
$formBuilder: '@=service("form.factory").createBuilder()'
|
||||
$hookDispatcher: '@prestashop.core.hook.dispatcher'
|
||||
$formDataProvider: '@prestashop.module.btcpay.form.server.provider'
|
||||
$form: 'BTCPay\Form\Type\ServerType'
|
||||
$hookName: 'ServerType'
|
||||
$formName: 'server-form'
|
||||
|
||||
# Form handler
|
||||
prestashop.module.btcpay.form_handler.general:
|
||||
class: PrestaShop\PrestaShop\Core\Form\Handler
|
||||
arguments:
|
||||
$formFactory: '@Symfony\Component\Form\FormFactoryInterface'
|
||||
$hookDispatcher: '@prestashop.core.hook.dispatcher'
|
||||
$formDataProvider: '@prestashop.module.btcpay.form.general.provider'
|
||||
$form: 'BTCPay\Form\Type\GeneralType'
|
||||
$hookName: 'GeneralType'
|
||||
$formName: 'general-form'
|
||||
$formDataProvider: '@prestashop.module.btcpay.form.configure.provider'
|
||||
$formTypes:
|
||||
'btcpay': 'BTCPay\Form\Type\ConfigureType'
|
||||
$hookName: 'AdminConfigureBTCPay'
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class AdminConfigureBTCPayController extends ModuleAdminController
|
||||
{
|
||||
/**
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -2,11 +2,6 @@
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Server\Factory;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class BTCPayPaymentModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
@ -53,16 +48,14 @@ class BTCPayPaymentModuleFrontController extends ModuleFrontController
|
||||
|
||||
try {
|
||||
if (null !== ($redirect = $this->factory->createPaymentRequest($this->context->customer, $this->context->cart))) {
|
||||
Tools::redirect($redirect);
|
||||
Tools::redirectLink($redirect);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->warning[] = $this->context->getTranslator()->trans('We could not create a payment request via BTCPay Server. Please try again or contact us.', [], 'Modules.Btcpay.Front');
|
||||
$this->redirectWithNotifications($this->context->link->getPageLink('cart', $this->ssl));
|
||||
} catch (\Throwable $throwable) {
|
||||
PrestaShopLogger::addLog(\sprintf('[ERROR] An error occurred during payment creation: %s', $throwable), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, $throwable->getCode());
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$this->warning[] = $this->context->getTranslator()->trans('We are having issues with our BTCPay Server backend. Please try again or contact us.', [], 'Modules.Btcpay.Front');
|
||||
$this->redirectWithNotifications($this->context->link->getPageLink('cart', $this->ssl));
|
||||
}
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
<?php
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Invoice\Processor;
|
||||
use BTCPay\Repository\BitcoinPaymentRepository;
|
||||
use BTCPay\LegacyBitcoinPaymentRepository;
|
||||
use BTCPay\Server\Client;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class BTCPayValidationModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
@ -29,11 +24,29 @@ class BTCPayValidationModuleFrontController extends ModuleFrontController
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var LegacyBitcoinPaymentRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \BTCPay\Invoice\Processor
|
||||
*/
|
||||
private $processor;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->configuration = new Configuration();
|
||||
$this->client = Client::createFromConfiguration($this->configuration);
|
||||
$this->repository = new LegacyBitcoinPaymentRepository();
|
||||
$this->processor = new \BTCPay\Invoice\Processor($this->module, $this->configuration, $this->client);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +66,7 @@ class BTCPayValidationModuleFrontController extends ModuleFrontController
|
||||
|
||||
// Get the translator so we can translate our errors
|
||||
if (null === ($translator = $this->getTranslator())) {
|
||||
throw new RuntimeException('Expected the translator to be available');
|
||||
throw new \RuntimeException('Expected the translator to be available');
|
||||
}
|
||||
|
||||
// Check if our payment option is still valid
|
||||
@ -76,7 +89,7 @@ class BTCPayValidationModuleFrontController extends ModuleFrontController
|
||||
|
||||
// Get the passed invoice reference, which we can then use to get the actual order
|
||||
$invoiceReference = Tools::getValue('invoice_reference', 0);
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByInvoiceReference($invoiceReference))) {
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByInvoiceReference($invoiceReference))) {
|
||||
$this->warning[] = $translator->trans('The passed invoice reference is not valid.', [], 'Modules.Btcpay.Front');
|
||||
$this->redirectWithNotifications($this->context->link->getPageLink('cart', $this->ssl));
|
||||
|
||||
@ -97,14 +110,8 @@ class BTCPayValidationModuleFrontController extends ModuleFrontController
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the client is ready for use
|
||||
if (null === ($client = Client::createFromConfiguration($this->configuration)) || false === $client->isValid()) {
|
||||
throw new RuntimeException('Expected the client to be available');
|
||||
}
|
||||
|
||||
// User was quicker than the callback, so we deal with the actual invoice now
|
||||
$processor = new Processor($this->module, $this->context, $this->configuration, $client);
|
||||
$processor->paymentReceivedCreateAfter($bitcoinPayment);
|
||||
// User was quicker than the callback, deal with the actual invoice now
|
||||
$this->processor->paymentReceivedCreateAfter($bitcoinPayment);
|
||||
|
||||
// Grab the (now existing) order
|
||||
$order = Order::getByCartId($bitcoinPayment->getCartId());
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
<?php
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\LegacyBitcoinPaymentRepository;
|
||||
use BTCPay\Server\Client;
|
||||
use BTCPay\Server\WebhookHandler;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class BTCPayWebhookModuleFrontController extends \ModuleFrontController
|
||||
{
|
||||
/**
|
||||
@ -30,7 +27,7 @@ class BTCPayWebhookModuleFrontController extends \ModuleFrontController
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var Client|null
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
@ -45,7 +42,7 @@ class BTCPayWebhookModuleFrontController extends \ModuleFrontController
|
||||
|
||||
$this->configuration = new Configuration();
|
||||
$this->client = Client::createFromConfiguration($this->configuration);
|
||||
$this->handler = new WebhookHandler($this->module, $this->context, $this->client);
|
||||
$this->handler = new WebhookHandler($this->module, $this->client, new LegacyBitcoinPaymentRepository());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,15 +71,10 @@ class BTCPayWebhookModuleFrontController extends \ModuleFrontController
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the client is ready for use, if not, just return
|
||||
if (null === $this->client || false === $this->client->isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure our webhook is actually valid
|
||||
if (false === $this->client->webhook()->isIncomingWebhookRequestValid($request->getContent(), $signature, $secret)) {
|
||||
$error = 'Invalid BTCPay Server payment notification message received - signature did not match.';
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
\PrestaShopLogger::addLog($error, 3);
|
||||
|
||||
throw new \Exception($error);
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,24 +4,17 @@ namespace BTCPay;
|
||||
|
||||
use BTCPayServer\Client\InvoiceCheckoutOptions;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Constants
|
||||
{
|
||||
// Version information
|
||||
public const MINIMUM_BTCPAY_VERSION = '1.7.0';
|
||||
public const MINIMUM_PS_VERSION = '8.0.0';
|
||||
public const MINIMUM_PHP_VERSION = '8.0.0';
|
||||
public const MINIMUM_BTCPAY_VERSION = '1.3.0';
|
||||
public const MINIMUM_PS_VERSION = '1.7.8';
|
||||
public const MINIMUM_PHP_VERSION = '7.3.0';
|
||||
|
||||
// Cache configuration
|
||||
public const LASTEST_VERSION_CACHE_KEY = 'BTCPAY_LATEST_VERSION';
|
||||
public const LASTEST_VERSION_CACHE_EXPIRATION = 60 * 60 * 24 * 7; // 7 days
|
||||
|
||||
// GitHub API endpoint for releases
|
||||
public const GITHUB_API_LATEST_ENDPOINT = 'https://api.github.com/repos/btcpayserver/prestashop-plugin/releases/latest';
|
||||
|
||||
// BTCPay Server webhook header
|
||||
public const BTCPAY_HEADER_SIG = 'Btcpay-Sig';
|
||||
|
||||
@ -54,9 +47,6 @@ class Constants
|
||||
public const CONFIGURATION_ORDER_STATE_FAILED = 'BTCPAY_OS_FAILED';
|
||||
public const CONFIGURATION_ORDER_STATE_PAID = 'BTCPAY_OS_PAID';
|
||||
|
||||
// Do we want to protect order states from getting changed by webhook
|
||||
public const CONFIGURATION_PROTECT_ORDERS = 'BTCPAY_PROTECT_ORDERS';
|
||||
|
||||
// Do we want to share personal details with BTCPay Server
|
||||
public const CONFIGURATION_SHARE_METADATA = 'BTCPAY_SHARE_METADATA';
|
||||
|
||||
|
||||
@ -2,33 +2,21 @@
|
||||
|
||||
namespace BTCPay\Controller\Admin\Improve\Payment;
|
||||
|
||||
use BTCPay;
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Form\Data\General;
|
||||
use BTCPay\Form\Data\Server;
|
||||
use BTCPay\Form\Data\Configuration;
|
||||
use BTCPay\Github\Versioning;
|
||||
use BTCPay\Server\Client;
|
||||
use BTCPay\Server\Data\ValidateApiKey;
|
||||
use BTCPayServer\Client\ApiKey;
|
||||
use Exception;
|
||||
use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface;
|
||||
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
|
||||
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
|
||||
use PrestaShopBundle\Security\Annotation\AdminSecurity;
|
||||
use PrestaShopBundle\Security\Annotation\ModuleActivated;
|
||||
use PrestaShopLogger;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Throwable;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ModuleActivated(moduleName="btcpay", redirectRoute="admin_module_manage")
|
||||
@ -36,7 +24,7 @@ if (!\defined('_PS_VERSION_')) {
|
||||
class ConfigureController extends FrameworkBundleAdminController
|
||||
{
|
||||
/**
|
||||
* @var BTCPay
|
||||
* @var \BTCPay
|
||||
*/
|
||||
private $module;
|
||||
|
||||
@ -48,51 +36,62 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
/**
|
||||
* @var FormHandlerInterface
|
||||
*/
|
||||
private $serverFormHandler;
|
||||
|
||||
/**
|
||||
* @var FormHandlerInterface
|
||||
*/
|
||||
private $generalFormHandler;
|
||||
private $formHandler;
|
||||
|
||||
/**
|
||||
* @var Versioning
|
||||
*/
|
||||
private $versioning;
|
||||
|
||||
public function __construct(BTCPay $module, ValidatorInterface $validator, FormHandlerInterface $serverFormHandler, FormHandlerInterface $generalFormHandler)
|
||||
public function __construct(\BTCPay $module, ValidatorInterface $validator, FormHandlerInterface $formHandler)
|
||||
{
|
||||
// Fallback in case 8.0 is used // TODO: Remove once we make 9.0 the minimum
|
||||
if (\version_compare(\_PS_VERSION_, '8.1.0', '<')) {
|
||||
parent::__construct();
|
||||
}
|
||||
parent::__construct();
|
||||
|
||||
$this->module = $module;
|
||||
$this->validator = $validator;
|
||||
$this->serverFormHandler = $serverFormHandler;
|
||||
$this->generalFormHandler = $generalFormHandler;
|
||||
$this->versioning = new Versioning();
|
||||
$this->module = $module;
|
||||
$this->validator = $validator;
|
||||
$this->formHandler = $formHandler;
|
||||
$this->versioning = new Versioning();
|
||||
}
|
||||
|
||||
/**
|
||||
* @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.")
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function viewAction(Request $request): Response
|
||||
public function editAction(Request $request): Response
|
||||
{
|
||||
// Build the client
|
||||
$client = Client::createFromConfiguration($this->getConfiguration());
|
||||
$client = Client::createFromConfiguration($this->configuration);
|
||||
|
||||
// Create the authorization URL (without redirect)
|
||||
$authorizeUrl = ApiKey::getAuthorizeUrl($this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_HOST), Constants::BTCPAY_PERMISSIONS, $this->module->name, true, true, null, $this->module->name);
|
||||
$authorizeUrl = ApiKey::getAuthorizeUrl($this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST), Constants::BTCPAY_PERMISSIONS, $this->module->name, true, true, null, $this->module->name);
|
||||
|
||||
// Ensure we always have a webhook
|
||||
if (null !== $client && $client->isValid()) {
|
||||
$client->webhook()->ensureWebhook($this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_STORE_ID));
|
||||
if (false === $client->isValid()) {
|
||||
return $this->render('@Modules/btcpay/views/templates/admin/configure.html.twig', [
|
||||
'form' => $this->get('prestashop.module.btcpay.form_handler')->getForm()->createView(),
|
||||
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
|
||||
'latestVersion' => $this->versioning->latest(),
|
||||
'moduleVersion' => $this->module->version,
|
||||
'authorizeUrl' => $authorizeUrl,
|
||||
'invalidApiKey' => true,
|
||||
'enableSidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->getResponse($request, $this->serverFormHandler->getForm(), $this->generalFormHandler->getForm(), $authorizeUrl, $client);
|
||||
// Ensure we always have a webhook
|
||||
$client->webhook()->ensureWebhook($this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID));
|
||||
|
||||
return $this->render('@Modules/btcpay/views/templates/admin/configure.html.twig', [
|
||||
'form' => $this->get('prestashop.module.btcpay.form_handler')->getForm()->createView(),
|
||||
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
|
||||
'storeId' => $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID),
|
||||
'webhookId' => $this->configuration->get(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID),
|
||||
'latestVersion' => $this->versioning->latest(),
|
||||
'moduleVersion' => $this->module->version,
|
||||
'authorizeUrl' => $authorizeUrl,
|
||||
'client' => $client,
|
||||
'enableSidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,58 +99,60 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
*
|
||||
* @return RedirectResponse|Response
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function editServerSettingsAction(Request $request): Response
|
||||
public function editProcessAction(Request $request): Response
|
||||
{
|
||||
// Get configuration container
|
||||
$shopConfiguration = $this->getConfiguration();
|
||||
|
||||
// Get current configuration, before processing everything
|
||||
$currentConfiguration = Server::create($shopConfiguration);
|
||||
$currentConfiguration = Configuration::create($this->configuration);
|
||||
|
||||
$serverForm = $this->serverFormHandler->getForm();
|
||||
$serverForm->handleRequest($request);
|
||||
$form = $this->formHandler->getForm();
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Just show the boring configuration field on no submit/invalid form
|
||||
if (!$serverForm->isSubmitted() || !$serverForm->isValid()) {
|
||||
// Try and create the client
|
||||
$client = Client::createFromConfiguration($this->getConfiguration());
|
||||
|
||||
if (!$form->isSubmitted() || !$form->isValid()) {
|
||||
// Create the authorization URL (without redirect)
|
||||
$authorizeUrl = ApiKey::getAuthorizeUrl($this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_HOST), Constants::BTCPAY_PERMISSIONS, $this->module->name, true, true, null, $this->module->name);
|
||||
$authorizeUrl = ApiKey::getAuthorizeUrl($this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST), Constants::BTCPAY_PERMISSIONS, $this->module->name, true, true, null, $this->module->name);
|
||||
|
||||
return $this->getResponse($request, $serverForm, $this->generalFormHandler->getForm(), $authorizeUrl, $client);
|
||||
return $this->render('@Modules/btcpay/views/templates/admin/configure.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
|
||||
'invalidApiKey' => false === Client::createFromConfiguration($this->configuration)->isValid(),
|
||||
'latestVersion' => $this->versioning->latest(),
|
||||
'moduleVersion' => $this->module->version,
|
||||
'authorizeUrl' => $authorizeUrl,
|
||||
'enableSidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @var Server $submittedConfiguration */
|
||||
$submittedConfiguration = $serverForm->getData();
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = $form->getData()['btcpay'];
|
||||
|
||||
// If there are errors in the form, error out here
|
||||
if (0 !== \count($saveErrors = $this->serverFormHandler->save($submittedConfiguration->toArray()))) {
|
||||
if (0 !== \count($saveErrors = $this->formHandler->save($form->getData()))) {
|
||||
$this->flashErrors($saveErrors);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// If the configuration is the same, just stop
|
||||
if ($submittedConfiguration->equals($currentConfiguration)) {
|
||||
if ($configuration->equals($currentConfiguration)) {
|
||||
$this->addFlash('success', 'BTCPay Server Plugin: Settings have not changed.');
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// If we are just removing the API key, do that and return
|
||||
if (null === $submittedConfiguration->getApiKey() && !empty($currentConfiguration->getApiKey())) {
|
||||
if (null === $configuration->getApiKey() && !empty($currentConfiguration->getApiKey())) {
|
||||
// Remove the current webhook to prevent issues in the future
|
||||
if (false === (new Client($shopConfiguration->get(Constants::CONFIGURATION_BTCPAY_HOST), $currentConfiguration->getApiKey()))->webhook()->removeCurrent()) {
|
||||
if (false === (new Client($this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST), $currentConfiguration->getApiKey()))->webhook()->removeCurrent()) {
|
||||
$this->addFlash('error', 'BTCPay Server Plugin: Could not remove webhook from the server. Please double check it is actually gone.');
|
||||
}
|
||||
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, null);
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID, null);
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_SECRET, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_SECRET, null);
|
||||
|
||||
$this->addFlash('success', 'BTCPay Server plugin: API key has been removed');
|
||||
|
||||
@ -162,96 +163,40 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
(new Client($currentConfiguration->getHost(), $currentConfiguration->getApiKey()))->webhook()->removeCurrent();
|
||||
|
||||
// If an API key is set, use that
|
||||
if (null !== $submittedConfiguration->getApiKey()) {
|
||||
return $this->processApiKey($submittedConfiguration);
|
||||
if (null !== $configuration->getApiKey()) {
|
||||
return $this->processApiKey($configuration);
|
||||
}
|
||||
|
||||
// If nothing has been set, redirect to the host
|
||||
return $this->processRedirect($request, $submittedConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.")
|
||||
*
|
||||
* @return RedirectResponse|Response
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function editGeneralSettingsAction(Request $request): Response
|
||||
{
|
||||
// Get current configuration, before processing everything
|
||||
$currentConfiguration = General::create($this->getConfiguration());
|
||||
|
||||
$generalForm = $this->generalFormHandler->getForm();
|
||||
$generalForm->handleRequest($request);
|
||||
|
||||
// Just show the boring configuration field on no submit/invalid form
|
||||
if (!$generalForm->isSubmitted() || !$generalForm->isValid()) {
|
||||
// Try and create the client
|
||||
$client = Client::createFromConfiguration($this->getConfiguration());
|
||||
|
||||
// Create the authorization URL (without redirect)
|
||||
$authorizeUrl = ApiKey::getAuthorizeUrl($this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_HOST), Constants::BTCPAY_PERMISSIONS, $this->module->name, true, true, null, $this->module->name);
|
||||
|
||||
return $this->getResponse($request, $this->serverFormHandler->getForm(), $generalForm, $authorizeUrl, $client);
|
||||
}
|
||||
|
||||
/** @var General $general */
|
||||
$general = $generalForm->getData();
|
||||
|
||||
// If there are errors in the form, error out here
|
||||
if (0 !== \count($saveErrors = $this->generalFormHandler->save($general->toArray()))) {
|
||||
$this->flashErrors($saveErrors);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// If the configuration is the same, just stop
|
||||
if ($general->equals($currentConfiguration)) {
|
||||
$this->addFlash('success', 'BTCPay Server Plugin: Settings have not changed.');
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Return home
|
||||
$this->addFlash('success', 'BTCPay Server Plugin: Settings have been saved.');
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
return $this->processRedirect($request, $configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RedirectResponse|Response
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function validateAPIKeyAction(Request $request): Response
|
||||
public function validateAction(Request $request): Response
|
||||
{
|
||||
// If we received an empty post we probably hit the PrestaShop security check
|
||||
if (empty($request->request->all())) {
|
||||
$this->addFlash('error', 'Did not receive data from BTCPay Server. If you received an <strong>Invalid Token</strong> page, make sure to properly setup PrestaShop and BTCPay Server (publicly accessible and HTTPS enabled). Please try again once done or use the API key option.');
|
||||
|
||||
// Make sure to reset the API key
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Validate incoming request and return any errors we encounter
|
||||
// Validate incoming request and return any errors we encouter
|
||||
$validateRequest = new ValidateApiKey($request->request);
|
||||
if (0 !== \count($errors = $this->validator->validate($validateRequest))) {
|
||||
/** @var ConstraintViolationInterface $error */
|
||||
foreach ($errors as $error) {
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
}
|
||||
|
||||
// Make sure to reset the API key
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Build the client
|
||||
$client = new Client($this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_HOST), $validateRequest->getApiKey());
|
||||
$client = new Client($this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST), $validateRequest->getApiKey());
|
||||
|
||||
// Get the store ID
|
||||
$storeId = $validateRequest->getStoreID();
|
||||
@ -260,10 +205,6 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
// Ensure we have a valid BTCPay Server version
|
||||
if (null !== ($info = $client->server()->getInfo()) && \version_compare($info->getVersion(), Constants::MINIMUM_BTCPAY_VERSION, '<')) {
|
||||
$this->addFlash('error', \sprintf('BTCPay server version is too low. Expected %s or higher, received %s.', Constants::MINIMUM_BTCPAY_VERSION, $info->getVersion()));
|
||||
PrestaShopLogger::addLog(\sprintf('[ERROR] BTCPay server version is too low. Expected %s or higher, received %s.', Constants::MINIMUM_BTCPAY_VERSION, $info->getVersion()), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
// Make sure to reset the API key
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
@ -271,50 +212,33 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
// Ensure we have a payment methods setup
|
||||
if (empty($client->payment()->getPaymentMethods($storeId))) {
|
||||
$this->addFlash('error', \sprintf("This plugin expects a payment method to have been setup for store '%s'.", $client->store()->getStore($storeId)->offsetGet('name')));
|
||||
PrestaShopLogger::addLog(\sprintf("[ERROR] This plugin expects a payment method to have been setup for store '%s'.", $client->store()->getStore($storeId)->offsetGet('name')), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
// Make sure to reset the API key
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Ensure we have a webhook
|
||||
$client->webhook()->ensureWebhook($storeId);
|
||||
} catch (Throwable $throwable) {
|
||||
$this->addFlash('error', \sprintf('BTCPay Server plugin: %s', $throwable->getMessage()));
|
||||
PrestaShopLogger::addLog(\sprintf('[ERROR] An error occurred during configuration validation: %s', $throwable), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, $throwable->getCode());
|
||||
} catch (\Throwable $exception) {
|
||||
$this->addFlash('error', \sprintf('BTCPay Server plugin: %s', $exception->getMessage()));
|
||||
\PrestaShopLogger::addLog('[ERROR] An error occurred during setup ' . \print_r($exception, true));
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Store the API key and store ID we received
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_API_KEY, $validateRequest->getApiKey());
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, $storeId);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, $validateRequest->getApiKey());
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, $storeId);
|
||||
|
||||
$this->addFlash('success', 'BTCPay Server plugin: Your store and server have been linked!');
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
protected function getConfiguration(): ShopConfigurationInterface
|
||||
{
|
||||
// Fallback in case 8.0 is used // TODO: Remove once we make 9.0 the minimum
|
||||
if (\version_compare(\_PS_VERSION_, '8.1.0', '<')) {
|
||||
return $this->configuration;
|
||||
}
|
||||
|
||||
return parent::getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function processApiKey(Server $configuration): RedirectResponse
|
||||
private function processApiKey(Configuration $configuration): RedirectResponse
|
||||
{
|
||||
// Get configuration container
|
||||
$shopConfiguration = $this->getConfiguration();
|
||||
|
||||
// Build the client
|
||||
$client = new Client($configuration->getHost(), $configuration->getApiKey());
|
||||
|
||||
@ -322,66 +246,51 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
// Validate created API key and return any errors we encounter
|
||||
$validateKey = new ValidateApiKey(new ParameterBag($client->apiKey()->getCurrent()->getData()));
|
||||
if (0 !== \count($errors = $this->validator->validate($validateKey))) {
|
||||
/** @var ConstraintViolationInterface $error */
|
||||
foreach ($errors as $error) {
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
}
|
||||
|
||||
// Make sure to reset the API key
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Get the store ID
|
||||
$storeId = $validateKey->getStoreID();
|
||||
|
||||
// Grab the store
|
||||
$store = $client->store()->getStore($storeId);
|
||||
|
||||
// Ensure we have a valid BTCPay Server version
|
||||
if (null !== ($info = $client->server()->getInfo()) && \version_compare($info->getVersion(), Constants::MINIMUM_BTCPAY_VERSION, '<')) {
|
||||
$this->addFlash('error', \sprintf('BTCPay server version is too low. Expected %s or higher, received %s.', Constants::MINIMUM_BTCPAY_VERSION, $info->getVersion()));
|
||||
PrestaShopLogger::addLog(\sprintf('[ERROR] BTCPay server version is too low. Expected %s or higher, received %s.', Constants::MINIMUM_BTCPAY_VERSION, $info->getVersion()), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
// Make sure to reset the API key
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Ensure we have a payment methods setup
|
||||
if (empty($client->payment()->getPaymentMethods($storeId))) {
|
||||
$this->addFlash('error', \sprintf("This plugin expects a payment method to have been setup for store '%s'.", $store->offsetGet('name')));
|
||||
PrestaShopLogger::addLog(\sprintf("[ERROR] This plugin expects a payment method to have been setup for store '%s'.", $store->offsetGet('name')), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
// Make sure to reset the API key
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$this->addFlash('error', \sprintf("This plugin expects a payment method to have been setup for store '%s'.", $client->store()->getStore($storeId)->offsetGet('name')));
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Save the new store ID
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, $storeId);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, $storeId);
|
||||
|
||||
// Ensure we have a webhook
|
||||
$client->webhook()->ensureWebhook($storeId);
|
||||
} catch (Throwable $throwable) {
|
||||
$this->addFlash('error', \sprintf('BTCPay Server plugin: %s', $throwable->getMessage()));
|
||||
PrestaShopLogger::addLog(\sprintf('[ERROR] An error occurred during setup: %s', $throwable), PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, $throwable->getCode());
|
||||
} catch (\Throwable $exception) {
|
||||
$this->addFlash('error', \sprintf('BTCPay Server plugin: %s', $exception->getMessage()));
|
||||
\PrestaShopLogger::addLog('[ERROR] An error occurred during setup ' . \print_r($exception, true));
|
||||
|
||||
// Ensure nothing is saved
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, null);
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID, null);
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_SECRET, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_SECRET, null);
|
||||
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
// Store the API key and store ID we received
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, $validateKey->getApiKey());
|
||||
$shopConfiguration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, $storeId);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, $validateKey->getApiKey());
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_STORE_ID, $storeId);
|
||||
|
||||
$this->addFlash('success', 'BTCPay Server plugin: Your store and server have been linked!');
|
||||
|
||||
@ -390,19 +299,19 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function processRedirect(Request $request, Server $configuration): RedirectResponse
|
||||
private function processRedirect(Request $request, Configuration $configuration): RedirectResponse
|
||||
{
|
||||
// Get the store name and build the redirect URL
|
||||
$storeName = $this->getContext()->shop->name;
|
||||
$storeName = $this->getContext()->shop->name;
|
||||
$redirectUrl = $request->getSchemeAndHttpHost() . $this->getAdminLink('btcpay', ['route' => 'admin_btcpay_validate'], true);
|
||||
|
||||
// Create the authorization URL (with redirect)
|
||||
$authorizeUrl = ApiKey::getAuthorizeUrl($configuration->getHost(), Constants::BTCPAY_PERMISSIONS, $storeName, true, true, $redirectUrl, $storeName);
|
||||
|
||||
// If there is no API key, redirect no matter what
|
||||
if (empty($apiKey = $this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_API_KEY))) {
|
||||
if (empty($apiKey = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY))) {
|
||||
return $this->redirect($authorizeUrl);
|
||||
}
|
||||
|
||||
@ -411,17 +320,17 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
$client = new Client($configuration->getHost(), $apiKey);
|
||||
|
||||
// If we don't have a store ID, abort right away
|
||||
if (null === ($storeID = $this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_STORE_ID))) {
|
||||
if (null === ($storeID = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID))) {
|
||||
return $this->redirect($authorizeUrl);
|
||||
}
|
||||
|
||||
// Ensure we have a webhook
|
||||
$client->webhook()->ensureWebhook($storeID);
|
||||
} catch (Throwable) {
|
||||
} catch (\Throwable $e) {
|
||||
// Reset BTCPay details
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID, null);
|
||||
$this->getConfiguration()->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_SECRET, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID, null);
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_WEBHOOK_SECRET, null);
|
||||
|
||||
// Redirect away to get proper details
|
||||
return $this->redirect($authorizeUrl);
|
||||
@ -430,20 +339,4 @@ class ConfigureController extends FrameworkBundleAdminController
|
||||
// Return home
|
||||
return $this->redirectToRoute('admin_btcpay_configure');
|
||||
}
|
||||
|
||||
private function getResponse(Request $request, FormInterface $serverForm, FormInterface $generalForm, string $authorizeUrl, ?Client $client): Response
|
||||
{
|
||||
return $this->render('@Modules/btcpay/views/templates/admin/configure.html.twig', [
|
||||
'server_form' => $serverForm->createView(),
|
||||
'general_form' => $generalForm->createView(),
|
||||
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
|
||||
'storeId' => $this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_STORE_ID),
|
||||
'webhookId' => $this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID),
|
||||
'latestVersion' => $this->versioning->latest(),
|
||||
'moduleVersion' => $this->module->version,
|
||||
'authorizeUrl' => $authorizeUrl,
|
||||
'client' => $client,
|
||||
'enableSidebar' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -2,10 +2,6 @@
|
||||
|
||||
namespace BTCPay\Entity;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
*/
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -2,10 +2,6 @@
|
||||
|
||||
namespace BTCPay\Exception;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class BTCPayException extends \RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Factory;
|
||||
|
||||
use BTCPay\Repository\CustomerThreadRepository;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class CustomerMessage
|
||||
{
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public static function create(\CustomerThread $ct, string $message): \CustomerMessage
|
||||
{
|
||||
// Create a customer message
|
||||
$cm = new \CustomerMessage();
|
||||
$cm->id_customer_thread = $ct->id;
|
||||
$cm->id_employee = 0;
|
||||
$cm->message = $message;
|
||||
$cm->private = true;
|
||||
$cm->read = true;
|
||||
|
||||
// Ensure it is actually created
|
||||
$cm->add();
|
||||
|
||||
return $cm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public static function addToOrder(\Shop $shop, \Order $order, string $message): void
|
||||
{
|
||||
// Find or create the customer thread
|
||||
$ct = CustomerThreadRepository::fetchOrCreate($shop, $order);
|
||||
|
||||
// Ensure the thread is open
|
||||
$ct->status = 'open';
|
||||
$ct->update();
|
||||
|
||||
// Create the message
|
||||
self::create($ct, $message);
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Factory;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class CustomerThread
|
||||
{
|
||||
/**
|
||||
* @throws \PrestaShopException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
*/
|
||||
public static function create(\Shop $shop, \Order $order): \CustomerThread
|
||||
{
|
||||
// Grab the customer from the order
|
||||
$customer = $order->getCustomer();
|
||||
|
||||
// Create a customer thread
|
||||
$ct = new \CustomerThread();
|
||||
$ct->id_contact = 0;
|
||||
$ct->id_customer = $order->id_customer;
|
||||
$ct->id_shop = (int) $shop->id;
|
||||
$ct->id_order = (int) $order->id;
|
||||
$ct->id_lang = \Language::getIdByIso('en');
|
||||
$ct->email = $customer->email;
|
||||
$ct->status = 'open';
|
||||
$ct->token = \Tools::passwdGen(12);
|
||||
|
||||
// Ensure it is actually created
|
||||
$ct->add();
|
||||
|
||||
return $ct;
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -3,15 +3,11 @@
|
||||
namespace BTCPay\Form;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Form\Data\General;
|
||||
use BTCPay\Form\Data\Configuration;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration as PrestaShopConfiguration;
|
||||
use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class GeneralFormDataProvider implements FormDataProviderInterface
|
||||
class ConfigureFormDataProvider implements FormDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var PrestaShopConfiguration
|
||||
@ -23,9 +19,12 @@ class GeneralFormDataProvider implements FormDataProviderInterface
|
||||
$this->configuration = new PrestaShopConfiguration();
|
||||
}
|
||||
|
||||
public function getData(): General
|
||||
/**
|
||||
* @return Configuration[]
|
||||
*/
|
||||
public function getData(): array
|
||||
{
|
||||
return General::create($this->configuration);
|
||||
return ['btcpay' => Configuration::create($this->configuration)];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,8 +32,16 @@ class GeneralFormDataProvider implements FormDataProviderInterface
|
||||
*/
|
||||
public function setData(array $data): array
|
||||
{
|
||||
// Re-create configuration element with form data
|
||||
$configuration = General::fromArray($data);
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = $data['btcpay'];
|
||||
|
||||
if ($this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST) !== \rtrim(\trim(($host = $configuration->getHost())), '/\\') && !empty($host)) {
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_HOST, \rtrim(\trim($host), '/\\'));
|
||||
}
|
||||
|
||||
if ($this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY) !== \rtrim(\trim(($apiKey = $configuration->getApiKey())), '/\\') && !empty($apiKey)) {
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, \rtrim(\trim($apiKey), '/\\'));
|
||||
}
|
||||
|
||||
if ($this->configuration->get(Constants::CONFIGURATION_SPEED_MODE) !== ($speedMode = $configuration->getSpeed()) && !empty($speedMode)) {
|
||||
$this->configuration->set(Constants::CONFIGURATION_SPEED_MODE, $speedMode);
|
||||
@ -4,15 +4,18 @@ namespace BTCPay\Form\Data;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPayServer\Client\InvoiceCheckoutOptions;
|
||||
use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class General
|
||||
class Configuration
|
||||
{
|
||||
/**
|
||||
* @Assert\Url()
|
||||
* @Assert\NotBlank()
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Choice(choices=\BTCPay\Constants::TRANSACTION_SPEEDS, message="Invalid transaction speed")
|
||||
@ -29,42 +32,56 @@ class General
|
||||
*/
|
||||
private $orderMode;
|
||||
|
||||
/**
|
||||
* @Assert\Choice(choices={true, false})
|
||||
*/
|
||||
private $protectOrders;
|
||||
|
||||
/**
|
||||
* @Assert\Choice(choices={true, false})
|
||||
*/
|
||||
private $shareMetadata;
|
||||
|
||||
public function __construct(string $speed, string $orderMode, bool $protectOrders, bool $shareMetadata)
|
||||
/**
|
||||
* @Assert\Type(type="alnum")
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $apiKey;
|
||||
|
||||
public function __construct(string $host, string $speed, string $orderMode, bool $shareMetadata, string $apiKey = null)
|
||||
{
|
||||
$this->speed = $speed;
|
||||
$this->orderMode = $orderMode;
|
||||
$this->protectOrders = $protectOrders;
|
||||
$this->host = $host;
|
||||
$this->apiKey = $apiKey;
|
||||
$this->speed = $speed;
|
||||
$this->orderMode = $orderMode;
|
||||
$this->shareMetadata = $shareMetadata;
|
||||
}
|
||||
|
||||
public static function create(ShopConfigurationInterface $configuration): self
|
||||
public static function create(\PrestaShop\PrestaShop\Adapter\Configuration $configuration): self
|
||||
{
|
||||
return new self(
|
||||
$configuration->get(Constants::CONFIGURATION_BTCPAY_HOST, Constants::CONFIGURATION_DEFAULT_HOST),
|
||||
$configuration->get(Constants::CONFIGURATION_SPEED_MODE, InvoiceCheckoutOptions::SPEED_MEDIUM),
|
||||
$configuration->get(Constants::CONFIGURATION_ORDER_MODE, Constants::ORDER_MODE_BEFORE),
|
||||
(bool) $configuration->get(Constants::CONFIGURATION_PROTECT_ORDERS, true),
|
||||
(bool) $configuration->get(Constants::CONFIGURATION_SHARE_METADATA, false),
|
||||
$configuration->get(Constants::CONFIGURATION_SHARE_METADATA, false),
|
||||
$configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY),
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): self
|
||||
public function getHost(): ?string
|
||||
{
|
||||
return new self(
|
||||
$data['speed'],
|
||||
$data['orderMode'],
|
||||
$data['protectOrders'],
|
||||
$data['shareMetadata'],
|
||||
);
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function setHost(?string $host): void
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
public function getApiKey(): ?string
|
||||
{
|
||||
return $this->apiKey;
|
||||
}
|
||||
|
||||
public function setApiKey(?string $apiKey): void
|
||||
{
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
public function getSpeed(): string
|
||||
@ -87,16 +104,6 @@ class General
|
||||
$this->orderMode = $order_mode;
|
||||
}
|
||||
|
||||
public function getProtectOrders(): bool
|
||||
{
|
||||
return $this->protectOrders;
|
||||
}
|
||||
|
||||
public function setProtectOrders(bool $protectOrders): void
|
||||
{
|
||||
$this->protectOrders = $protectOrders;
|
||||
}
|
||||
|
||||
public function shareMetadata(): bool
|
||||
{
|
||||
return $this->shareMetadata;
|
||||
@ -107,17 +114,18 @@ class General
|
||||
$this->shareMetadata = $shareMetadata;
|
||||
}
|
||||
|
||||
public function equals(self $general): bool
|
||||
public function equals(self $configuration): bool
|
||||
{
|
||||
return $this->toArray() === $general->toArray();
|
||||
return $this->toArray() === $configuration->toArray();
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'host' => $this->host,
|
||||
'apiKey' => $this->apiKey,
|
||||
'speed' => $this->speed,
|
||||
'orderMode' => $this->orderMode,
|
||||
'protectOrders' => $this->protectOrders,
|
||||
'shareMetadata' => $this->shareMetadata,
|
||||
];
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Form\Data;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Server
|
||||
{
|
||||
/**
|
||||
* @Assert\Url()
|
||||
* @Assert\NotBlank()
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @Assert\Type(type="alnum")
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $apiKey;
|
||||
|
||||
public function __construct(string $host, string $apiKey = null)
|
||||
{
|
||||
$this->host = $host;
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
public static function create(ShopConfigurationInterface $configuration): self
|
||||
{
|
||||
return new self(
|
||||
$configuration->get(Constants::CONFIGURATION_BTCPAY_HOST, Constants::CONFIGURATION_DEFAULT_HOST),
|
||||
$configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY, null),
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
$data['host'],
|
||||
$data['apiKey'],
|
||||
);
|
||||
}
|
||||
|
||||
public function getHost(): ?string
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function setHost(?string $host): void
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
public function getApiKey(): ?string
|
||||
{
|
||||
return $this->apiKey;
|
||||
}
|
||||
|
||||
public function setApiKey(?string $apiKey): void
|
||||
{
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
public function equals(self $configuration): bool
|
||||
{
|
||||
return $this->toArray() === $configuration->toArray();
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'host' => $this->host,
|
||||
'apiKey' => $this->apiKey,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Form;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Form\Data\Server;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration as PrestaShopConfiguration;
|
||||
use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class ServerFormDataProvider implements FormDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var PrestaShopConfiguration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->configuration = new PrestaShopConfiguration();
|
||||
}
|
||||
|
||||
public function getData(): Server
|
||||
{
|
||||
return Server::create($this->configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setData(array $data): array
|
||||
{
|
||||
// Re-create configuration element with form data
|
||||
$configuration = Server::fromArray($data);
|
||||
|
||||
if ($this->configuration->get(Constants::CONFIGURATION_BTCPAY_HOST) !== \rtrim(\trim(($host = $configuration->getHost())), '/\\') && !empty($host)) {
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_HOST, \rtrim(\trim($host), '/\\'));
|
||||
}
|
||||
|
||||
if ($this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY) !== \rtrim(\trim(($apiKey = $configuration->getApiKey())), '/\\') && !empty($apiKey)) {
|
||||
$this->configuration->set(Constants::CONFIGURATION_BTCPAY_API_KEY, \rtrim(\trim($apiKey), '/\\'));
|
||||
}
|
||||
|
||||
// All is fine
|
||||
return [];
|
||||
}
|
||||
}
|
||||
69
modules/btcpay/src/Form/Type/ConfigureType.php
Normal file
69
modules/btcpay/src/Form/Type/ConfigureType.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Form\Type;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Form\Data\Configuration;
|
||||
use BTCPayServer\Client\InvoiceCheckoutOptions;
|
||||
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ConfigureType extends TranslatorAwareType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('host', UrlType::class, ['label' => $this->trans('BTCPay Server URL', 'Modules.Btcpay.Admin')])
|
||||
->add('api_key', TextType::class, [
|
||||
'label' => $this->trans('BTCPay Server API key', 'Modules.Btcpay.Admin'),
|
||||
'attr' => [
|
||||
'placeholder' => empty($this->getConfiguration()->get(Constants::CONFIGURATION_BTCPAY_API_KEY))
|
||||
? $this->trans('Leave blank to be redirected to your BTCPay Server for authentication', 'Modules.Btcpay.Admin')
|
||||
: null,
|
||||
'pattern' => '[a-zA-Z0-9]+',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => null,
|
||||
])
|
||||
->add('speed', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Low', 'Modules.Btcpay.Admin') => InvoiceCheckoutOptions::SPEED_LOW,
|
||||
$this->trans('Medium', 'Modules.Btcpay.Admin') => InvoiceCheckoutOptions::SPEED_MEDIUM,
|
||||
$this->trans('High', 'Modules.Btcpay.Admin') => InvoiceCheckoutOptions::SPEED_HIGH,
|
||||
],
|
||||
'label' => $this->trans('Transaction speed', 'Modules.Btcpay.Admin'),
|
||||
'empty_data' => InvoiceCheckoutOptions::SPEED_MEDIUM,
|
||||
])
|
||||
->add('order_mode', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Order before payment', 'Modules.Btcpay.Admin') => Constants::ORDER_MODE_BEFORE,
|
||||
$this->trans('Order after payment', 'Modules.Btcpay.Admin') => Constants::ORDER_MODE_AFTER,
|
||||
],
|
||||
'label' => $this->trans('Order creation method', 'Modules.Btcpay.Admin'),
|
||||
])
|
||||
->add('share_metadata', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Yes', 'Modules.Btcpay.Admin') => true,
|
||||
$this->trans('No', 'Modules.Btcpay.Admin') => false,
|
||||
],
|
||||
'label' => $this->trans('Store customer data within invoice', 'Modules.Btcpay.Admin'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults(['data_class' => Configuration::class]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix(): string
|
||||
{
|
||||
return 'module_btcpay';
|
||||
}
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Form\Type;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Form\Data\General;
|
||||
use BTCPayServer\Client\InvoiceCheckoutOptions;
|
||||
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class GeneralType extends TranslatorAwareType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('speed', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Low', 'Modules.Btcpay.Admin') => InvoiceCheckoutOptions::SPEED_LOW,
|
||||
$this->trans('Medium', 'Modules.Btcpay.Admin') => InvoiceCheckoutOptions::SPEED_MEDIUM,
|
||||
$this->trans('High', 'Modules.Btcpay.Admin') => InvoiceCheckoutOptions::SPEED_HIGH,
|
||||
],
|
||||
'label' => $this->trans('Transaction speed', 'Modules.Btcpay.Admin'),
|
||||
'help' => $this->trans('Determines the transaction fee that we recommend to the customer.', 'Modules.Btcpay.Admin'),
|
||||
'empty_data' => InvoiceCheckoutOptions::SPEED_MEDIUM,
|
||||
])
|
||||
->add('orderMode', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Order before payment', 'Modules.Btcpay.Admin') => Constants::ORDER_MODE_BEFORE,
|
||||
$this->trans('Order after payment', 'Modules.Btcpay.Admin') => Constants::ORDER_MODE_AFTER,
|
||||
],
|
||||
'label' => $this->trans('Order creation method', 'Modules.Btcpay.Admin'),
|
||||
'help' => $this->trans('Will we create the order as soon as the user gets redirect to BTCPay Server or do we wait for the webhook.', 'Modules.Btcpay.Admin'),
|
||||
'empty_data' => Constants::ORDER_MODE_BEFORE,
|
||||
])
|
||||
->add('protectOrders', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Yes', 'Modules.Btcpay.Admin') => true,
|
||||
$this->trans('No', 'Modules.Btcpay.Admin') => false,
|
||||
],
|
||||
'label' => $this->trans('Protect order status', 'Modules.Btcpay.Admin'),
|
||||
'help' => $this->trans('Will protect the order status from changing to "failed" if it already has a "paid" order state. This will protect an order from being cancelled via webhook, if it was paid via a different payment gateway.', 'Modules.Btcpay.Admin'),
|
||||
'empty_data' => true,
|
||||
])
|
||||
->add('shareMetadata', ChoiceType::class, [
|
||||
'choices' => [
|
||||
$this->trans('Yes', 'Modules.Btcpay.Admin') => true,
|
||||
$this->trans('No', 'Modules.Btcpay.Admin') => false,
|
||||
],
|
||||
'label' => $this->trans('Send customer data to BTCPay Server', 'Modules.Btcpay.Admin'),
|
||||
'help' => $this->trans('If you want customer email, address, etc. sent to BTCPay Server enable this option. By default for privacy and GDPR reasons this is disabled.', 'Modules.Btcpay.Admin'),
|
||||
'empty_data' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults(['data_class' => General::class]);
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Form\Type;
|
||||
|
||||
use BTCPay\Form\Data\Server;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class ServerType extends TranslatorAwareType
|
||||
{
|
||||
public function __construct(TranslatorInterface $translator, array $locales)
|
||||
{
|
||||
parent::__construct($translator, $locales);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/** @var Server $data */
|
||||
$data = $builder->getData() ?? Server::create(new Configuration());
|
||||
|
||||
$builder
|
||||
->add('host', UrlType::class, [
|
||||
'label' => $this->trans('BTCPay Server URL', 'Modules.Btcpay.Admin'),
|
||||
'help' => $this->trans('The URL/host to your BTCPay Server instance. Make sure your node is reachable from the internet.', 'Modules.Btcpay.Admin'),
|
||||
'required' => true,
|
||||
])
|
||||
->add('apiKey', TextType::class, [
|
||||
'label' => $this->trans('BTCPay Server API key', 'Modules.Btcpay.Admin'),
|
||||
'attr' => [
|
||||
'pattern' => '[a-zA-Z0-9]+',
|
||||
'placeholder' => empty($data->getApiKey())
|
||||
? $this->trans('Keep blank to be redirected for authentication', 'Modules.Btcpay.Admin')
|
||||
: $this->trans('Removing the API key will disconnect your store', 'Modules.Btcpay.Admin'),
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults(['data_class' => Server::class]);
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -4,10 +4,6 @@ namespace BTCPay\Github;
|
||||
|
||||
use Composer\Semver\Comparator;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Latest
|
||||
{
|
||||
/**
|
||||
@ -37,11 +33,11 @@ class Latest
|
||||
|
||||
public function __construct(int $id, string $name, string $tagName, string $commit, string $url)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->tagName = $tagName;
|
||||
$this->commit = $commit;
|
||||
$this->url = $url;
|
||||
$this->commit = $commit;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public static function create(array $data): self
|
||||
@ -54,26 +50,61 @@ class Latest
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(int $id): self
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTagName(): string
|
||||
{
|
||||
return $this->tagName;
|
||||
}
|
||||
|
||||
public function setTagName(string $tagName): self
|
||||
{
|
||||
$this->tagName = $tagName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommit(): string
|
||||
{
|
||||
return $this->commit;
|
||||
}
|
||||
|
||||
public function setCommit(string $commit): self
|
||||
{
|
||||
$this->commit = $commit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl(string $url): self
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function newer(string $currentVersion): bool
|
||||
{
|
||||
return Comparator::greaterThan(
|
||||
|
||||
@ -3,78 +3,57 @@
|
||||
namespace BTCPay\Github;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Server\CurlAdapter;
|
||||
use Github\Api\Repo;
|
||||
use Github\Client;
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Versioning
|
||||
{
|
||||
private const HEADERS = [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => 'btcpayserver/prestashop-plugin',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var FilesystemAdapter
|
||||
* @var AdapterInterface
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* @var CurlAdapter
|
||||
* @var Repo
|
||||
*/
|
||||
private $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache = new FilesystemAdapter();
|
||||
$this->client = new CurlAdapter();
|
||||
$this->cache = new FilesystemAdapter();
|
||||
|
||||
$client = new Client();
|
||||
$client->addCache($this->cache);
|
||||
|
||||
$this->client = new Repo($client);
|
||||
}
|
||||
|
||||
public function latest(): ?Latest
|
||||
{
|
||||
try {
|
||||
// Check if we have a recent check cached
|
||||
$cachedUpdate = $this->cache->getItem(Constants::LASTEST_VERSION_CACHE_KEY);
|
||||
if ($cachedUpdate->isHit() && !empty($cachedData = $cachedUpdate->get())) {
|
||||
return Latest::create($cachedData);
|
||||
}
|
||||
// Check if we have a recent check, cached
|
||||
$cachedUpdate = $this->cache->getItem(Constants::LASTEST_VERSION_CACHE_KEY);
|
||||
if ($cachedUpdate->isHit() && !empty($cachedData = $cachedUpdate->get())) {
|
||||
return Latest::create($cachedData);
|
||||
}
|
||||
|
||||
// Fetch the latest version
|
||||
$response = $this->client->request(Request::METHOD_GET, Constants::GITHUB_API_LATEST_ENDPOINT, self::HEADERS);
|
||||
|
||||
// If the request failed, stop bothering
|
||||
if (200 !== $response->getStatus()) {
|
||||
\PrestaShopLogger::addLog(\sprintf('[WARNING] Could not check for latest version, received status: %s', $response->getBody()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $response->getStatus());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Decode JSON response
|
||||
$data = \json_decode($response->getBody(), true, 512, \JSON_THROW_ON_ERROR);
|
||||
|
||||
// If the data is empty (or the request failed), return null
|
||||
if (empty($data) || false === \array_key_exists('tag_name', $data) || (\array_key_exists('message', $data) && 'Not Found' === $data['message'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set updated data
|
||||
$cachedUpdate->expiresAfter(Constants::LASTEST_VERSION_CACHE_EXPIRATION);
|
||||
$cachedUpdate->set($data);
|
||||
|
||||
// Save updated data
|
||||
$this->cache->save($cachedUpdate);
|
||||
|
||||
// Finally, return the data
|
||||
return Latest::create($cachedUpdate->get());
|
||||
} catch (\Throwable $exception) {
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Could not check for latest version, caught exception: %s', $exception->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, $exception->getCode());
|
||||
// Fetch the latest version
|
||||
$data = $this->client->releases()->latest('btcpayserver', 'prestashop-plugin');
|
||||
|
||||
// If the data is empty, return null
|
||||
if (empty($data)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set updated data
|
||||
$cachedUpdate->expiresAfter(Constants::LASTEST_VERSION_CACHE_EXPIRATION);
|
||||
$cachedUpdate->set($data);
|
||||
|
||||
// Save updated data
|
||||
$this->cache->save($cachedUpdate);
|
||||
|
||||
// Finally, return the data
|
||||
return Latest::create($cachedUpdate->get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -6,10 +6,6 @@ use BTCPay\Constants;
|
||||
use BTCPayServer\Client\InvoiceCheckoutOptions;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
@ -27,7 +23,7 @@ class Config
|
||||
*/
|
||||
public function install(): array
|
||||
{
|
||||
// Ensure sane defaults
|
||||
// Init clear configurations
|
||||
if (!$this->configuration->set(Constants::CONFIGURATION_BTCPAY_HOST, Constants::CONFIGURATION_DEFAULT_HOST)
|
||||
|| !$this->configuration->set(Constants::CONFIGURATION_SPEED_MODE, InvoiceCheckoutOptions::SPEED_MEDIUM)
|
||||
|| !$this->configuration->set(Constants::CONFIGURATION_ORDER_MODE, Constants::ORDER_MODE_BEFORE)
|
||||
|
||||
@ -4,10 +4,6 @@ namespace BTCPay\Installer;
|
||||
|
||||
use BTCPay;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Hooks
|
||||
{
|
||||
/**
|
||||
@ -24,6 +20,8 @@ class Hooks
|
||||
{
|
||||
if (!$this->module->registerHook('displayAdminOrderMainBottom')
|
||||
|| !$this->module->registerHook('displayOrderDetail')
|
||||
|| !$this->module->registerHook('displayPaymentEU')
|
||||
|| !$this->module->registerHook('payment')
|
||||
|| !$this->module->registerHook('paymentReturn')
|
||||
|| !$this->module->registerHook('paymentOptions')
|
||||
|| !$this->module->registerHook('actionCartSave')) {
|
||||
|
||||
@ -7,10 +7,6 @@ use Language;
|
||||
use OrderState;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class OrderStates
|
||||
{
|
||||
/**
|
||||
@ -43,7 +39,7 @@ class OrderStates
|
||||
|| !\Validate::isLoadedObject(new OrderState($this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_WAITING)))) {
|
||||
if (false === $this->installAwaiting()) {
|
||||
$errors[] = [
|
||||
'key' => \sprintf('Could not add new order state: %s', Constants::CONFIGURATION_ORDER_STATE_WAITING),
|
||||
'key' => 'Could not add new order state: BTCPAY_OS_WAITING',
|
||||
'parameters' => [],
|
||||
'domain' => 'Admin.Modules.Notification',
|
||||
];
|
||||
@ -55,7 +51,7 @@ class OrderStates
|
||||
|| !\Validate::isLoadedObject(new OrderState($this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING)))) {
|
||||
if (false === $this->installConfirming()) {
|
||||
$errors[] = [
|
||||
'key' => \sprintf('Could not add new order state: %s', Constants::CONFIGURATION_ORDER_STATE_CONFIRMING),
|
||||
'key' => 'Could not add new order state: BTCPAY_OS_CONFIRMING',
|
||||
'parameters' => [],
|
||||
'domain' => 'Admin.Modules.Notification',
|
||||
];
|
||||
@ -67,7 +63,7 @@ class OrderStates
|
||||
|| !\Validate::isLoadedObject(new OrderState($this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_FAILED)))) {
|
||||
if (false === $this->installFailed()) {
|
||||
$errors[] = [
|
||||
'key' => \sprintf('Could not add new order state: %s', Constants::CONFIGURATION_ORDER_STATE_FAILED),
|
||||
'key' => 'Could not add new order state: BTCPAY_OS_FAILED',
|
||||
'parameters' => [],
|
||||
'domain' => 'Admin.Modules.Notification',
|
||||
];
|
||||
@ -79,7 +75,7 @@ class OrderStates
|
||||
|| !\Validate::isLoadedObject(new OrderState($this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_PAID)))) {
|
||||
if (false === $this->installPaid()) {
|
||||
$errors[] = [
|
||||
'key' => \sprintf('Could not add new order state: %s', Constants::CONFIGURATION_ORDER_STATE_PAID),
|
||||
'key' => 'Could not add new order state: BTCPAY_OS_PAID',
|
||||
'parameters' => [],
|
||||
'domain' => 'Admin.Modules.Notification',
|
||||
];
|
||||
@ -189,7 +185,6 @@ class OrderStates
|
||||
$order_state->color = '#108510';
|
||||
$order_state->logable = true;
|
||||
$order_state->unremovable = true;
|
||||
$order_state->invoice = true;
|
||||
$order_state->module_name = $this->moduleName;
|
||||
|
||||
foreach (Language::getLanguages(true, false, true) as $languageId) {
|
||||
|
||||
@ -2,22 +2,18 @@
|
||||
|
||||
namespace BTCPay\Installer;
|
||||
|
||||
use BTCPay\Repository\TableRepository;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
use BTCPay\Repository\BitcoinPaymentRepository;
|
||||
|
||||
class Tables
|
||||
{
|
||||
/**
|
||||
* @var TableRepository
|
||||
* @var BitcoinPaymentRepository
|
||||
*/
|
||||
private $tableRepository;
|
||||
private $repository;
|
||||
|
||||
public function __construct(TableRepository $repository)
|
||||
public function __construct(BitcoinPaymentRepository $repository)
|
||||
{
|
||||
$this->tableRepository = $repository;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -26,7 +22,7 @@ class Tables
|
||||
*/
|
||||
public function install(): array
|
||||
{
|
||||
return $this->tableRepository->createTables();
|
||||
return $this->repository->createTables();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,6 +31,6 @@ class Tables
|
||||
*/
|
||||
public function uninstall(): array
|
||||
{
|
||||
return $this->tableRepository->dropTables();
|
||||
return $this->repository->dropTables();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,6 @@ namespace BTCPay\Installer;
|
||||
use BTCPay\Server\Client;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Webhook
|
||||
{
|
||||
/**
|
||||
@ -26,16 +22,8 @@ class Webhook
|
||||
*/
|
||||
public function uninstall(): array
|
||||
{
|
||||
// Build the client from our stored configuration
|
||||
$client = Client::createFromConfiguration($this->configuration);
|
||||
|
||||
// If there is no client, return now
|
||||
if (null === $client) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Remove the current webhook to prevent issues in the future.
|
||||
if (false === ($client->webhook()->removeCurrent())) {
|
||||
// Remove the current webhook to prevent issues in the future
|
||||
if (false === (Client::createFromConfiguration($this->configuration)->webhook()->removeCurrent())) {
|
||||
return [
|
||||
[
|
||||
'key' => 'Could not remove webhook from the server. Please double check it is actually gone.',
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -4,26 +4,15 @@ namespace BTCPay\Invoice;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Entity\BitcoinPayment;
|
||||
use BTCPay\Repository\OrderPaymentRepository;
|
||||
use BTCPay\Server\Client;
|
||||
use BTCPayServer\Result\Invoice;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Processor
|
||||
{
|
||||
/**
|
||||
* @var \BTCPay
|
||||
* @var Configuration
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var \Context
|
||||
*/
|
||||
private $context;
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
@ -31,16 +20,15 @@ class Processor
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
* @var \BTCPay
|
||||
*/
|
||||
private $configuration;
|
||||
private $module;
|
||||
|
||||
public function __construct(\BTCPay $module, \Context $context, Configuration $configuration, Client $client)
|
||||
public function __construct(\BTCPay $module, Configuration $configuration, Client $client)
|
||||
{
|
||||
$this->module = $module;
|
||||
$this->context = $context;
|
||||
$this->configuration = $configuration;
|
||||
$this->client = $client;
|
||||
$this->client = $client;
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,7 +36,7 @@ class Processor
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function invoiceSettled(BitcoinPayment $bitcoinPayment): void
|
||||
public function paymentConfirmed(BitcoinPayment $bitcoinPayment)
|
||||
{
|
||||
// Get the order
|
||||
$order = new \Order($bitcoinPayment->getOrderId());
|
||||
@ -62,15 +50,15 @@ class Processor
|
||||
// Grab the invoice from the server
|
||||
$invoice = $this->client->invoice()->getInvoice($storeID, $bitcoinPayment->getInvoiceId());
|
||||
|
||||
// Ensure the invoice is not processing
|
||||
if ($invoice->isProcessing()) {
|
||||
\PrestaShopLogger::addLog(\sprintf("[ERROR] Invoice '%s' should not be processing when 'InvoiceSettled' has been received", $invoice->getId()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, null, 'Order', $order->id);
|
||||
|
||||
return;
|
||||
// Change state if it's paid/processing
|
||||
if ($invoice->isPaid() || $invoice->isProcessing()) {
|
||||
// Transaction received but we have to wait some confirmation
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
}
|
||||
|
||||
// Change state if it's settled
|
||||
if ($invoice->isSettled()) {
|
||||
// Change state if it's fully paid
|
||||
if ($invoice->isFullyPaid()) {
|
||||
// Transaction confirmed on the network
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_PAID);
|
||||
}
|
||||
|
||||
@ -79,6 +67,16 @@ class Processor
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_PAID);
|
||||
}
|
||||
|
||||
// Add a message if the user paid too late
|
||||
if ($invoice->isPaidLate()) {
|
||||
\PrestaShopLogger::addLog('[INFO] User paid after expiration for this invoice', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
}
|
||||
|
||||
// Add a message if the overpaid
|
||||
if ($invoice->isOverpaid()) {
|
||||
\PrestaShopLogger::addLog('[INFO] User overpaid for this order', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
}
|
||||
|
||||
// If nothing changed, return
|
||||
if ((string) $order->current_state === $orderStatus) {
|
||||
\PrestaShopLogger::addLog('[INFO] The state is the same as the one received', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
@ -86,8 +84,24 @@ class Processor
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the updated status
|
||||
$this->updateOrderStatus($bitcoinPayment, $orderStatus);
|
||||
// Set the status
|
||||
$bitcoinPayment->setStatus((string) $orderStatus);
|
||||
|
||||
// Update the object
|
||||
if (false === $bitcoinPayment->update(true)) {
|
||||
$error = \sprintf('[ERROR] Could not update bitcoin_payment: %s', \Db::getInstance()->getMsgError());
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
|
||||
throw new \RuntimeException($error);
|
||||
}
|
||||
|
||||
// Add the order change to the order history table
|
||||
$orderHistory = new \OrderHistory();
|
||||
$orderHistory->id_order = $bitcoinPayment->getOrderId();
|
||||
|
||||
// Store the change
|
||||
$orderHistory->changeIdOrderState($orderStatus, $bitcoinPayment->getOrderId(), true);
|
||||
$orderHistory->add(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +109,7 @@ class Processor
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function invoiceFailed(BitcoinPayment $bitcoinPayment): void
|
||||
public function paymentFailed(BitcoinPayment $bitcoinPayment)
|
||||
{
|
||||
// Get the order
|
||||
$order = new \Order($bitcoinPayment->getOrderId());
|
||||
@ -115,7 +129,7 @@ class Processor
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_FAILED);
|
||||
}
|
||||
|
||||
// Transaction was marked as invalid via BTCPay Server
|
||||
// Transaction was marked completed via BTCPay Server
|
||||
if ($invoice->isMarked()) {
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_FAILED);
|
||||
}
|
||||
@ -128,153 +142,7 @@ class Processor
|
||||
}
|
||||
|
||||
// Update the status
|
||||
$this->updateOrderStatus($bitcoinPayment, $orderStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function paymentReceived(BitcoinPayment $bitcoinPayment): void
|
||||
{
|
||||
// Get the order
|
||||
$order = new \Order($bitcoinPayment->getOrderId());
|
||||
|
||||
// Get the store ID
|
||||
$storeID = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID);
|
||||
|
||||
// Grab the invoice from the server
|
||||
$invoice = $this->client->invoice()->getInvoice($storeID, $bitcoinPayment->getInvoiceId());
|
||||
|
||||
// Set the default status to be the current status
|
||||
$orderStatus = $order->current_state;
|
||||
|
||||
// If partially paid, we are still waiting for more
|
||||
if ($invoice->isPartiallyPaid()) {
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_WAITING);
|
||||
}
|
||||
|
||||
// Transaction received, but we have to wait some confirmation
|
||||
if ($invoice->isProcessing()) {
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
}
|
||||
|
||||
// Transaction received, but paid late
|
||||
if ($invoice->isPaidLate()) {
|
||||
// Transaction received but we have to wait some confirmation
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
}
|
||||
|
||||
// Transaction received, but overpaid
|
||||
if ($invoice->isOverpaid()) {
|
||||
// Transaction received but we have to wait some confirmation
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
}
|
||||
|
||||
// Invoice confirmed on the network
|
||||
if ($invoice->isSettled()) {
|
||||
// Transaction received and already confirmed
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_PAID);
|
||||
}
|
||||
|
||||
// If nothing changed, return
|
||||
if ((string) $order->current_state === $orderStatus) {
|
||||
\PrestaShopLogger::addLog(\sprintf("[INFO] The state is the same as the one received for invoice '%s'", $invoice->getId()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the updated status
|
||||
$this->updateOrderStatus($bitcoinPayment, $orderStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function paymentReceivedCreateAfter(BitcoinPayment $bitcoinPayment): void
|
||||
{
|
||||
// Generate an order only if there is not another one with this cart
|
||||
if (null !== \Order::getByCartId($bitcoinPayment->getCartId())) {
|
||||
// We already have an order, so process as normal
|
||||
$this->paymentReceived($bitcoinPayment);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the store ID
|
||||
$storeID = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID);
|
||||
|
||||
// Grab the invoice from the server
|
||||
$invoice = $this->client->invoice()->getInvoice($storeID, $bitcoinPayment->getInvoiceId());
|
||||
|
||||
// Set an initial state
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_WAITING);
|
||||
|
||||
// If partially paid, we are still waiting for more
|
||||
if ($invoice->isPartiallyPaid()) {
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_WAITING);
|
||||
}
|
||||
|
||||
// Transaction received, but we have to wait some confirmation
|
||||
if ($invoice->isProcessing()) {
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
}
|
||||
|
||||
// Transaction received, but paid late
|
||||
if ($invoice->isPaidLate()) {
|
||||
// Transaction received but we have to wait some confirmation
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
|
||||
// Add a regular log
|
||||
\PrestaShopLogger::addLog(\sprintf("[INFO] User paid after expiration for this invoice '%s'", $invoice->getId()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE);
|
||||
}
|
||||
|
||||
// Transaction received, but overpaid
|
||||
if ($invoice->isOverpaid()) {
|
||||
// Transaction received but we have to wait some confirmation
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
}
|
||||
|
||||
// Invoice confirmed on the network
|
||||
if ($invoice->isSettled()) {
|
||||
// Transaction received and already confirmed
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_PAID);
|
||||
}
|
||||
|
||||
// Fetch the secure key, which is used to check if the order has been made from this store
|
||||
if (null === ($invoiceData = $invoice->getData()) || !\array_key_exists('metadata', $invoiceData) || !\array_key_exists('posData', $invoiceData['metadata'])) {
|
||||
\PrestaShopLogger::addLog('[ERROR] Secure key was not defined', \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the secure key
|
||||
$secureKey = $invoiceData['metadata']['posData'];
|
||||
|
||||
\PrestaShopLogger::addLog(\sprintf("[INFO] Creating actual order for invoice '%s'", $invoice->getId()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
|
||||
$this->module->validateOrder(
|
||||
$bitcoinPayment->getCartId(),
|
||||
$orderStatus,
|
||||
$bitcoinPayment->getAmount(),
|
||||
$this->module->displayName,
|
||||
null,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
$secureKey,
|
||||
$this->context->shop
|
||||
);
|
||||
|
||||
// Get the new order ID
|
||||
$order = \Order::getByCartId($bitcoinPayment->getCartId());
|
||||
|
||||
// Store the new order ID and set the proper status
|
||||
$bitcoinPayment->setOrderId($order->id);
|
||||
$bitcoinPayment->setStatus($orderStatus);
|
||||
$bitcoinPayment->setStatus((string) $orderStatus);
|
||||
|
||||
// Update the object
|
||||
if (false === $bitcoinPayment->update(true)) {
|
||||
@ -283,6 +151,14 @@ class Processor
|
||||
|
||||
throw new \RuntimeException($error);
|
||||
}
|
||||
|
||||
// Add the order change to the order history table
|
||||
$orderHistory = new \OrderHistory();
|
||||
$orderHistory->id_order = $bitcoinPayment->getOrderId();
|
||||
|
||||
// Store the change
|
||||
$orderHistory->changeIdOrderState($orderStatus, $bitcoinPayment->getOrderId(), true);
|
||||
$orderHistory->add(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,47 +166,38 @@ class Processor
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function paymentSettled(BitcoinPayment $bitcoinPayment): void
|
||||
public function paymentReceived(BitcoinPayment $bitcoinPayment)
|
||||
{
|
||||
// Get the order
|
||||
$order = new \Order($bitcoinPayment->getOrderId());
|
||||
|
||||
// Specify what status it will be
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
|
||||
// If nothing changed, return
|
||||
if ((string) $order->current_state === $orderStatus) {
|
||||
\PrestaShopLogger::addLog('[INFO] The state is the same as the one received', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the store ID
|
||||
$storeID = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID);
|
||||
|
||||
// Grab the payments from the server
|
||||
$paymentMethods = $this->client->invoice()->getPaymentMethods($storeID, $bitcoinPayment->getInvoiceId());
|
||||
// Grab the invoice from the server
|
||||
$invoice = $this->client->invoice()->getInvoice($storeID, $bitcoinPayment->getInvoiceId());
|
||||
|
||||
// Process all payments
|
||||
foreach ($paymentMethods as $paymentMethod) {
|
||||
// Grab all payments per payment method
|
||||
$payments = $paymentMethod->getPayments();
|
||||
|
||||
// Process all payments
|
||||
foreach ($payments as $payment) {
|
||||
// Payment is not yet settled, continue
|
||||
if (Invoice::STATUS_SETTLED !== $payment->getStatus()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Payment is known, continue
|
||||
if (OrderPaymentRepository::hasPayment($order, $payment)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add the payment
|
||||
$order->addOrderPayment(\bcmul($payment->getValue(), $paymentMethod->getRate()), null, $payment->getTransactionId());
|
||||
}
|
||||
// Add a message if the user paid too late
|
||||
if ($invoice->isPaidLate()) {
|
||||
\PrestaShopLogger::addLog('[INFO] User paid after expiration for this invoice', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
private function updateOrderStatus(BitcoinPayment $bitcoinPayment, string $orderStatus): void
|
||||
{
|
||||
// Set the status
|
||||
// Add a message if the overpaid
|
||||
if ($invoice->isOverpaid()) {
|
||||
\PrestaShopLogger::addLog('[INFO] User overpaid for this order', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
}
|
||||
|
||||
// Update the status
|
||||
$bitcoinPayment->setStatus($orderStatus);
|
||||
|
||||
// Update the object
|
||||
@ -342,11 +209,82 @@ class Processor
|
||||
}
|
||||
|
||||
// Add the order change to the order history table
|
||||
$orderHistory = new \OrderHistory();
|
||||
$orderHistory = new \OrderHistory();
|
||||
$orderHistory->id_order = $bitcoinPayment->getOrderId();
|
||||
|
||||
// Store the change and make sure to create an invoice using existing payments (in case the status is changed to 'paid with crypto')
|
||||
// Store the change
|
||||
$orderHistory->changeIdOrderState($orderStatus, $bitcoinPayment->getOrderId(), true);
|
||||
$orderHistory->add();
|
||||
$orderHistory->add(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function paymentReceivedCreateAfter(BitcoinPayment $bitcoinPayment)
|
||||
{
|
||||
// Specify what status it will be
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_CONFIRMING);
|
||||
|
||||
// Get the store ID
|
||||
$storeID = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID);
|
||||
|
||||
// Grab the invoice from the server
|
||||
$invoice = $this->client->invoice()->getInvoice($storeID, $bitcoinPayment->getInvoiceId());
|
||||
|
||||
// Fetch the secure key, which is used to check if the order has been made from this store
|
||||
if (null === ($invoiceData = $invoice->getData()) || !\array_key_exists('metadata', $invoiceData) || !\array_key_exists('posData', $invoiceData['metadata'])) {
|
||||
\PrestaShopLogger::addLog('[ERROR] Secure key was not defined', \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the secure key
|
||||
$secureKey = $invoiceData['metadata']['posData'];
|
||||
|
||||
// Generate an order only if there is not another one with this cart
|
||||
if ($existingOrder = \Order::getByCartId($bitcoinPayment->getCartId())) {
|
||||
$message = \sprintf('[INFO] Invoice %s already has an order %s', $bitcoinPayment->getInvoiceId(), $existingOrder->reference);
|
||||
\PrestaShopLogger::addLog($message, \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->module->validateOrder(
|
||||
$bitcoinPayment->getCartId(),
|
||||
$orderStatus,
|
||||
$bitcoinPayment->getAmount(),
|
||||
$this->module->displayName, // BTCPay
|
||||
null, //message should be new Message
|
||||
[], // extra variables for mail
|
||||
null, //currency special
|
||||
false, // don't touch amount
|
||||
$secureKey
|
||||
);
|
||||
|
||||
// Get the new order ID
|
||||
$order = \Order::getByCartId($bitcoinPayment->getCartId());
|
||||
|
||||
$bitcoinPayment->setOrderId($order->id);
|
||||
$bitcoinPayment->setStatus($orderStatus);
|
||||
|
||||
// Add a message if the user paid too late
|
||||
if ($invoice->isPaidLate()) {
|
||||
\PrestaShopLogger::addLog('[INFO] User paid after expiration for this invoice', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
}
|
||||
|
||||
// Add a message if the overpaid
|
||||
if ($invoice->isOverpaid()) {
|
||||
\PrestaShopLogger::addLog('[INFO] User overpaid for this order', \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'Order', $order->id);
|
||||
}
|
||||
|
||||
// Update the object
|
||||
if (false === $bitcoinPayment->update(true)) {
|
||||
$error = \sprintf('[ERROR] Could not update bitcoin_payment: %s', \Db::getInstance()->getMsgError());
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
|
||||
throw new \RuntimeException($error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
135
modules/btcpay/src/LegacyBitcoinPaymentRepository.php
Normal file
135
modules/btcpay/src/LegacyBitcoinPaymentRepository.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay;
|
||||
|
||||
use BTCPay\Entity\BitcoinPayment;
|
||||
|
||||
class LegacyBitcoinPaymentRepository
|
||||
{
|
||||
/**
|
||||
* @var \Db
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = \Db::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function create(int $cartId, string $status, string $invoiceId): BitcoinPayment
|
||||
{
|
||||
$bitcoinPayment = new BitcoinPayment();
|
||||
$bitcoinPayment->setCartId($cartId);
|
||||
$bitcoinPayment->setStatus($status);
|
||||
$bitcoinPayment->setInvoiceId($invoiceId);
|
||||
|
||||
if (false === $bitcoinPayment->save(true)) {
|
||||
\PrestaShopLogger::addLog('[ERROR] Could not store bitcoin_payment', \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
throw new \RuntimeException('[ERROR] Could not store bitcoin_payment');
|
||||
}
|
||||
|
||||
\PrestaShopLogger::addLog('[INFO] Created bitcoin_payment for invoice ' . $invoiceId, \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
|
||||
return $bitcoinPayment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getOneByInvoiceID(string $invoiceId): ?BitcoinPayment
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.invoice_id = "%s"', $invoiceId))
|
||||
->limit(1);
|
||||
|
||||
$result = $this->connection->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getOneByInvoiceReference(string $invoiceReference): ?BitcoinPayment
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.invoice_reference = "%s"', $invoiceReference))
|
||||
->limit(1);
|
||||
|
||||
$result = $this->connection->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getOneByCartID(int $cartID): ?BitcoinPayment
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.cart_id = "%s"', $cartID))
|
||||
->limit(1);
|
||||
|
||||
$result = $this->connection->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getOneByOrderID(int $orderID): ?BitcoinPayment
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.order_id = "%s"', $orderID))
|
||||
->limit(1);
|
||||
|
||||
$result = $this->connection->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
}
|
||||
|
||||
if (false === ($object = $this->connection->query($query)->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
@ -2,128 +2,80 @@
|
||||
|
||||
namespace BTCPay\Repository;
|
||||
|
||||
use BTCPay\Entity\BitcoinPayment;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Exception;
|
||||
|
||||
class BitcoinPaymentRepository
|
||||
{
|
||||
/**
|
||||
* @throws \PrestaShopException
|
||||
* @var Connection
|
||||
*/
|
||||
public static function create(int $cartId, string $status, string $invoiceId): BitcoinPayment
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
public function __construct(Connection $connection, string $prefix)
|
||||
{
|
||||
$bitcoinPayment = new BitcoinPayment();
|
||||
$bitcoinPayment->setCartId($cartId);
|
||||
$bitcoinPayment->setStatus($status);
|
||||
$bitcoinPayment->setInvoiceId($invoiceId);
|
||||
|
||||
if (false === $bitcoinPayment->save(true)) {
|
||||
\PrestaShopLogger::addLog('[ERROR] Could not store bitcoin_payment', \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
throw new \RuntimeException('[ERROR] Could not store bitcoin_payment');
|
||||
}
|
||||
|
||||
\PrestaShopLogger::addLog('[INFO] Created bitcoin_payment for invoice ' . $invoiceId, \PrestaShopLogger::LOG_SEVERITY_LEVEL_INFORMATIVE, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
|
||||
return $bitcoinPayment;
|
||||
$this->connection = $connection;
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public static function getOneByInvoiceID(string $invoiceId): ?BitcoinPayment
|
||||
public function createTables(): array
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.invoice_id = "%s"', $invoiceId))
|
||||
->limit(1);
|
||||
$errors = [];
|
||||
$engine = \_MYSQL_ENGINE_;
|
||||
|
||||
$result = \Db::getInstance()->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
$queries = [
|
||||
"CREATE TABLE IF NOT EXISTS `{$this->prefix}bitcoin_payment`(
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`cart_id` int(11) NOT NULL,
|
||||
`order_id` int(11),
|
||||
`status` varchar(255) NOT NULL,
|
||||
`invoice_id` varchar(255),
|
||||
`invoice_reference` varchar(255),
|
||||
`amount` varchar(255),
|
||||
`bitcoin_price` varchar(255),
|
||||
`bitcoin_paid` varchar(255),
|
||||
`bitcoin_address` varchar(255),
|
||||
`bitcoin_refund_address` varchar(255),
|
||||
`redirect` varchar(255),
|
||||
`rate` varchar(255),
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `invoice_id` (`invoice_id`)
|
||||
) ENGINE=$engine DEFAULT CHARSET=utf8",
|
||||
];
|
||||
|
||||
try {
|
||||
foreach ($queries as $query) {
|
||||
$this->connection->executeQuery($query);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errors[] = ['key' => \json_encode($e->getMessage(), \JSON_THROW_ON_ERROR), 'parameters' => [], 'domain' => 'Admin.Modules.Notification'];
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public static function getOneByInvoiceReference(string $invoiceReference): ?BitcoinPayment
|
||||
public function dropTables(): array
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.invoice_reference = "%s"', $invoiceReference))
|
||||
->limit(1);
|
||||
$errors = [];
|
||||
$query = "DROP TABLE IF EXISTS `{$this->prefix}bitcoin_payment`";
|
||||
|
||||
$result = \Db::getInstance()->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
try {
|
||||
$this->connection->executeQuery($query);
|
||||
} catch (Exception $e) {
|
||||
$errors[] = ['key' => \json_encode($e->getMessage(), \JSON_THROW_ON_ERROR), 'parameters' => [], 'domain' => 'Admin.Modules.Notification'];
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public static function getOneByCartID(int $cartID): ?BitcoinPayment
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.cart_id = "%s"', $cartID))
|
||||
->limit(1);
|
||||
|
||||
$result = \Db::getInstance()->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public static function getOneByOrderID(int $orderID): ?BitcoinPayment
|
||||
{
|
||||
$query = new \DbQuery();
|
||||
$query->select('bp.*')
|
||||
->from('bitcoin_payment', 'bp')
|
||||
->where(\sprintf('bp.order_id = "%s"', $orderID))
|
||||
->limit(1);
|
||||
|
||||
$result = \Db::getInstance()->query($query);
|
||||
if (0 !== ($errorCode = (int) $result->errorCode())) {
|
||||
throw new \PrestaShopDatabaseException(\json_encode($result->errorInfo(), \JSON_THROW_ON_ERROR), $errorCode);
|
||||
}
|
||||
|
||||
if (false === ($object = $result->fetchObject(BitcoinPayment::class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $object;
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Repository;
|
||||
|
||||
use BTCPay\Factory\CustomerThread;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class CustomerThreadRepository
|
||||
{
|
||||
/**
|
||||
* @throws \PrestaShopException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
*/
|
||||
public static function fetchOrCreate(\Shop $shop, \Order $order): \CustomerThread
|
||||
{
|
||||
// Get the customer
|
||||
$customer = $order->getCustomer();
|
||||
|
||||
// Check if we need to create a thread, if so, create it and return it
|
||||
if (false === ($threadId = \CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id))) {
|
||||
return CustomerThread::create($shop, $order);
|
||||
}
|
||||
|
||||
// Return the existing thread
|
||||
return new \CustomerThread((int) $threadId);
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Repository;
|
||||
|
||||
use BTCPayServer\Result\InvoicePayment;
|
||||
use PrestaShopCollection;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class OrderPaymentRepository
|
||||
{
|
||||
/**
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public static function hasPayment(\Order $order, InvoicePayment $payment): bool
|
||||
{
|
||||
$order_payments = new PrestaShopCollection(\OrderPayment::class);
|
||||
$order_payments->where('order_reference', '=', $order->reference);
|
||||
$order_payments->where('transaction_id', '=', $payment->getTransactionId());
|
||||
|
||||
return false === empty($order_payments->getResults());
|
||||
}
|
||||
}
|
||||
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BTCPay\Repository;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Exception;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class TableRepository
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->prefix = \_DB_PREFIX_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function createTables(): array
|
||||
{
|
||||
$errors = [];
|
||||
$engine = \_MYSQL_ENGINE_;
|
||||
|
||||
$queries = [
|
||||
"CREATE TABLE IF NOT EXISTS `{$this->prefix}bitcoin_payment`(
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`cart_id` int(11) NOT NULL,
|
||||
`order_id` int(11),
|
||||
`status` varchar(255) NOT NULL,
|
||||
`invoice_id` varchar(255),
|
||||
`invoice_reference` varchar(255),
|
||||
`amount` varchar(255),
|
||||
`bitcoin_price` varchar(255),
|
||||
`bitcoin_paid` varchar(255),
|
||||
`bitcoin_address` varchar(255),
|
||||
`bitcoin_refund_address` varchar(255),
|
||||
`redirect` varchar(255),
|
||||
`rate` varchar(255),
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `invoice_id` (`invoice_id`)
|
||||
) ENGINE=$engine DEFAULT CHARSET=utf8",
|
||||
];
|
||||
|
||||
try {
|
||||
foreach ($queries as $query) {
|
||||
$this->connection->executeQuery($query);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errors[] = ['key' => \json_encode($e->getMessage(), \JSON_THROW_ON_ERROR), 'parameters' => [], 'domain' => 'Admin.Modules.Notification'];
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function dropTables(): array
|
||||
{
|
||||
$errors = [];
|
||||
$query = "DROP TABLE IF EXISTS `{$this->prefix}bitcoin_payment`";
|
||||
|
||||
try {
|
||||
$this->connection->executeQuery($query);
|
||||
} catch (Exception $e) {
|
||||
$errors[] = ['key' => \json_encode($e->getMessage(), \JSON_THROW_ON_ERROR), 'parameters' => [], 'domain' => 'Admin.Modules.Notification'];
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -3,19 +3,16 @@
|
||||
namespace BTCPay\Server;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Repository\BitcoinPaymentRepository;
|
||||
use BTCPay\LegacyBitcoinPaymentRepository;
|
||||
use BTCPayServer\Client\AbstractClient;
|
||||
use BTCPayServer\Client\ApiKey as ApiKeyClient;
|
||||
use BTCPayServer\Client\Invoice as InvoiceClient;
|
||||
use BTCPayServer\Client\Server as ServerClient;
|
||||
use BTCPayServer\Client\Store as StoreClient;
|
||||
use BTCPayServer\Client\StorePaymentMethod;
|
||||
use BTCPayServer\Client\StorePaymentMethodLightningNetwork;
|
||||
use BTCPayServer\Client\StorePaymentMethodOnChain;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Client extends AbstractClient
|
||||
{
|
||||
@ -44,6 +41,16 @@ class Client extends AbstractClient
|
||||
*/
|
||||
private $payment;
|
||||
|
||||
/**
|
||||
* @var StorePaymentMethodOnChain
|
||||
*/
|
||||
private $onChain;
|
||||
|
||||
/**
|
||||
* @var StorePaymentMethodLightningNetwork
|
||||
*/
|
||||
private $offChain;
|
||||
|
||||
/**
|
||||
* @var Webhook
|
||||
*/
|
||||
@ -54,6 +61,11 @@ class Client extends AbstractClient
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var LegacyBitcoinPaymentRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
public function __construct(string $baseUrl, string $apiKey)
|
||||
{
|
||||
$httpClient = new CurlAdapter();
|
||||
@ -65,27 +77,20 @@ class Client extends AbstractClient
|
||||
$this->server = new ServerClient($baseUrl, $apiKey, $httpClient);
|
||||
$this->store = new StoreClient($baseUrl, $apiKey, $httpClient);
|
||||
$this->payment = new StorePaymentMethod($baseUrl, $apiKey, $httpClient);
|
||||
$this->onChain = new StorePaymentMethodOnChain($baseUrl, $apiKey, $httpClient);
|
||||
$this->offChain = new StorePaymentMethodLightningNetwork($baseUrl, $apiKey, $httpClient);
|
||||
$this->webhook = new Webhook($baseUrl, $apiKey, $httpClient);
|
||||
|
||||
$this->configuration = new Configuration();
|
||||
$this->repository = new LegacyBitcoinPaymentRepository();
|
||||
}
|
||||
|
||||
public static function createFromConfiguration(ShopConfigurationInterface $configuration): ?self
|
||||
public static function createFromConfiguration(Configuration $configuration): self
|
||||
{
|
||||
$host = $configuration->get(Constants::CONFIGURATION_BTCPAY_HOST, null);
|
||||
$apiKey = $configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY, null);
|
||||
|
||||
// Cannot create a client, if we do not have valid configuration
|
||||
if (empty($host) || empty($apiKey)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new self($host, $apiKey);
|
||||
}
|
||||
|
||||
public function getBaseUrl(): string
|
||||
{
|
||||
return parent::getBaseUrl();
|
||||
return new self(
|
||||
$configuration->get(Constants::CONFIGURATION_BTCPAY_HOST),
|
||||
$configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY)
|
||||
);
|
||||
}
|
||||
|
||||
public function invoice(): InvoiceClient
|
||||
@ -113,6 +118,16 @@ class Client extends AbstractClient
|
||||
return $this->payment;
|
||||
}
|
||||
|
||||
public function onChain(): StorePaymentMethodOnChain
|
||||
{
|
||||
return $this->onChain;
|
||||
}
|
||||
|
||||
public function offChain(): StorePaymentMethodLightningNetwork
|
||||
{
|
||||
return $this->offChain;
|
||||
}
|
||||
|
||||
public function webhook(): Webhook
|
||||
{
|
||||
return $this->webhook;
|
||||
@ -121,12 +136,8 @@ class Client extends AbstractClient
|
||||
public function isValid(): bool
|
||||
{
|
||||
try {
|
||||
// Test the server connection
|
||||
$this->server()->getInfo();
|
||||
|
||||
// Test the store connection
|
||||
$this->store()->getStore($this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID))->getName();
|
||||
} catch (\Throwable) {
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -144,7 +155,7 @@ class Client extends AbstractClient
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByCartID($cart->id))) {
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByCartID($cart->id))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,6 @@ use BTCPayServer\Http\CurlClient;
|
||||
use BTCPayServer\Http\ResponseInterface;
|
||||
use STS\Backoff\Backoff;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class CurlAdapter extends CurlClient
|
||||
{
|
||||
/**
|
||||
|
||||
@ -6,10 +6,6 @@ use BTCPay\Constants;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class ValidateApiKey
|
||||
{
|
||||
/**
|
||||
@ -44,7 +40,7 @@ class ValidateApiKey
|
||||
}
|
||||
|
||||
/**
|
||||
* @Assert\IsTrue(message="This plugin expects all passed permissions to be given. Please remove and recreate the API key")
|
||||
* @Assert\IsTrue(message="This plugin expects all passed permissions to be given. Remove the new API key and try again.")
|
||||
*/
|
||||
public function hasRequiredPermissions(): bool
|
||||
{
|
||||
@ -59,7 +55,7 @@ class ValidateApiKey
|
||||
}
|
||||
|
||||
/**
|
||||
* @Assert\IsTrue(message="This plugin requires one store (and one store only) to be authorized. Please remove and recreate the API key.")
|
||||
* @Assert\IsTrue(message="This plugin requires one store (and one store only) to be authorized. Remove the new API key and try again.")
|
||||
*/
|
||||
public function hasSingleStore(): bool
|
||||
{
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -4,17 +4,18 @@ namespace BTCPay\Server;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Exception\BTCPayException;
|
||||
use BTCPay\Repository\BitcoinPaymentRepository;
|
||||
use BTCPay\LegacyBitcoinPaymentRepository;
|
||||
use BTCPayServer\Client\InvoiceCheckoutOptions;
|
||||
use BTCPayServer\Util\PreciseNumber;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Factory
|
||||
{
|
||||
/**
|
||||
* @var LegacyBitcoinPaymentRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Link
|
||||
*/
|
||||
@ -37,6 +38,7 @@ class Factory
|
||||
|
||||
public function __construct(\BTCPay $module, \Context $context)
|
||||
{
|
||||
$this->repository = new LegacyBitcoinPaymentRepository();
|
||||
$this->link = new \Link();
|
||||
$this->configuration = new Configuration();
|
||||
$this->context = $context;
|
||||
@ -57,13 +59,12 @@ class Factory
|
||||
}
|
||||
|
||||
// Build the client from our stored configuration
|
||||
$client = Client::createFromConfiguration($this->configuration);
|
||||
try {
|
||||
$client = Client::createFromConfiguration($this->configuration);
|
||||
} catch (\Throwable $e) {
|
||||
\PrestaShopLogger::addLog(\sprintf('[MAJOR] %s', $e->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_MAJOR, $e->getCode());
|
||||
|
||||
// Ensure the client is ready for use
|
||||
if (null === $client || false === $client->isValid()) {
|
||||
\PrestaShopLogger::addLog("[ERROR] The BTCPay payment plugin was called to process a payment but the client doesn't exist.", \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
return null;
|
||||
throw new BTCPayException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
// Make sure we have a webhook, before we redirect anyone anywhere
|
||||
@ -119,8 +120,8 @@ class Factory
|
||||
$orderStatus = (string) $this->configuration->get(Constants::CONFIGURATION_ORDER_STATE_WAITING);
|
||||
|
||||
// Register invoice into bitcoin_payment table, if we didn't have one before.
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByCartID($cart->id))) {
|
||||
$bitcoinPayment = BitcoinPaymentRepository::create($cart->id, $orderStatus, $invoiceId);
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByCartID($cart->id))) {
|
||||
$bitcoinPayment = $this->repository->create($cart->id, $orderStatus, $invoiceId);
|
||||
}
|
||||
|
||||
$bitcoinPayment->setInvoiceId($invoiceId);
|
||||
@ -137,7 +138,7 @@ class Factory
|
||||
|
||||
// If we create the order after payment, do not make the order yet
|
||||
if (Constants::ORDER_MODE_AFTER === $this->configuration->get(Constants::CONFIGURATION_ORDER_MODE)) {
|
||||
// Update the object, so we can always validate it afterward
|
||||
// Update the object, so we can always validate it afterwards
|
||||
if (false === $bitcoinPayment->update(true)) {
|
||||
$error = \sprintf('[ERROR] Could not update bitcoin_payment: %s', \Db::getInstance()->getMsgError());
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, null, 'BitcoinPayment', $bitcoinPayment->getId());
|
||||
@ -157,13 +158,12 @@ class Factory
|
||||
$bitcoinPayment->getCartId(),
|
||||
$bitcoinPayment->getStatus(),
|
||||
$bitcoinPayment->getAmount(),
|
||||
$this->module->displayName,
|
||||
null,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
$customer->secure_key,
|
||||
$this->context->shop
|
||||
$this->module->displayName, // BTCPay
|
||||
null, //message should be new Message
|
||||
[], // extra variables for mail
|
||||
null, //currency special
|
||||
false, // don't touch amount
|
||||
$customer->secure_key
|
||||
);
|
||||
|
||||
// Get the new order ID
|
||||
@ -182,10 +182,10 @@ class Factory
|
||||
|
||||
// Redirect user to payment
|
||||
return $bitcoinPayment->getRedirect();
|
||||
} catch (\Throwable $throwable) {
|
||||
\PrestaShopLogger::addLog(\sprintf('[ERROR] %s', $throwable->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR, $throwable->getCode());
|
||||
} catch (\Throwable $e) {
|
||||
\PrestaShopLogger::addLog(\sprintf('[ERROR] %s', $e->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_ERROR);
|
||||
|
||||
throw new BTCPayException($throwable->getMessage(), $throwable->getCode(), $throwable);
|
||||
throw new BTCPayException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ class Factory
|
||||
'taxIncluded' => $taxAmount,
|
||||
];
|
||||
|
||||
// Only include personal details if enabled, if not, return here (force to bool, as the default could be not bool)
|
||||
// Only include personal details if enabled, if not, return here
|
||||
if (false === (bool) $this->configuration->get(Constants::CONFIGURATION_SHARE_METADATA, false)) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
@ -8,10 +8,6 @@ use BTCPayServer\Http\ClientInterface;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Webhook extends \BTCPayServer\Client\Webhook
|
||||
{
|
||||
/**
|
||||
@ -38,7 +34,7 @@ class Webhook extends \BTCPayServer\Client\Webhook
|
||||
*/
|
||||
public function ensureWebhook(string $storeId): void
|
||||
{
|
||||
// Check if we have an existing webhook, if so, just cancel now (empty check is required).
|
||||
// Check if we have an existing webhook, if so, just cancel now
|
||||
if (false === empty($this->getCurrent($storeId, $this->configuration->get(Constants::CONFIGURATION_BTCPAY_WEBHOOK_ID)))) {
|
||||
return;
|
||||
}
|
||||
@ -72,8 +68,7 @@ class Webhook extends \BTCPayServer\Client\Webhook
|
||||
public function getCurrent(string $storeId, ?string $webhookId): ?\BTCPayServer\Result\Webhook
|
||||
{
|
||||
try {
|
||||
// We need to check for empty here as twig passes a null variable as "" instead of null in configure.html.twig.
|
||||
if (empty($webhookId)) {
|
||||
if (null === $webhookId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -82,9 +77,9 @@ class Webhook extends \BTCPayServer\Client\Webhook
|
||||
}
|
||||
|
||||
return !empty($webhook->getData()) ? $webhook : null;
|
||||
} catch (\Throwable $throwable) {
|
||||
$warning = \sprintf("[WARNING] expected webhook '%s' for store '%s' to exist, but it didn't. Exception received: %s", $webhookId, $storeId, $throwable->getMessage());
|
||||
\PrestaShopLogger::addLog($warning, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $throwable->getCode());
|
||||
} catch (\Throwable $e) {
|
||||
$warning = \sprintf("[WARNING] expected webhook '%s' for store '%s' to exist, but it didn't. Exception received: %s", $webhookId, $storeId, $e->getMessage());
|
||||
\PrestaShopLogger::addLog($warning, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $e->getCode());
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -108,9 +103,8 @@ class Webhook extends \BTCPayServer\Client\Webhook
|
||||
$this->deleteWebhook($storeId, $webhookId);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $throwable) {
|
||||
$message = \sprintf("[WARNING] Could not remove webhook '%s' from the store '%s'. Please double check it is actually gone. Exception received: %s", $webhookId, $storeId, $throwable->getMessage());
|
||||
\PrestaShopLogger::addLog($message, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $throwable->getCode());
|
||||
} catch (\Throwable $e) {
|
||||
\PrestaShopLogger::addLog(\sprintf("[WARNING] Could not remove webhook '%s' from the store '%s'. Please double check it is actually gone. Exception received: %s", $webhookId, $storeId, $e->getMessage()), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, $e->getCode());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3,22 +3,27 @@
|
||||
namespace BTCPay\Server;
|
||||
|
||||
use BTCPay\Constants;
|
||||
use BTCPay\Factory\CustomerMessage;
|
||||
use BTCPay\Invoice\Processor;
|
||||
use BTCPay\Repository\BitcoinPaymentRepository;
|
||||
use BTCPay\LegacyBitcoinPaymentRepository;
|
||||
use PrestaShop\PrestaShop\Adapter\Configuration;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
if (!\defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class WebhookHandler
|
||||
{
|
||||
/**
|
||||
* @var \Context
|
||||
* @var \BTCPay
|
||||
*/
|
||||
private $context;
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var LegacyBitcoinPaymentRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
@ -30,11 +35,13 @@ class WebhookHandler
|
||||
*/
|
||||
private $processor;
|
||||
|
||||
public function __construct(\BTCPay $module, \Context $context, Client $client)
|
||||
public function __construct(\BTCPay $module, Client $client, LegacyBitcoinPaymentRepository $repository)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->module = $module;
|
||||
$this->client = $client;
|
||||
$this->repository = $repository;
|
||||
$this->configuration = new Configuration();
|
||||
$this->processor = new Processor($module, $context, $this->configuration, $client);
|
||||
$this->processor = new Processor($this->module, $this->configuration, $this->client);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,55 +62,48 @@ class WebhookHandler
|
||||
}
|
||||
|
||||
// If it's a test, just accept it
|
||||
if (\str_contains($data['invoiceId'], '__test__')) {
|
||||
if (false !== \strpos($data['invoiceId'], '__test__')) {
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received test IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the data type
|
||||
$eventType = (string) $data['type'];
|
||||
$dataType = (string) $data['type'];
|
||||
|
||||
// Get order mode
|
||||
$orderMode = $this->configuration->get(Constants::CONFIGURATION_ORDER_MODE);
|
||||
|
||||
// Payment has been received (order already exists)
|
||||
if (Constants::ORDER_MODE_BEFORE === $orderMode && \in_array($eventType, ['InvoiceProcessing', 'InvoicePaidInFull', 'InvoiceReceivedPayment'], true)) {
|
||||
if (Constants::ORDER_MODE_BEFORE === $orderMode && \in_array($dataType, ['InvoiceProcessing', 'InvoicePaidInFull', 'InvoiceReceivedPayment'], true)) {
|
||||
$this->paymentReceived($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Payment has been received (order needs to be made)
|
||||
if (Constants::ORDER_MODE_AFTER === $orderMode && \in_array($eventType, ['InvoiceProcessing', 'InvoicePaidInFull', 'InvoiceReceivedPayment'], true)) {
|
||||
if (Constants::ORDER_MODE_AFTER === $orderMode && \in_array($dataType, ['InvoiceProcessing', 'InvoicePaidInFull', 'InvoiceReceivedPayment'], true)) {
|
||||
$this->paymentReceivedDelayedOrder($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Payment has failed
|
||||
if (\in_array($dataType, ['InvoiceInvalid', 'InvoiceExpired'], true)) {
|
||||
$this->paymentFailed($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Payment has been confirmed
|
||||
if ('InvoicePaymentSettled' === $eventType) {
|
||||
$this->paymentSettled($data);
|
||||
if ('InvoiceSettled' === $dataType) {
|
||||
$this->paymentConfirmed($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoice has failed or expired
|
||||
if (\in_array($eventType, ['InvoiceInvalid', 'InvoiceExpired'], true)) {
|
||||
$this->invoiceFailed($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoice has been confirmed
|
||||
if ('InvoiceSettled' === $eventType) {
|
||||
$this->invoiceSettled($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoice was crated, but either order already exists or will be created on first payment, skip
|
||||
if ('InvoiceCreated' === $eventType) {
|
||||
// We don't really care about these events
|
||||
if (\in_array($dataType, ['InvoiceCreated', 'InvoicePaymentSettled'], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ class WebhookHandler
|
||||
$invoiceId = (string) $data['invoiceId'];
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Payment received for invoice %s', $invoiceId));
|
||||
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByInvoiceID($invoiceId))) {
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByInvoiceID($invoiceId))) {
|
||||
$error = \sprintf('[WARNING] Could not load order with invoice ID %s', $invoiceId);
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING);
|
||||
@ -144,7 +144,7 @@ class WebhookHandler
|
||||
$invoiceId = (string) $data['invoiceId'];
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Payment received for invoice %s', $invoiceId));
|
||||
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByInvoiceID($invoiceId))) {
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByInvoiceID($invoiceId))) {
|
||||
$error = \sprintf('[WARNING] Could not load order with invoice ID %s', $invoiceId);
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING);
|
||||
@ -157,40 +157,17 @@ class WebhookHandler
|
||||
$this->processor->paymentReceivedCreateAfter($bitcoinPayment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
private function paymentSettled(array $data): void
|
||||
{
|
||||
$invoiceId = (string) $data['invoiceId'];
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] One of the payments has settled for invoice %s', $invoiceId));
|
||||
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByInvoiceID($invoiceId))) {
|
||||
$error = \sprintf('[WARNING] Could not load order with invoice ID %s', $invoiceId);
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING);
|
||||
|
||||
// Don't bother retrying
|
||||
return;
|
||||
}
|
||||
|
||||
// Deal with the actual invoice now
|
||||
$this->processor->paymentSettled($bitcoinPayment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
private function invoiceFailed(array $data): void
|
||||
private function paymentFailed(array $data): void
|
||||
{
|
||||
$invoiceId = (string) $data['invoiceId'];
|
||||
\PrestaShopLogger::addLog(\sprintf("[INFO] Invoice '%s' failed, either because it wasn't paid, it expired or it was marked as invalid", $invoiceId));
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Payment failed for invoice %s', $invoiceId));
|
||||
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByInvoiceID($invoiceId))) {
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByInvoiceID($invoiceId))) {
|
||||
$error = \sprintf('[WARNING] Could not load order with invoice ID %s', $invoiceId);
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING);
|
||||
@ -204,30 +181,7 @@ class WebhookHandler
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if protection is disabled, if so, just process the failure
|
||||
if (false === $this->configuration->get(Constants::CONFIGURATION_PROTECT_ORDERS, true)) {
|
||||
$this->processor->invoiceFailed($bitcoinPayment);
|
||||
}
|
||||
|
||||
// Otherwise, will need to check the order so fetch it
|
||||
$order = new \Order($bitcoinPayment->getOrderId());
|
||||
|
||||
// Check if the order has been paid, if so, add a note and abort
|
||||
if (\Validate::isLoadedObject($orderState = $order->getCurrentOrderState()) && $orderState->paid) {
|
||||
// Ensure we log this IPN
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
\PrestaShopLogger::addLog(\sprintf("[WARN] Webhook ('%s') received from BTCPay Server, but the order was already marked as paid.", $data['type']), \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING, null, 'Order', $order->id);
|
||||
|
||||
// Build a simple note and add it to the order
|
||||
$note = \sprintf("BTCPay Server: Webhook ('%s') received, but the order was already marked as paid.", $data['type']);
|
||||
CustomerMessage::addToOrder($this->context->shop, $order, $note);
|
||||
|
||||
// Don't bother with the rest
|
||||
return;
|
||||
}
|
||||
|
||||
// The order has not been set to paid, process the failure
|
||||
$this->processor->invoiceFailed($bitcoinPayment);
|
||||
$this->processor->paymentFailed($bitcoinPayment);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,12 +189,12 @@ class WebhookHandler
|
||||
* @throws \PrestaShopException
|
||||
* @throws \PrestaShopDatabaseException
|
||||
*/
|
||||
private function invoiceSettled(array $data): void
|
||||
private function paymentConfirmed(array $data): void
|
||||
{
|
||||
$invoiceId = (string) $data['invoiceId'];
|
||||
\PrestaShopLogger::addLog(\sprintf("[INFO] Invoice '%s' has been settled and thus fully paid", $invoiceId));
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Payment confirmed for invoice %s', $invoiceId));
|
||||
|
||||
if (null === ($bitcoinPayment = BitcoinPaymentRepository::getOneByInvoiceID($invoiceId))) {
|
||||
if (null === ($bitcoinPayment = $this->repository->getOneByInvoiceID($invoiceId))) {
|
||||
$error = \sprintf('[WARNING] Could not load order with invoice ID %s', $invoiceId);
|
||||
\PrestaShopLogger::addLog(\sprintf('[INFO] Received IPN: %s', \json_encode($data, \JSON_THROW_ON_ERROR)));
|
||||
\PrestaShopLogger::addLog($error, \PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING);
|
||||
@ -254,6 +208,6 @@ class WebhookHandler
|
||||
return;
|
||||
}
|
||||
|
||||
$this->processor->invoiceSettled($bitcoinPayment);
|
||||
$this->processor->paymentConfirmed($bitcoinPayment);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@ -7,9 +7,9 @@ if (!defined('_PS_VERSION_')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
* @param BTCpay $module
|
||||
*/
|
||||
function upgrade_module_2_0_0(mixed $module): bool
|
||||
function upgrade_module_2_0_0(ModuleInterface $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
|
||||
@ -8,11 +8,11 @@ if (!defined('_PS_VERSION_')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
* @param BTCpay $module
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
function upgrade_module_3_0_0(mixed $module): bool
|
||||
function upgrade_module_3_0_0(ModuleInterface $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
|
||||
@ -7,9 +7,9 @@ if (!defined('_PS_VERSION_')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
* @param BTCpay $module
|
||||
*/
|
||||
function upgrade_module_4_0_0(mixed $module): bool
|
||||
function upgrade_module_4_0_0(ModuleInterface $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
|
||||
@ -9,13 +9,13 @@ if (!defined('_PS_VERSION_')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
* @param BTCpay $module
|
||||
*
|
||||
* @throws JsonException
|
||||
* @throws PrestaShopDatabaseException
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
function upgrade_module_5_0_0(mixed $module): bool
|
||||
function upgrade_module_5_0_0(ModuleInterface $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
|
||||
@ -7,9 +7,9 @@ if (!defined('_PS_VERSION_')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
* @param BTCpay $module
|
||||
*/
|
||||
function upgrade_module_5_1_0(mixed $module): bool
|
||||
function upgrade_module_5_1_0(ModuleInterface $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PrestaShop\PrestaShop\Core\Module\ModuleInterface;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
*/
|
||||
function upgrade_module_6_0_0(mixed $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
}
|
||||
|
||||
return updateHooks($module);
|
||||
}
|
||||
|
||||
function updateHooks(BTCPay $module): bool
|
||||
{
|
||||
return $module->unregisterHook('payment');
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PrestaShop\PrestaShop\Core\Module\ModuleInterface;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
*/
|
||||
function upgrade_module_6_0_2(mixed $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
}
|
||||
|
||||
return $module->unregisterHook('displayPaymentEU');
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
use BTCPay\Constants;
|
||||
use PrestaShop\PrestaShop\Core\Module\ModuleInterface;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BTCpay|ModuleInterface|mixed $module
|
||||
*
|
||||
* @throws PrestaShopDatabaseException
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
function upgrade_module_6_1_0(mixed $module): bool
|
||||
{
|
||||
if (!$module instanceof BTCPay) {
|
||||
throw new LogicException('Received invalid module');
|
||||
}
|
||||
|
||||
// Set a sane default for the new protection mode (which is true)
|
||||
Configuration::set(Constants::CONFIGURATION_PROTECT_ORDERS, true);
|
||||
|
||||
// Update "paid with crypto" order statuses to allow the invoice to be downloaded
|
||||
$orderState = new OrderState(Configuration::get(Constants::CONFIGURATION_ORDER_STATE_PAID));
|
||||
|
||||
// Ensure we actually have a valid order state
|
||||
if (!\Validate::isLoadedObject($orderState)) {
|
||||
throw new \LogicException(\sprintf("Expected order state '%s' to exist", Constants::CONFIGURATION_ORDER_STATE_FAILED));
|
||||
}
|
||||
|
||||
// Allow the invoice to be downloaded and save the order state
|
||||
$orderState->invoice = true;
|
||||
$orderState->save();
|
||||
|
||||
// And we are done
|
||||
return true;
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user