Skip to content

Commit

Permalink
Merge pull request #514 from mollie/release/2.10.0
Browse files Browse the repository at this point in the history
Release/2.10.0
  • Loading branch information
Marvin-Magmodules authored Apr 14, 2022
2 parents d0a8faa + 3fdf96b commit 389f21e
Show file tree
Hide file tree
Showing 12 changed files with 998 additions and 687 deletions.
6 changes: 3 additions & 3 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getApiKey($storeId = null)
}

if (!$this->isProductionMode($storeId)) {
$apiKey = trim($this->getPath(static::GENERAL_APIKEY_TEST, $storeId));
$apiKey = trim($this->getPath(static::GENERAL_APIKEY_TEST, $storeId) ?? '');
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (test modus)');
}
Expand All @@ -186,7 +186,7 @@ public function getApiKey($storeId = null)
return $decryptedApiKey;
}

$apiKey = trim($this->getPath(static::GENERAL_APIKEY_LIVE, $storeId));
$apiKey = trim($this->getPath(static::GENERAL_APIKEY_LIVE, $storeId) ?? '');
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (live modus)');
}
Expand Down Expand Up @@ -628,7 +628,7 @@ private function addMethodToPath($path, $method)
{
return sprintf(
$path,
str_replace('mollie_methods_', '', $method)
str_replace('mollie_methods_', '', $method ?? '')
);
}
}
24 changes: 13 additions & 11 deletions GraphQL/Resolver/Checkout/ProcessTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,34 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value

$result = $this->mollie->processTransaction($tokenModel->getOrderId(), 'success', $token);

if (isset($result['error'])) {
return ['paymentStatus' => 'ERROR'];
$cart = null;
if ($tokenModel->getCartId()) {
$cart = $this->getCart($result['status'], $tokenModel->getCartId());
}

return [
'paymentStatus' => strtoupper($result['status']),
'cart' => $this->getCart($result['status'], $tokenModel->getCartId()),
'cart' => $cart,
];
}

private function getCart(string $status, ?string $cartId): ?array
private function getCart(string $status, string $cartId): ?array
{
if (!$cartId || !in_array($status, [
$restoreCart = in_array($status, [
PaymentStatus::STATUS_EXPIRED,
PaymentStatus::STATUS_CANCELED,
PaymentStatus::STATUS_FAILED,
PaymentStatus::STATUS_PENDING,
])) {
return null;
}
]);

try {
$cart = $this->cartRepository->get($cartId);
$cart->setIsActive(1);
$cart->setReservedOrderId(null);
$this->cartRepository->save($cart);

if ($restoreCart) {
$cart->setIsActive(1);
$cart->setReservedOrderId(null);
$this->cartRepository->save($cart);
}

return ['model' => $cart];
} catch (NoSuchEntityException $exception) {
Expand Down
4 changes: 2 additions & 2 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public function getApiKey($storeId = null)
$modus = $this->getModus($storeId);

if ($modus == 'test') {
$apiKey = trim($this->getStoreConfig(self::XML_PATH_TEST_APIKEY, $storeId));
$apiKey = trim($this->getStoreConfig(self::XML_PATH_TEST_APIKEY, $storeId) ?? '');
if (empty($apiKey)) {
$this->addTolog('error', 'Mollie API key not set (test modus)');
}
Expand All @@ -311,7 +311,7 @@ public function getApiKey($storeId = null)
}
$this->apiKey[$storeId] = $decryptedApiKey;
} else {
$apiKey = trim($this->getStoreConfig(self::XML_PATH_LIVE_APIKEY, $storeId));
$apiKey = trim($this->getStoreConfig(self::XML_PATH_LIVE_APIKEY, $storeId) ?? '');
if (empty($apiKey)) {
$this->addTolog('error', 'Mollie API key not set (live modus)');
}
Expand Down
6 changes: 2 additions & 4 deletions Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getAddressLine($address)
{
return [
'organizationName' => $address->getCompany(),
'title' => trim($address->getPrefix()),
'title' => trim($address->getPrefix() ?? ''),
'givenName' => $address->getFirstname(),
'familyName' => $address->getLastname(),
'email' => $address->getEmail(),
Expand Down Expand Up @@ -334,9 +334,7 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook',
{
$result = $this->processTransaction->execute($order, $type);

return [
'success' => $result->isSuccess(),
];
return $result->toArray();
}

public function orderHasUpdate(OrderInterface $order, MollieApiClient $mollieApi)
Expand Down
2 changes: 1 addition & 1 deletion Service/Mollie/TransactionDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function forRegularTransaction(OrderInterface $order): string
$storeId = $order->getStoreId();
$description = $this->config->paymentMethodDescription($order->getPayment()->getMethod(), $storeId);

if (!trim($description)) {
if (!trim($description ?? '')) {
$description = '{ordernumber}';
}

Expand Down
15 changes: 15 additions & 0 deletions Service/Order/Lines/Generator/AheadworksAddFreeGift.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function __construct(

public function process(OrderInterface $order, array $orderLines): array
{
if (!$this->hasAheadworksFreeGiftItems($order)) {
return $orderLines;
}

$discount = 0;
foreach ($order->getItems() as $item) {
$discount += abs($item->getAwAfptcAmount());
Expand All @@ -48,4 +52,15 @@ public function process(OrderInterface $order, array $orderLines): array

return $orderLines;
}

private function hasAheadworksFreeGiftItems(OrderInterface $order): bool
{
foreach ($order->getItems() as $item) {
if ($item->getAwAfptcAmount() !== null) {
return true;
}
}

return false;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mollie/magento2",
"description": "Mollie Payment Module for Magento 2",
"version": "2.9.0",
"version": "2.10.0",
"keywords": [
"mollie",
"payment",
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<default>
<payment>
<mollie_general>
<version>v2.9.0</version>
<version>v2.10.0</version>
<active>0</active>
<enabled>0</enabled>
<type>test</type>
Expand Down
Loading

0 comments on commit 389f21e

Please sign in to comment.