-
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.
Merge pull request #420 from mollie/1.29.0
1.29.0
- Loading branch information
Showing
13 changed files
with
271 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\GraphQL\Resolver\Checkout; | ||
|
||
use Magento\Checkout\Model\Session; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
use Mollie\Api\Types\PaymentStatus; | ||
use Mollie\Payment\Api\PaymentTokenRepositoryInterface; | ||
use Mollie\Payment\Model\Mollie; | ||
|
||
class ProcessTransaction implements ResolverInterface | ||
{ | ||
/** | ||
* @var Mollie | ||
*/ | ||
private $mollie; | ||
|
||
/** | ||
* @var PaymentTokenRepositoryInterface | ||
*/ | ||
private $paymentTokenRepository; | ||
|
||
/** | ||
* @var CartRepositoryInterface | ||
*/ | ||
private $cartRepository; | ||
|
||
/** | ||
* @var Session | ||
*/ | ||
private $checkoutSession; | ||
|
||
public function __construct( | ||
Mollie $mollie, | ||
PaymentTokenRepositoryInterface $paymentTokenRepository, | ||
CartRepositoryInterface $cartRepository, | ||
Session $checkoutSession | ||
) { | ||
$this->mollie = $mollie; | ||
$this->paymentTokenRepository = $paymentTokenRepository; | ||
$this->cartRepository = $cartRepository; | ||
$this->checkoutSession = $checkoutSession; | ||
} | ||
|
||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) | ||
{ | ||
if (!isset($args['input']['payment_token'])) { | ||
throw new GraphQlInputException(__('Missing "payment_token" input argument')); | ||
} | ||
|
||
$token = $args['input']['payment_token']; | ||
$tokenModel = $this->paymentTokenRepository->getByToken($token); | ||
|
||
$result = $this->mollie->processTransaction($tokenModel->getOrderId(), 'success', $token); | ||
|
||
if (isset($result['error'])) { | ||
return ['paymentStatus' => 'ERROR']; | ||
} | ||
|
||
return [ | ||
'paymentStatus' => strtoupper($result['status']), | ||
'cart' => $this->getCart($result['status'], $tokenModel->getCartId()), | ||
]; | ||
} | ||
|
||
private function getCart(string $status, ?string $cartId): ?array | ||
{ | ||
if (!$cartId || !in_array($status, [ | ||
PaymentStatus::STATUS_EXPIRED, | ||
PaymentStatus::STATUS_CANCELED, | ||
PaymentStatus::STATUS_FAILED, | ||
])) { | ||
return null; | ||
} | ||
|
||
try { | ||
$this->checkoutSession->restoreQuote(); | ||
|
||
return ['model' => $this->cartRepository->get($cartId)]; | ||
} catch (NoSuchEntityException $exception) { | ||
return null; | ||
} | ||
} | ||
} |
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
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,47 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Block\\\\Info\\\\Base\\:\\:getOrderId\\(\\) should return string but return statement is missing\\.$#" | ||
count: 1 | ||
path: Block/Info/Base.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Process\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#" | ||
count: 1 | ||
path: Controller/Checkout/Process.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Redirect\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#" | ||
count: 1 | ||
path: Controller/Checkout/Redirect.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Restart\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#" | ||
count: 1 | ||
path: Controller/Checkout/Restart.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Success\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#" | ||
count: 1 | ||
path: Controller/Checkout/Success.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Helper\\\\General\\:\\:getBanktransferDueDate\\(\\) should return string\\|false but return statement is missing\\.$#" | ||
count: 1 | ||
path: Helper/General.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Model\\\\Adminhtml\\\\Backend\\\\VerifiyPaymentFee\\:\\:beforeSave\\(\\) should return \\$this\\(Mollie\\\\Payment\\\\Model\\\\Adminhtml\\\\Backend\\\\VerifiyPaymentFee\\) but return statement is missing\\.$#" | ||
count: 1 | ||
path: Model/Adminhtml/Backend/VerifiyPaymentFee.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Model\\\\Methods\\\\Reorder\\:\\:initialize\\(\\) should return \\$this\\(Mollie\\\\Payment\\\\Model\\\\Methods\\\\Reorder\\) but return statement is missing\\.$#" | ||
count: 1 | ||
path: Model/Methods/Reorder.php | ||
|
||
- | ||
message: "#^Method Mollie\\\\Payment\\\\Model\\\\Mollie\\:\\:createOrderRefund\\(\\) should return \\$this\\(Mollie\\\\Payment\\\\Model\\\\Mollie\\) but return statement is missing\\.$#" | ||
count: 1 | ||
path: Model/Mollie.php | ||
|
Oops, something went wrong.