Skip to content

Commit

Permalink
Merge pull request #13 from buckaroo-it/develop
Browse files Browse the repository at this point in the history
1.0.0 to master
  • Loading branch information
vladislav-padalka-hys authored Nov 19, 2021
2 parents 603eaa9 + 7fab31a commit 6cdda77
Show file tree
Hide file tree
Showing 40 changed files with 3,048 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Module checks
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: setup php
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
- uses: actions/checkout@v2
- name: validate composer json
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/${{ env.namespace }}-source/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: PHPUnit and PHPCS
run: |
echo '{"http-basic": {"repo.magento.com": {"username": "${{ secrets.REPO_USERNAME }}","password": "${{ secrets.REPO_PASS }}"}}}' > auth.json
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.3 m24
mkdir -p m24/app/code/Buckaroo/SecondChance/
rsync -r --exclude='m24' ./ m24/app/code/Buckaroo/SecondChance/
./m24/vendor/bin/phpcs --standard=Magento2 m24/app/code/Buckaroo/SecondChance/
61 changes: 61 additions & 0 deletions Api/Data/SecondChanceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
declare (strict_types = 1);

namespace Buckaroo\Magento2SecondChance\Api\Data;

interface SecondChanceInterface extends \Magento\Framework\Api\ExtensibleDataInterface
{

const ENTITY_ID = 'entity_id';
const ORDER_ID = 'order_id';

/**
* Get secondChance_id
*
* @return string|null
*/
public function getSecondChanceId();

/**
* Set secondChance_id
*
* @param string $secondChanceId
* @return \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface
*/
public function setSecondChanceId($secondChanceId);

/**
* Retrieve existing extension attributes object or create a new one.
*
* @return \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceExtensionInterface|null
*/
public function getExtensionAttributes();

/**
* Set an extension attributes object.
*
* @param \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceExtensionInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
\Buckaroo\Magento2SecondChance\Api\Data\SecondChanceExtensionInterface $extensionAttributes
);
}
41 changes: 41 additions & 0 deletions Api/Data/SecondChanceSearchResultsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
declare (strict_types = 1);

namespace Buckaroo\Magento2SecondChance\Api\Data;

interface SecondChanceSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
{

/**
* Get SecondChance list.
*
* @return \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface[]
*/
public function getItems();

/**
* Set quote_id list.
*
* @param \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface[] $items
* @return $this
*/
public function setItems(array $items);
}
80 changes: 80 additions & 0 deletions Api/SecondChanceRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
declare (strict_types = 1);

namespace Buckaroo\Magento2SecondChance\Api;

use Magento\Framework\Api\SearchCriteriaInterface;

interface SecondChanceRepositoryInterface
{

/**
* Save SecondChance
*
* @param \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface $secondChance
* @return \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function save(
\Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface $secondChance
);

/**
* Retrieve SecondChance
*
* @param string $secondChanceId
* @return \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function get($secondChanceId);

/**
* Retrieve SecondChance matching the specified criteria.
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceSearchResultsInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getList(
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
);

/**
* Delete SecondChance
*
* @param \Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface $secondChance
* @return bool true on success
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function delete(
\Buckaroo\Magento2SecondChance\Api\Data\SecondChanceInterface $secondChance
);

/**
* Delete SecondChance by ID
*
* @param string $secondChanceId
* @return bool true on success
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function deleteById($secondChanceId);
}
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Contribution Guidelines

### Repository setup:
- Fork the repository to your account
- more details about [how to fork a repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) can be found [here](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo):

### Making changes:
- create a branch from develop branch
- name of the branch shoul be something like: `feature/GITHUB-ISSUE-ID-slug` (eg: `feature/50-configprovider-update`)
- your code changes should follow [Magento2 coding standard](https://github.com/magento/magento-coding-standard)
- including unit tests is encouraged

### Pull Request:
- open the PR to develop branch
- if there is no issue referenced, add a description about the problem and the way it is being solved
- Allow edits from maintainers


### Contribution to refactoring:
- branch should be created from refactoring
- code changes should follow Magento2 coding standard
- include unit tests
- open the Pull Request
- check that git workflows checks have passed
67 changes: 67 additions & 0 deletions Controller/Checkout/SecondChance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\Magento2SecondChance\Controller\Checkout;

use Buckaroo\Magento2\Logging\Log;

class SecondChance extends \Magento\Framework\App\Action\Action
{
/**
* @var Log
*/
protected $logger;

/**
* @var \Buckaroo\Magento2SecondChance\Model\SecondChanceRepository
*/
protected $secondChanceRepository;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param Log $logger
* @param SecondChanceRepository $secondChanceRepository
*
* @throws \Buckaroo\Magento2SecondChance\Exception
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
Log $logger,
\Buckaroo\Magento2SecondChance\Model\SecondChanceRepository $secondChanceRepository
) {
parent::__construct($context);
$this->logger = $logger;
$this->secondChanceRepository = $secondChanceRepository;
}

/**
* Process action
*
* @return \Magento\Framework\App\ResponseInterface
* @throws \Exception
*/
public function execute()
{
if ($token = $this->getRequest()->getParam('token')) {
$this->secondChanceRepository->getSecondChanceByToken($token);
}
return $this->_redirect('checkout', ['_fragment' => 'payment']);
}
}
72 changes: 72 additions & 0 deletions Cron/SecondChance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
namespace Buckaroo\Magento2SecondChance\Cron;

class SecondChance
{
/**
* @var \Buckaroo\Magento2SecondChance\Model\ConfigProvider\Account
*/
protected $configProvider;

/**
* @var Log $logging
*/
public $logging;

/**
* @var \Magento\Store\Api\StoreRepositoryInterface
*/
private $storeRepository;

/**
* @var \Buckaroo\Magento2SecondChance\Model\SecondChanceRepository
*/
protected $secondChanceRepository;

/**
* @param \Magento\Checkout\Model\Session\Proxy $checkoutSession
* @param \Buckaroo\Magento2SecondChance\Model\ConfigProvider\Account $configProvider
*/
public function __construct(
\Buckaroo\Magento2SecondChance\Model\ConfigProvider\SecondChance $configProvider,
\Magento\Store\Api\StoreRepositoryInterface $storeRepository,
\Buckaroo\Magento2\Logging\Log $logging,
\Buckaroo\Magento2SecondChance\Model\SecondChanceRepository $secondChanceRepository
) {
$this->configProvider = $configProvider;
$this->storeRepository = $storeRepository;
$this->logging = $logging;
$this->secondChanceRepository = $secondChanceRepository;
}

public function execute()
{
$stores = $this->storeRepository->getList();
foreach ($stores as $store) {
if ($this->configProvider->isSecondChanceEnabled($store)) {
foreach ([2, 1] as $step) {
$this->secondChanceRepository->getSecondChanceCollection($step, $store);
}
}
}
return $this;
}
}
Loading

0 comments on commit 6cdda77

Please sign in to comment.