Skip to content

Commit 01a66e8

Browse files
committed
Release 2.0.6
1 parent 1701ee1 commit 01a66e8

19 files changed

+225
-17
lines changed

Api/OrderRepositoryInterface.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* PostFinance Checkout Magento 2
4+
*
5+
* This Magento 2 extension enables to process payments with PostFinance Checkout (https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html/).
6+
*
7+
* @package PostFinanceCheckout_Payment
8+
* @author wallee AG (http://www.wallee.com/)
9+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0)
10+
*/
11+
namespace PostFinanceCheckout\Payment\Api;
12+
13+
use Magento\Sales\Api\Data\OrderInterface;
14+
15+
/**
16+
* Interface for PostFinance Checkout order data.
17+
*
18+
* @api
19+
*/
20+
interface OrderRepositoryInterface
21+
{
22+
23+
/**
24+
* Get order by Order Increment Id
25+
*
26+
* @param $incrementId
27+
* @return OrderInterface|null
28+
*/
29+
public function getOrderByIncrementId($incrementId);
30+
}

Model/OrderRepository.php

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
/**
3+
* PostFinance Checkout Magento 2
4+
*
5+
* This Magento 2 extension enables to process payments with PostFinance Checkout (https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html/).
6+
*
7+
* @package PostFinanceCheckout_Payment
8+
* @author wallee AG (http://www.wallee.com/)
9+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0)
10+
*/
11+
namespace PostFinanceCheckout\Payment\Model;
12+
13+
use Exception;
14+
use Magento\Framework\Api\FilterBuilder;
15+
use Magento\Framework\Api\Search\FilterGroupBuilder;
16+
use Magento\Framework\Api\SearchCriteriaBuilder;
17+
use Magento\Sales\Api\Data\OrderInterface;
18+
use Magento\Sales\Api\OrderRepositoryInterface as BaseOrderRepositoryInterface;
19+
use Psr\Log\LoggerInterface;
20+
use PostFinanceCheckout\Payment\Api\OrderRepositoryInterface;
21+
22+
class OrderRepository implements OrderRepositoryInterface
23+
{
24+
/**
25+
* @var FilterBuilder
26+
*/
27+
protected $filterBuilder;
28+
29+
/**
30+
* @var FilterGroupBuilder
31+
*/
32+
protected $filterGroupBuilder;
33+
34+
/**
35+
* @var SearchCriteriaBuilder
36+
*/
37+
protected $searchCriteriaBuilder;
38+
39+
/**
40+
* @var BaseOrderRepositoryInterface
41+
*/
42+
private $orderRepository;
43+
44+
/**
45+
* @var LoggerInterface
46+
*/
47+
private $logger;
48+
49+
/**
50+
*
51+
* @param SearchCriteriaBuilder $searchCriteriaBuilder
52+
* @param BaseOrderRepositoryInterface $orderRepository
53+
* @param FilterBuilder $filterBuilder
54+
* @param FilterGroupBuilder $filterGroupBuilder
55+
* @param LoggerInterface $logger
56+
*/
57+
public function __construct(
58+
SearchCriteriaBuilder $searchCriteriaBuilder,
59+
BaseOrderRepositoryInterface $orderRepository,
60+
FilterBuilder $filterBuilder,
61+
FilterGroupBuilder $filterGroupBuilder,
62+
LoggerInterface $logger
63+
) {
64+
$this->filterBuilder = $filterBuilder;
65+
$this->filterGroupBuilder = $filterGroupBuilder;
66+
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
67+
$this->orderRepository = $orderRepository;
68+
$this->logger = $logger;
69+
}
70+
71+
/**
72+
* Get Order data by Order Increment Id
73+
*
74+
* @param $incrementId
75+
* @return OrderInterface|null
76+
*/
77+
public function getOrderByIncrementId($incrementId)
78+
{
79+
$orderData = null;
80+
81+
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
82+
$searchCriteriaBuilder = $this->searchCriteriaBuilder;
83+
84+
/** @var FilterBuilder $filterBuilder */
85+
$filterBuilder = $this->filterBuilder;
86+
87+
/** @var FilterGroupBuilder $filterGroupBuilder */
88+
$filterGroupBuilder = $this->filterGroupBuilder;
89+
90+
$filter = $filterBuilder
91+
->setField('increment_id')
92+
->setValue($incrementId)
93+
->setConditionType('eq')
94+
->create();
95+
96+
$filterGroup = $filterGroupBuilder
97+
->addFilter($filter)
98+
->create();
99+
100+
$searchCriteriaBuilder->setFilterGroups([$filterGroup]);
101+
$searchCriteriaBuilder->setPageSize(1);
102+
$searchCriteria = $searchCriteriaBuilder->create();
103+
104+
try {
105+
$orderList = $this->orderRepository->getList($searchCriteria);
106+
if ($orderList->getTotalCount() > 0) {
107+
$items = $orderList->getItems();
108+
$orderData = reset($items);
109+
}
110+
} catch (Exception $exception) {
111+
$this->logger->critical($exception->getMessage());
112+
}
113+
return $orderData;
114+
}
115+
}

