-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOL-1222: add POS payment method (#620)
* MOL-1222: Payment Method POS Terminals * NTR: Pos layout * NTR: hide status change * NTR: handle response * NTR: add auto redirect again --------- Co-authored-by: Vitalij Mik <[email protected]>
- Loading branch information
1 parent
c5f2ddd
commit 817f3e0
Showing
84 changed files
with
2,246 additions
and
634 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,89 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Controller\StoreApi\POS; | ||
|
||
use Kiener\MolliePayments\Controller\StoreApi\POS\Response\StoreTerminalResponse; | ||
use Kiener\MolliePayments\Controller\StoreApi\POS\Response\TerminalsResponse; | ||
use Kiener\MolliePayments\Gateway\MollieGatewayInterface; | ||
use Kiener\MolliePayments\Service\CustomerService; | ||
use Mollie\Api\Resources\Terminal; | ||
use Shopware\Core\Checkout\Customer\CustomerEntity; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
use Shopware\Core\System\SalesChannel\StoreApiResponse; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class PosControllerBase | ||
{ | ||
|
||
/** | ||
* @var CustomerService | ||
*/ | ||
private $customerService; | ||
|
||
/** | ||
* @var MollieGatewayInterface | ||
*/ | ||
private $mollieGateway; | ||
|
||
|
||
/** | ||
* @param CustomerService $customerService | ||
* @param MollieGatewayInterface $mollieGateway | ||
*/ | ||
public function __construct(CustomerService $customerService, MollieGatewayInterface $mollieGateway) | ||
{ | ||
$this->customerService = $customerService; | ||
$this->mollieGateway = $mollieGateway; | ||
} | ||
|
||
|
||
/** | ||
* @Route("/store-api/mollie/pos/terminals", name="store-api.mollie.pos.terminals", methods={"GET"}) | ||
* | ||
* @param SalesChannelContext $context | ||
* @return StoreApiResponse | ||
*/ | ||
public function getIssuers(SalesChannelContext $context): StoreApiResponse | ||
{ | ||
$this->mollieGateway->switchClient($context->getSalesChannelId()); | ||
|
||
$terminalsArray = []; | ||
|
||
$terminals = $this->mollieGateway->getPosTerminals(); | ||
|
||
foreach ($terminals as $terminal) { | ||
$terminalsArray[] = [ | ||
'id' => $terminal->id, | ||
'name' => $terminal->description, | ||
]; | ||
} | ||
|
||
return new TerminalsResponse($terminalsArray); | ||
} | ||
|
||
/** | ||
* @Route("/store-api/mollie/pos/store-terminal/{customerId}/{terminalID}", name="store-api.mollie.pos.store-terminal", methods={"POST"}) | ||
* | ||
* @param string $customerId | ||
* @param string $terminalID | ||
* @param SalesChannelContext $context | ||
* @throws \Exception | ||
* @return StoreApiResponse | ||
*/ | ||
public function saveTerminalId(string $customerId, string $terminalID, SalesChannelContext $context): StoreApiResponse | ||
{ | ||
$customer = $this->customerService->getCustomer($customerId, $context->getContext()); | ||
|
||
if (!$customer instanceof CustomerEntity) { | ||
throw new \Exception('Customer with ID ' . $customerId . ' not found in Shopware'); | ||
} | ||
|
||
$result = $this->customerService->setPosTerminal( | ||
$customer, | ||
$terminalID, | ||
$context->getContext() | ||
); | ||
|
||
return new StoreTerminalResponse($result !== null); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Controller/StoreApi/POS/Response/StoreTerminalResponse.php
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,29 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Controller\StoreApi\POS\Response; | ||
|
||
use Shopware\Core\Framework\Struct\ArrayStruct; | ||
use Shopware\Core\System\SalesChannel\StoreApiResponse; | ||
|
||
class StoreTerminalResponse extends StoreApiResponse | ||
{ | ||
/** | ||
* @var ArrayStruct<mixed, mixed> | ||
*/ | ||
protected $object; | ||
|
||
/** | ||
* @param bool $success | ||
*/ | ||
public function __construct(bool $success) | ||
{ | ||
$this->object = new ArrayStruct( | ||
[ | ||
'success' => $success, | ||
], | ||
'mollie_payments_pos_terminal_stored' | ||
); | ||
|
||
parent::__construct($this->object); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Controller/StoreApi/POS/Response/TerminalsResponse.php
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,30 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Controller\StoreApi\POS\Response; | ||
|
||
use Shopware\Core\Framework\Struct\ArrayStruct; | ||
use Shopware\Core\System\SalesChannel\StoreApiResponse; | ||
|
||
class TerminalsResponse extends StoreApiResponse | ||
{ | ||
/** | ||
* @var ArrayStruct<mixed, mixed> | ||
*/ | ||
protected $object; | ||
|
||
|
||
/** | ||
* @param array<mixed> $terminals | ||
*/ | ||
public function __construct(array $terminals) | ||
{ | ||
$this->object = new ArrayStruct( | ||
[ | ||
'terminals' => $terminals, | ||
], | ||
'mollie_payments_pos_terminals' | ||
); | ||
|
||
parent::__construct($this->object); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Controller\StoreApi\POS\Sw6; | ||
|
||
use Kiener\MolliePayments\Controller\StoreApi\POS\PosControllerBase; | ||
use Shopware\Core\Framework\Routing\Annotation\RouteScope; | ||
|
||
/** | ||
* @RouteScope(scopes={"store-api"}) | ||
*/ | ||
class PosController extends PosControllerBase | ||
{ | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Controller\StoreApi\POS\Sw65; | ||
|
||
use Kiener\MolliePayments\Controller\StoreApi\POS\PosControllerBase; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
/** | ||
* @Route(defaults={"_routeScope"={"store-api"}}) | ||
*/ | ||
class PosController extends PosControllerBase | ||
{ | ||
} |
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.