-
Notifications
You must be signed in to change notification settings - Fork 54
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 #738 from mollie/release/2.34.0
Release/2.34.0
- Loading branch information
Showing
24 changed files
with
824 additions
and
79 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
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
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,46 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\GraphQL\Resolver\Checkout; | ||
|
||
use Magento\Framework\Exception\NotFoundException; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Mollie\Payment\Service\Magento\PaymentLinkRedirect as PaymentLinkRedirectService; | ||
|
||
class PaymentLinkRedirect implements ResolverInterface | ||
{ | ||
/** | ||
* @var PaymentLinkRedirectService | ||
*/ | ||
private $paymentLinkRedirect; | ||
|
||
public function __construct( | ||
PaymentLinkRedirectService $paymentLinkRedirect | ||
) { | ||
$this->paymentLinkRedirect = $paymentLinkRedirect; | ||
} | ||
|
||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) | ||
{ | ||
$order = $args['order']; | ||
|
||
try { | ||
$result = $this->paymentLinkRedirect->execute($order); | ||
} catch (NotFoundException $exception) { | ||
throw new GraphQlNoSuchEntityException(__('Order not found')); | ||
} | ||
|
||
return [ | ||
'already_paid' => $result->isAlreadyPaid(), | ||
'redirect_url' => $result->getRedirectUrl(), | ||
]; | ||
} | ||
} |
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,75 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\Service\Magento; | ||
|
||
use Magento\Framework\Encryption\EncryptorInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\Exception\NotFoundException; | ||
use Magento\Sales\Api\OrderRepositoryInterface; | ||
use Magento\Sales\Model\Order; | ||
use Mollie\Payment\Model\Mollie; | ||
|
||
class PaymentLinkRedirect | ||
{ | ||
/** | ||
* @var EncryptorInterface | ||
*/ | ||
private $encryptor; | ||
/** | ||
* @var OrderRepositoryInterface | ||
*/ | ||
private $orderRepository; | ||
/** | ||
* @var Mollie | ||
*/ | ||
private $mollie; | ||
/** | ||
* @var PaymentLinkRedirectResultFactory | ||
*/ | ||
private $paymentLinkRedirectResultFactory; | ||
|
||
public function __construct( | ||
EncryptorInterface $encryptor, | ||
OrderRepositoryInterface $orderRepository, | ||
Mollie $mollie, | ||
PaymentLinkRedirectResultFactory $paymentLinkRedirectResultFactory | ||
) { | ||
$this->encryptor = $encryptor; | ||
$this->orderRepository = $orderRepository; | ||
$this->mollie = $mollie; | ||
$this->paymentLinkRedirectResultFactory = $paymentLinkRedirectResultFactory; | ||
} | ||
|
||
public function execute(string $orderId): PaymentLinkRedirectResult | ||
{ | ||
$id = $this->encryptor->decrypt(base64_decode($orderId)); | ||
|
||
if (empty($id)) { | ||
throw new NotFoundException(__('Order not found')); | ||
} | ||
|
||
try { | ||
$order = $this->orderRepository->get($id); | ||
} catch (NoSuchEntityException $exception) { | ||
throw new NotFoundException(__('Order not found')); | ||
} | ||
|
||
if (in_array($order->getState(), [Order::STATE_PROCESSING, Order::STATE_COMPLETE])) { | ||
return $this->paymentLinkRedirectResultFactory->create([ | ||
'redirectUrl' => null, | ||
'alreadyPaid' => true, | ||
]); | ||
} | ||
|
||
return $this->paymentLinkRedirectResultFactory->create([ | ||
'redirectUrl' => $this->mollie->startTransaction($order), | ||
'alreadyPaid' => false, | ||
]); | ||
} | ||
} |
Oops, something went wrong.