-
Notifications
You must be signed in to change notification settings - Fork 14
module draft with HPP integration #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
168 commits
Select commit
Hold shift + click to select a range
a285fa5
Initial commit
bartoszkaluzny-solteq f960173
SQNETS-32: create Adobe Commerce module
bartoszkaluzny-solteq f283d75
SQNETS-32: update README.md
bartoszkaluzny-solteq 577589d
SQNETS-32: initial module commit
bartoszkaluzny-solteq b5db912
SQNETS-32: add registration.php
bartoszkaluzny-solteq a5af015
SQNETS-40: Fix config virtual type
konrad-konieczny 3da9a9c
Merge pull request #1 from Solteq/SQNETS-40
konrad-konieczny 7894b26
SQNETS-40: remove unused methods
konrad-konieczny 8dbc2df
SQNETS-32: improve admin configuration
bartoszkaluzny-solteq 033ab52
SQNETS-32: improve constructor
bartoszkaluzny-solteq d789bd7
SQNETS: add code-validation.yml
bartoszkaluzny-solteq efb1819
Merge branch 'main' into SQNETS-32
bartoszkaluzny-solteq 311b960
SQNETS-32: simplify FQN
bartoszkaluzny-solteq 57f58a9
Merge remote-tracking branch 'refs/remotes/origin/SQNETS-32' into SQN…
konrad-konieczny 1ed1eb7
SQNETS-32/test-button: add test button
konrad-konieczny 4ebedb5
SQNETS-32/test-button: remove type config
konrad-konieczny 26d2d1e
SQNETS-32-test-button: remove comments
konrad-konieczny 90092a0
SQNETS: add phpunit
bartoszkaluzny-solteq d63cbe6
SQNETS-32: add PHPDocs
bartoszkaluzny-solteq 8c733ac
SQNETS-32: improve logs
bartoszkaluzny-solteq eb1e2df
SQNETS: add magento-enterprise-edition for github actions
bartoszkaluzny-solteq aa4ef66
Merge branch 'SQNETS-32' into SQNETS-32-test-button
bartoszkaluzny-solteq b8661bc
Merge pull request #3 from Solteq/SQNETS-32-test-button
bartoszkaluzny-solteq df7ca88
SQNETS-32: improve gatewayConfig
bartoszkaluzny-solteq 15e7f09
Merge pull request #2 from Solteq/SQNETS-32
bartoszkaluzny-solteq d6bfc25
SQNETS-32: add nexi as methodCode
bartoszkaluzny-solteq dfa9196
SQNETS-32: fix code-validation comments
bartoszkaluzny-solteq bc57165
SQNETS-32: fix comments
bartoszkaluzny-solteq 19f6913
SQNETS-32: update client token
bartoszkaluzny-solteq 29d959b
SQNETS-32: fix code-validation comments
bartoszkaluzny-solteq 504ae88
Merge pull request #4 from Solteq/SQNETS-32
konrad-konieczny 4c3636a
SQNETS-49: add AuthorizeRequestBuilder
konrad-konieczny eb1a1fb
Merge remote-tracking branch 'origin/main' into SQNETS-49
konrad-konieczny 924eb72
Merge branch 'refs/heads/main' into SQNETS-49
konrad-konieczny 726118f
SQNETS-49: fix di const, add error handling, fix request builder
konrad-konieczny 66b55b8
SQNETS-49: fix test connection
konrad-konieczny 7924421
SQNETS-49: add hpp payment and webhook handling
konrad-konieczny 82cf32d
SQNETS-49: add hpp payment and webhook handling
konrad-konieczny 6729794
SQNETS-49: add hpp payment and webhook handling
konrad-konieczny 974db95
SQNETS-49: add transaction and invoice creation
konrad-konieczny a9c5fe7
SQNETS-49: remove error
konrad-konieczny ca686c9
SQNETS-49: add consumer
konrad-konieczny 1e30f38
Merge pull request #5 from Solteq/SQNETS-49
konrad-konieczny d69b652
SQNETS-49: remove redirect and debug changes
konrad-konieczny 0a38a5c
Merge pull request #6
konrad-konieczny 665a65a
SQNETS-49: fix test connection
konrad-konieczny 3541ba7
Merge pull request #7
konrad-konieczny 97c06fb
main: fix test connection field mapping
konrad-konieczny c8d73fb
SQNETS-49: add cancel action logic
konrad-konieczny 9e97258
SQNETS-49: add conditions and error handling for return action
konrad-konieczny b797736
SQNETS-49: send consumer informations to nexi
konrad-konieczny 4d9a377
SQNETS-49: handle logged in customers api call
konrad-konieczny c76471d
SQNETS-49: fix tests
konrad-konieczny 94c6e49
SQNETS-49: fix namespace
konrad-konieczny 1689da6
SQNETS-49: remove logger class
konrad-konieczny 2bcf8e5
SQNETS-49: fix di
konrad-konieczny bbc600f
SQNETS-49: add api factory di
konrad-konieczny ac1b4cf
SQNETS-49: fix static code validation comments
konrad-konieczny bbd9bfc
SQNETS-49: fix static code validation comments
konrad-konieczny 9181804
SQNETS-49: fix static code validation comments
konrad-konieczny 27dcc06
Merge pull request #8 from Solteq/SQNETS-49
konrad-konieczny 3a4c0ff
SQNETS-49: add comments
konrad-konieczny f6c6fd9
SQNETS-49: add comments
konrad-konieczny 3faf050
SQNETS-49: add comments
konrad-konieczny 8f9b965
SQNETS-49: add comments
konrad-konieczny e471a46
Merge pull request #9 from Solteq/SQNETS-49
konrad-konieczny 1c1c995
SQNETS-49: reformat
konrad-konieczny f291cf7
Merge pull request #10
konrad-konieczny b805bf9
SQNETS-49: cleanup di file
konrad-konieczny db592ee
Merge pull request #11 from Solteq/SQNETS-49
konrad-konieczny 6624531
SQNETS-47: handle capture command
konrad-konieczny 8de0236
SQNETS-47: remove unused imports
konrad-konieczny 17d654a
SQNETS-47: reformat
konrad-konieczny 641b68f
SQNETS-34: webhooks configuration
bartoszkaluzny-solteq 9ba32a2
Merge pull request #12 from Solteq/SQNETS-47
konrad-konieczny fc9c372
SQNETS-34: change class name
bartoszkaluzny-solteq 01297ae
SQNETS-34: improve webhook handler
bartoszkaluzny-solteq 2cdf15b
SQNETS-47: change config, reformat request builder
konrad-konieczny 1f5ec57
Merge pull request #14
konrad-konieczny d1dea32
module draft with HPP integration
konrad-konieczny 93fe256
SQNETS-34: add more webhooks in DI
bartoszkaluzny-solteq a973e06
SQNETS-34: create service for 'payment.reservation.created.v2'
bartoszkaluzny-solteq bfb9d1e
SQNETS-34: create service class for 'payment.created' event
bartoszkaluzny-solteq 6b0ecc6
SQNETS-34: improve PaymentCreated service
bartoszkaluzny-solteq c2bced8
SQNETS-34: improve handler & controller
bartoszkaluzny-solteq e893647
SQNETS-34: update PaymentCreated service
bartoszkaluzny-solteq f0a4049
SQNETS-34: create service for 'payment.charge.created.v2'
bartoszkaluzny-solteq 1744e5d
SQNETS-34: create data loader
bartoszkaluzny-solteq be00250
SQNETS-34: push empty webhooks
bartoszkaluzny-solteq c3680e6
SQNETS-34: add refund webhook
bartoszkaluzny-solteq bec5550
fixes regarding to pr comments
konrad-konieczny e4f93e7
Merge pull request #56 from konrad-konieczny/hpp-pr-comments
konrad-konieczny b4dea16
use hosted payment method
konrad-konieczny e683d80
Merge pull request #57 from konrad-konieczny/hpp-pr-comments
konrad-konieczny e31b99d
SQNETS-34: improve webhook controller
bartoszkaluzny-solteq 0a39b56
SQNETS-34: improve webhook handler
bartoszkaluzny-solteq 71f2329
SQNETS-34: update webhooks models
bartoszkaluzny-solteq 6af9eac
Refactor payment cancellation logic and improve error handling
konrad-konieczny 400f27b
SQNETS-59: make terms and condition fields required
bartoszkaluzny-solteq e2f2b44
Improve logging in ReturnAction for better debugging
konrad-konieczny 1aa4c10
Add a blank line for improved readability in TestConnection.php
konrad-konieczny 05eee67
Refactor payment initialization to use constants for status and impro…
konrad-konieczny fb5ae31
Fix condition check for payment authorization action in ReturnAction
konrad-konieczny d2b146f
Enhance logging in ReturnAction to include payment and order IDs for …
konrad-konieczny 23f0853
Fix conditional structure in ReturnAction for payment status check
konrad-konieczny 65f0abc
Fix formatting in ReturnAction for charge transaction ID assignment
konrad-konieczny 159f6b0
Merge pull request #20 from Solteq/SQNETS-59
bartoszkaluzny-solteq af8e01d
Implement payment creation and termination in TestConnection, enhanci…
konrad-konieczny eaf3a85
Fix type casting for payment amount in CreatePaymentRequestBuilder to…
konrad-konieczny 582f498
Update URLs in TestConnection and CreatePaymentRequestBuilder for suc…
konrad-konieczny 6598697
Fix type casting for payment amount in CreatePaymentRequestBuilder to…
konrad-konieczny e866717
SQNETS-34: remove unnecessary arguments
bartoszkaluzny-solteq 100ba1b
Merge pull request #19 from Solteq/develop-2.0.0
konrad-konieczny 78e2257
SQNETS-34: simplify transaction loading by removing try-catch block
konrad-konieczny 9920805
SQNETS-34: refactor transaction loading by removing try-catch block
konrad-konieczny d92d495
refactor WebhookDataLoader constructor for improved readability
konrad-konieczny eb76b8e
Merge branch 'develop-2.0.0' into SQNETS-34
konrad-konieczny e8adc35
Enhance webhook logging and refactor webhook handler argument naming
konrad-konieczny 76d8d9f
Refactor webhook handling and enhance error logging; add serializer f…
konrad-konieczny 2256393
Fix tax rate calculation to handle division by zero in SalesDocumentI…
konrad-konieczny b0ad646
Refactor webhook handling: update namespaces, improve transaction loa…
konrad-konieczny e466bd2
Add transaction builder parameter to PaymentReservationCreated constr…
konrad-konieczny 786b5bd
Remove unused processOrder method and related code from PaymentReserv…
konrad-konieczny 9653a08
Fix typo in processWebhook parameter name and update references
konrad-konieczny 1aa6b9d
Add OrderRepositoryInterface to PaymentRefundCompleted for order saving
konrad-konieczny 4015f6e
Add TODO comments for refund completed event handling in PaymentRefun…
konrad-konieczny de8c001
Refactor PaymentRefundCompleted constructor to use readonly propertie…
konrad-konieczny 6403d34
Implement WebhookProcessorInterface in PaymentRefundCompleted and upd…
konrad-konieczny 2f9bd65
Add check for existing transaction in processWebhook method of Paymen…
konrad-konieczny 21861c1
remove github actions
konrad-konieczny 0c0fec2
Merge pull request #13 from Solteq/SQNETS-34
konrad-konieczny 5dd514f
Merge remote-tracking branch 'refs/remotes/origin/main' into develop-…
konrad-konieczny bfaa5fb
Refactor PaymentRefundCompleted to handle full refunds and add credit…
konrad-konieczny b85b248
Refactor WebhookHandler to use WebhookProcessorInterface and update p…
konrad-konieczny 7b6b11c
Enhance Webhook class with improved constructor documentation and CSR…
konrad-konieczny 16f1106
Enhance CreatePaymentRequestBuilder with additional method documentat…
konrad-konieczny 4d2891d
Merge remote-tracking branch 'origin/SQNETS-34' into SQNETS-34
konrad-konieczny af4ebcf
Enhance CreatePaymentRequestBuilder with type hinting for buildOrder …
konrad-konieczny 45c700f
Enhance PaymentRefundCompleted with constructor parameter documentati…
konrad-konieczny a10cf36
Enhance PaymentRefundCompleted and CreatePaymentRequestBuilder with t…
konrad-konieczny 1acf413
Enhance WebhookHandler with constructor documentation and type hintin…
konrad-konieczny 6f817f0
Merge pull request #21 from Solteq/SQNETS-34
konrad-konieczny 4bdc7f4
Merge branch 'main' into develop-2.0.0
konrad-konieczny 9d241d7
Add test API keys to configuration and update key retrieval logic
konrad-konieczny 4301ffc
Add support for test API key and enhance payment processing logic
konrad-konieczny 74d1299
Add method to retrieve test API key and update payment API connection…
konrad-konieczny 4a658c5
Rename API key references to secret key in configuration and update r…
konrad-konieczny 808ce30
Add auto capture option to payment configuration
konrad-konieczny 102208c
Add webhook secret generation functionality and update module version
konrad-konieczny 33e8001
SQNETS-72: add validation for config fields
bartoszkaluzny-solteq 95b374f
Add GitHub Actions workflow for PHP code validation and unit testing
konrad-konieczny bf2cdae
Add GitHub Actions workflow for PHP code validation and unit testing
konrad-konieczny 50b5c05
Merge pull request #24 from Solteq/SQNETS-72
bartoszkaluzny-solteq 29e7b10
Update payment order reference and require specific version of paymen…
konrad-konieczny 9998782
Refactor code for improved readability and maintainability; add stric…
konrad-konieczny fcb4f03
Merge remote-tracking branch 'origin/develop-2.0.0' into develop-2.0.0
konrad-konieczny e876125
Implement authorization check in Webhook and update webhook processor…
konrad-konieczny 8f1a5ab
remove merchant_handles_consumer_data configuration and related metho…
konrad-konieczny 3d027d3
Remove merchant_handles_consumer_data from config and set merchantHan…
konrad-konieczny 6a39086
Add StringSanitizer for input sanitization in SalesDocumentItemsBuild…
konrad-konieczny afff8d9
Add StringSanitizer dependency to CreatePaymentRequestBuilder constru…
konrad-konieczny c1258e3
Remove unnecessary comments and whitespace in StringSanitizer and Pay…
konrad-konieczny 75aebe3
add phone number parser
konrad-konieczny 479f48b
Add phone number parsing functionality to CreatePaymentRequestBuilder
konrad-konieczny 3b6fba3
Add StringSanitizer dependency and improve escaping in testconnection…
konrad-konieczny 25f9061
Merge remote-tracking branch 'origin-solteq/develop-2.0.0' into devel…
konrad-konieczny 19ca7af
Refactor PhoneNumber return type in getNumber method
konrad-konieczny f29f610
Update copyright holder in LICENSE file
konrad-konieczny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: Run code validation checks | ||
| on: | ||
| pull_request: | ||
| jobs: | ||
| changed-files: | ||
| runs-on: ubuntu-latest | ||
| name: Gather Changelist | ||
| strategy: | ||
| matrix: | ||
| fetch-depth: | ||
| - 2 | ||
| base-branch: | ||
| - "master" | ||
| outputs: | ||
| all: ${{ steps.changes.outputs.all }} | ||
| php: ${{ steps.changes.outputs.php }} | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: ${{ matrix.fetch-depth }} | ||
| - name: Get changed files | ||
| id: changes | ||
| run: | | ||
| BASE_SHA="${{ github.event.before }}" | ||
| if [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then | ||
| BASE_SHA="${{ matrix.base-branch }}" | ||
| fi | ||
| if [[ ! -z "${{ github.event.pull_request.base.sha }}" ]]; then | ||
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
| fi | ||
| echo "all=$(git diff --name-only --diff-filter=ACMRT $BASE_SHA ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT | ||
| echo "php=$(git diff --name-only --diff-filter=ACMRT $BASE_SHA ${{ github.sha }} | grep -E '.ph(p|tml)$' | xargs)" >> $GITHUB_OUTPUT | ||
| validate-php: | ||
| runs-on: ubuntu-latest | ||
| name: Run php code validation and Unit tests | ||
| needs: changed-files | ||
| if: ${{needs.changed-files.outputs.php}} | ||
| strategy: | ||
| matrix: | ||
| node-version: | ||
| - 20 | ||
| php-version: ["8.1", "8.2", "8.3"] | ||
| dependencies: | ||
| - "highest" | ||
| composer-options: | ||
| - "--no-plugins --no-progress" | ||
| steps: | ||
| - name: Setup node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node_version }} | ||
| - name: Check out code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Php | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-version }} | ||
| ini-file: development | ||
| tools: composer:2.2, cs2pr | ||
| env: | ||
| COMPOSER_AUTH_JSON: | | ||
| { | ||
| "http-basic": { | ||
| "repo.magento.com": { | ||
| "username": "${{ secrets.REPO_MAGENTO_USER }}", | ||
| "password": "${{ secrets.REPO_MAGENTO_PASSWORD }}" | ||
| } | ||
| } | ||
| } | ||
| - name: Validate Composer Files | ||
| run: composer validate | ||
| - name: Run Composer install | ||
| uses: "ramsey/composer-install@v1" | ||
| with: | ||
| dependency-versions: "${{ matrix.dependencies }}" | ||
| composer-options: "${{ matrix.composer-options }}" | ||
| - name: Detect PhpCs violations | ||
| run: | | ||
| vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility,../../magento/php-compatibility-fork | ||
| vendor/bin/phpcs --standard=Magento2 -q --report=checkstyle ${{needs.changed-files.outputs.php}} | cs2pr --graceful-warnings | ||
| - name: Run Unit test | ||
| run: | | ||
| vendor/bin/phpunit Test/Unit/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Nexi\Checkout\Block\Adminhtml\System\Config; | ||
|
|
||
| use Magento\Backend\Block\Template\Context; | ||
| use Magento\Config\Block\System\Config\Form\Field; | ||
| use Magento\Config\Model\Config\Structure; | ||
| use Magento\Framework\Data\Form\Element\AbstractElement; | ||
| use Magento\Framework\View\Helper\SecureHtmlRenderer; | ||
|
|
||
| class TestConnection extends Field | ||
| { | ||
| /** | ||
| * @param Context $context | ||
| * @param Structure $configStructure | ||
| * @param array $data | ||
| * @param SecureHtmlRenderer|null $secureRenderer | ||
| */ | ||
| public function __construct( | ||
| Context $context, | ||
| private readonly Structure $configStructure, | ||
| array $data = [], | ||
| ?SecureHtmlRenderer $secureRenderer = null | ||
| ) { | ||
| parent::__construct($context, $data, $secureRenderer); | ||
| } | ||
|
|
||
| /** | ||
| * Unset some non-related element parameters | ||
| * | ||
| * @param AbstractElement $element | ||
| * | ||
| * @return string | ||
| * @since 100.1.0 | ||
| */ | ||
| public function render(AbstractElement $element) | ||
| { | ||
| $element = clone $element; | ||
| $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
|
|
||
| return parent::render($element); | ||
| } | ||
|
|
||
| /** | ||
| * Set template to itself | ||
| * | ||
| * @return $this | ||
| * @since 100.1.0 | ||
| */ | ||
| protected function _prepareLayout() | ||
| { | ||
| parent::_prepareLayout(); | ||
| $this->setTemplate('Nexi_Checkout::system/config/testconnection.phtml'); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Get HTML for the element | ||
| * | ||
| * @param AbstractElement $element | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function _getElementHtml(AbstractElement $element) | ||
| { | ||
| $originalData = $element->getOriginalData(); | ||
| $this->addData( | ||
| [ | ||
| 'button_label' => __($originalData['button_label']), | ||
| 'html_id' => $element->getHtmlId(), | ||
| 'ajax_url' => $this->_urlBuilder->getUrl('nexi/system_config/testconnection'), | ||
| 'field_mapping' => str_replace('"', '\\"', json_encode($this->getFieldMapping())) | ||
| ] | ||
| ); | ||
|
|
||
| return $this->_toHtml(); | ||
| } | ||
|
|
||
| /** | ||
| * Get configuration field mapping | ||
| * | ||
| * @return string[] | ||
| */ | ||
| private function getFieldMapping(): array | ||
| { | ||
| $apiKeyPath = $this->configStructure->getElementByConfigPath('payment/nexi/secret_key'); | ||
| $testApiKeyPath = $this->configStructure->getElementByConfigPath('payment/nexi/test_secret_key'); | ||
| $environmentPath = $this->configStructure->getElementByConfigPath('payment/nexi/environment'); | ||
|
|
||
| return [ | ||
| 'environment' => str_replace('/', '_', $environmentPath->getPath()), | ||
| 'secret_key' => str_replace('/', '_', $apiKeyPath->getPath()), | ||
| 'test_secret_key' => str_replace('/', '_', $testApiKeyPath->getPath()) | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Nexi\Checkout\Controller\Adminhtml\System\Config; | ||
|
|
||
| use JsonException; | ||
| use Magento\Backend\App\Action; | ||
| use Magento\Backend\App\Action\Context; | ||
| use Magento\Framework\App\Action\HttpPostActionInterface; | ||
| use Magento\Framework\App\Config\ScopeConfigInterface; | ||
| use Magento\Framework\Controller\Result\Json; | ||
| use Magento\Framework\Controller\Result\JsonFactory; | ||
| use Magento\Framework\Filter\StripTags; | ||
| use Magento\Framework\Url; | ||
| use Magento\Store\Model\ScopeInterface; | ||
| use Nexi\Checkout\Gateway\Config\Config; | ||
| use Nexi\Checkout\Model\Config\Source\Environment; | ||
| use NexiCheckout\Api\Exception\PaymentApiException; | ||
| use NexiCheckout\Factory\PaymentApiFactory; | ||
| use NexiCheckout\Model\Request\Item; | ||
| use NexiCheckout\Model\Request\Payment; | ||
| use NexiCheckout\Model\Request\Shared\Order; | ||
|
|
||
| class TestConnection extends Action implements HttpPostActionInterface | ||
| { | ||
| /** | ||
| * Authorization level of a basic admin session. | ||
| * | ||
| * @see _isAllowed() | ||
| */ | ||
| public const ADMIN_RESOURCE = 'Magento_Catalog::config_catalog'; | ||
|
|
||
| /** | ||
| * @param Context $context | ||
| * @param JsonFactory $resultJsonFactory | ||
| * @param StripTags $tagFilter | ||
| * @param PaymentApiFactory $paymentApiFactory | ||
| * @param Config $config | ||
| * @param Url $url | ||
| * @param ScopeConfigInterface $scopeConfig | ||
| */ | ||
| public function __construct( | ||
| Context $context, | ||
| private readonly JsonFactory $resultJsonFactory, | ||
| private readonly StripTags $tagFilter, | ||
| private readonly PaymentApiFactory $paymentApiFactory, | ||
| private readonly Config $config, | ||
| private readonly Url $url, | ||
| private readonly ScopeConfigInterface $scopeConfig | ||
| ) { | ||
| parent::__construct($context); | ||
| } | ||
|
|
||
| /** | ||
| * Check for connection to server | ||
| * | ||
| * @return Json | ||
| * @throws JsonException | ||
| */ | ||
| public function execute() | ||
| { | ||
| $result = [ | ||
| 'success' => true, | ||
| 'errorMessage' => '', | ||
| ]; | ||
| $options = $this->getRequest()->getParams(); | ||
| $isLiveMode = $options['environment'] == Environment::LIVE; | ||
|
|
||
| $apiKey = $isLiveMode ? $options['secret_key'] : $options['test_secret_key']; | ||
|
|
||
| if ($apiKey == '******') { | ||
| $apiKey = $isLiveMode ? $this->config->getApiKey() : $this->config->getTestApiKey(); | ||
| } | ||
|
|
||
| try { | ||
| $api = $this->paymentApiFactory->create( | ||
| secretKey : $apiKey, | ||
| isLiveMode: $isLiveMode | ||
| ); | ||
| $currency = $this->scopeConfig->getValue( | ||
| 'currency/options/default', | ||
| ScopeInterface::SCOPE_STORE | ||
| ); | ||
|
|
||
| $payment = $api->createEmbeddedPayment( | ||
| new Payment( | ||
| new Order( | ||
| [ | ||
| new Item('test', 1, 'pcs', 1, 1, 1, 'test') | ||
| ], | ||
| $currency, | ||
| 1 | ||
| ), | ||
| new Payment\EmbeddedCheckout( | ||
| $this->url->getUrl('checkout/onepage/success'), | ||
| 'terms_url' | ||
| ) | ||
| ) | ||
| ); | ||
|
|
||
| if ($payment->getPaymentId()) { | ||
| $api->terminate($payment->getPaymentId()); | ||
| } | ||
|
|
||
| } catch (PaymentApiException $e) { | ||
| $message = $e->getMessage(); | ||
| $result['success'] = false; | ||
| $result['errorMessage'] = $this->tagFilter->filter($message) . ' ' | ||
| . __('Please check your API key and environment.'); | ||
| } | ||
|
|
||
| $resultJson = $this->resultJsonFactory->create(); | ||
|
|
||
| return $resultJson->setData($result); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| namespace Nexi\Checkout\Controller\Hpp; | ||
|
|
||
| use Magento\Checkout\Model\Session; | ||
| use Magento\Framework\App\ActionInterface; | ||
| use Magento\Framework\Controller\Result\RedirectFactory; | ||
| use Magento\Framework\Controller\ResultInterface; | ||
| use Magento\Framework\Message\ManagerInterface; | ||
| use Magento\Framework\UrlInterface; | ||
|
|
||
| class CancelAction implements ActionInterface | ||
| { | ||
| /** | ||
| * @param RedirectFactory $resultRedirectFactory | ||
| * @param UrlInterface $url | ||
| * @param Session $checkoutSession | ||
| * @param ManagerInterface $messageManager | ||
| */ | ||
| public function __construct( | ||
| private readonly RedirectFactory $resultRedirectFactory, | ||
| private readonly UrlInterface $url, | ||
| private readonly Session $checkoutSession, | ||
| private readonly ManagerInterface $messageManager | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * Execute action based on request and return result | ||
| * | ||
| * @return ResultInterface | ||
| */ | ||
| public function execute(): ResultInterface | ||
| { | ||
| $this->checkoutSession->restoreQuote(); | ||
| $this->messageManager->addNoticeMessage(__('The payment has been canceled.')); | ||
|
|
||
| return $this->resultRedirectFactory->create()->setUrl( | ||
| $this->url->getUrl('checkout/cart/index', ['_secure' => true]) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.