-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from thelia-modules/develop
Integration of variable amount and/or frequency subscriptions
- Loading branch information
Showing
23 changed files
with
1,139 additions
and
359 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,94 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <info@thelia.net> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/* web : https://www.openstudio.fr */ | ||
|
||
/* For the full copyright and license information, please view the LICENSE */ | ||
/* file that was distributed with this source code. */ | ||
|
||
namespace Axepta\Command; | ||
|
||
use Axepta\Axepta; | ||
use Axepta\Event\CreatePaymentEvent; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Thelia\Command\ContainerAwareCommand; | ||
use Thelia\Exception\TheliaProcessException; | ||
use Thelia\Model\OrderQuery; | ||
|
||
/** | ||
* Created by Franck Allimant, OpenStudio <fallimant@openstudio.fr> | ||
* Projet: thelia25 | ||
* Date: 24/01/2024. | ||
*/ | ||
class CreatePayment extends ContainerAwareCommand | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName('create-axcepta-payment') | ||
->setDescription('Create a new Axepta payment for a given order') | ||
->addArgument( | ||
'original_order_ref', | ||
InputArgument::REQUIRED, | ||
'Original order reference.' | ||
) | ||
->addArgument( | ||
'new_order_ref', | ||
InputArgument::REQUIRED, | ||
'New order reference.' | ||
) | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if (! Axepta::isSubscriptionMode()) { | ||
$output->writeln( | ||
'<error>This command is intended for use when the subscription payment feature is enabled.' | ||
.'Subscription feature is not currently activated. ($feat is activated)</error>' | ||
); | ||
|
||
return Command::INVALID; | ||
} | ||
|
||
$this->initRequest(); | ||
|
||
$orderRef = $input->getArgument('original_order_ref'); | ||
|
||
if (null === $originalOrder = OrderQuery::create()->findOneByRef($orderRef)) { | ||
throw new TheliaProcessException("Unknown order $orderRef"); | ||
} | ||
|
||
$newOrderRef = $input->getArgument('new_order_ref'); | ||
|
||
if (null === $newOrder = OrderQuery::create()->findOneByRef($newOrderRef)) { | ||
throw new TheliaProcessException("Unknown order $newOrderRef"); | ||
} | ||
|
||
$event = new CreatePaymentEvent($originalOrder, $newOrder); | ||
|
||
$this->getDispatcher()->dispatch($event, Axepta::AXCEPTA_CREATE_PAYMENT_EVENT); | ||
|
||
$output->writeln('Payment status : '.($event->isSuccess() ? 'success' : 'failure')); | ||
|
||
if (!$event->isSuccess()) { | ||
$output->writeln('<error> : '.$event->getErrorMessage().'</error>'); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains 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,27 @@ | ||
|
||
# This is a fix for InnoDB in MySQL >= 4.1.x | ||
# It "suspends judgement" for fkey relationships until are tables are set. | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- --------------------------------------------------------------------- | ||
-- axcepta_scheme | ||
-- --------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS `axcepta_scheme`; | ||
|
||
CREATE TABLE `axcepta_scheme` | ||
( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`order_id` INTEGER, | ||
`name` VARCHAR(45) NOT NULL, | ||
`number` VARCHAR(19) NOT NULL, | ||
`brand` VARCHAR(33) NOT NULL, | ||
`expiry_date` VARCHAR(6) NOT NULL, | ||
`scheme_reference_id` VARCHAR(255) NOT NULL, | ||
`created_at` DATETIME, | ||
`updated_at` DATETIME, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB; | ||
|
||
# This restores the fkey checks, after having unset them earlier | ||
SET FOREIGN_KEY_CHECKS = 1; |
This file contains 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
This file contains 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
Oops, something went wrong.