Model/Resolver/CustomerOrderTransactionSettings.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
2222
use Magento\Customer\Model\Session;
2323
use Magento\GraphQl\Model\Query\ContextInterface;
24-
use Magento\Sales\Api\OrderRepositoryInterface;
24+
use PostFinanceCheckout\Payment\Api\OrderRepositoryInterface;
2525
use Psr\Log\LoggerInterface;
2626
use PostFinanceCheckout\Payment\Model\Service\Quote\TransactionService as TransactionQuoteService;
2727
use PostFinanceCheckout\Payment\Model\Service\Order\TransactionService as TransactionOrderService;
@@ -124,7 +124,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
124124
private function getTransactionSettings(int $orderId, string $integrationType)
125125
{
126126
/** @var \Magento\Sales\Model\Order $order */
127-
$order = $this->orderRepository->get($orderId);
127+
$order = $this->orderRepository->getOrderByIncrementId($orderId);
128128
$transaction = $this->transactionQuoteService->getTransaction(
129129
$order->getPostfinancecheckoutSpaceId(),
130130
$order->getPostfinancecheckoutTransactionId()

Model/Service/Order/TransactionService.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
*/
6262
class TransactionService extends AbstractTransactionService
6363
{
64+
/**
65+
* Number of attempts to call the portal API
66+
*/
67+
const NUMBER_OF_ATTEMPTS = 3;
6468

6569
/**
6670
*
@@ -184,7 +188,7 @@ public function confirmTransaction(Transaction $transaction, Order $order, Invoi
184188
$spaceId = $order->getPostfinancecheckoutSpaceId();
185189
$transactionId = $order->getPostfinancecheckoutTransactionId();
186190

187-
for ($i = 0; $i < 5; $i ++) {
191+
for ($i = 0; $i < self::NUMBER_OF_ATTEMPTS; $i ++) {
188192
try {
189193
if ($i > 0) {
190194
$transaction = $this->getTransaction($spaceId, $transactionId);

Model/Service/Quote/TransactionService.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
*/
4848
class TransactionService extends AbstractTransactionService
4949
{
50+
/**
51+
* Number of attempts to call the portal API
52+
*/
53+
const NUMBER_OF_ATTEMPTS = 3;
5054

5155
/**
5256
*
@@ -357,7 +361,7 @@ private function createTransactionByQuote(Quote $quote)
357361
*/
358362
private function updateTransactionByQuote(Quote $quote)
359363
{
360-
for ($i = 0; $i < 5; $i ++) {
364+
for ($i = 0; $i < self::NUMBER_OF_ATTEMPTS; $i ++) {
361365
try {
362366
$spaceId = $this->scopeConfig->getValue('postfinancecheckout_payment/general/space_id',
363367
ScopeInterface::SCOPE_STORE, $quote->getStoreId());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace PostFinanceCheckout\Payment\Plugin\QuoteGraphQl\Model\Cart;
4+
5+
use Magento\Authorization\Model\UserContextInterface;
6+
use Magento\Framework\Exception\NoSuchEntityException;
7+
use Magento\Quote\Api\CartManagementInterface;
8+
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser as OriginalGetCartForUser;
9+
use Psr\Log\LoggerInterface;
10+
11+
class GetCartForUser
12+
{
13+
/**
14+
* @var UserContextInterface
15+
*/
16+
private $userContext;
17+
18+
/**
19+
*
20+
* @var CartManagementInterface
21+
*/
22+
private $cartManagement;
23+
24+
/**
25+
*
26+
* @var LoggerInterface
27+
*/
28+
protected $logger;
29+
30+
public function __construct(
31+
UserContextInterface $userContext,
32+
CartManagementInterface $cartManagement,
33+
LoggerInterface $logger
34+
) {
35+
$this->userContext = $userContext;
36+
$this->cartManagement = $cartManagement;
37+
$this->logger = $logger;
38+
}
39+
40+
public function aroundExecute(OriginalGetCartForUser $subject, callable $proceed, $userId)
41+
{
42+
try {
43+
//call the original method using $proceed to get the result.
44+
$result = $proceed($userId);
45+
} catch (NoSuchEntityException $e) {
46+
//handle any exceptions occurring in the main class
47+
$cartId = $result = $this->cartManagement->createEmptyCartForCustomer($userId);
48+
$this->logger->debug("GET-CART-FOR-USER-INTERCEPTOR::aroundExecute - Cart was created: customer id:" . $userId);
49+
$this->logger->debug("GET-CART-FOR-USER-INTERCEPTOR::aroundExecute - Cart was created: cart id:" . $cartId);
50+
}
51+
52+
return $result;
53+
}
54+
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repository contains the Magento 2 extension that enables to process payment
1212

1313
## Documentation
1414

15-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html)
15+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html)
1616

1717

1818
## Support
@@ -30,4 +30,4 @@ We do provide special integrations for the following one step checkouts:
3030

3131
## License
3232

33-
Please see the [license file](https://github.com/pfpayments/magento-2/blob/2.0.5/LICENSE) for more information.
33+
Please see the [license file](https://github.com/pfpayments/magento-2/blob/2.0.6/LICENSE) for more information.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"type" : "magento2-module",
19-
"version" : "2.0.5",
19+
"version" : "2.0.6",
2020
"require" : {
2121
"php" : "~7.1.3||~7.2.0||~7.3.0||~7.4.0||~8.0||~8.1",
2222
"magento/framework" : "^102.0.0||^103.0.0",

docs/en/documentation.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
2222
</a>
2323
</li>
2424
<li>
25-
<a href="https://github.com/pfpayments/magento-2/releases/tag/2.0.5/">
25+
<a href="https://github.com/pfpayments/magento-2/releases/tag/2.0.6/">
2626
Source
2727
</a>
2828
</li>

etc/adminhtml/system.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<resource>PostFinanceCheckout_Payment::config</resource>
1919
<group id="information" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2020
<label>Information</label>
21-
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
21+
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
2222
<field id="version" translate="label" type="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2323
<label>Module Version</label>
2424
</field>

etc/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<default>
1515
<postfinancecheckout_payment>
1616
<information>
17-
<version>2.0.5</version>
17+
<version>2.0.6</version>
1818
<sdk_version>3.2.0</sdk_version>
1919
</information>
2020
<general>

etc/di.xml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<preference for="PostFinanceCheckout\Payment\Api\PaymentMethodConfigurationManagementInterface" type="PostFinanceCheckout\Payment\Model\PaymentMethodConfigurationManagement" />
1616
<preference for="PostFinanceCheckout\Payment\Api\Data\PaymentMethodConfigurationInterface" type="PostFinanceCheckout\Payment\Model\PaymentMethodConfiguration" />
1717
<preference for="PostFinanceCheckout\Payment\Api\Data\PaymentMethodConfigurationSearchResultsInterface" type="Magento\Framework\Api\SearchResults" />
18+
<preference for="PostFinanceCheckout\Payment\Api\OrderRepositoryInterface" type="PostFinanceCheckout\Payment\Model\OrderRepository" />
1819
<preference for="PostFinanceCheckout\Payment\Api\TransactionInfoRepositoryInterface" type="PostFinanceCheckout\Payment\Model\TransactionInfoRepository" />
1920
<preference for="PostFinanceCheckout\Payment\Api\TransactionInfoManagementInterface" type="PostFinanceCheckout\Payment\Model\TransactionInfoManagement" />
2021
<preference for="PostFinanceCheckout\Payment\Api\Data\TransactionInfoInterface" type="PostFinanceCheckout\Payment\Model\TransactionInfo" />

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
-->
1313
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
14-
<module name="PostFinanceCheckout_Payment" setup_version="2.0.5">
14+
<module name="PostFinanceCheckout_Payment" setup_version="2.0.6">
1515
<sequence>
1616
<module name="Magento_Sales"/>
1717
<module name="Magento_Payment"/>

i18n/de_DE.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Geschenkverpackung"
5151
"Hold Delivery","Lieferung halten"
5252
"ID required","ID erforderlich"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
53+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
5454
"Inactive","Inaktiv"
5555
"Information","Informationen"
5656
"Invoice","Rechnung"

i18n/en_US.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Gift Wrap"
5151
"Hold Delivery","Hold Delivery"
5252
"ID required","ID required"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>."
53+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>."
5454
"Inactive","Inactive"
5555
"Information","Information"
5656
"Invoice","Invoice"

i18n/fr_CH.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"

i18n/fr_FR.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"

i18n/it_CH.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5454
"Inactive","Inattivo"
5555
"Information","Informazione"
5656
"Invoice","Fattura"

i18n/it_IT.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.5/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.0.6/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5454
"Inactive","Inattivo"
5555
"Information","Informazione"
5656
"Invoice","Fattura"

0 commit comments

Comments
 (0)