Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into hotfix/moneiProjects
Browse files Browse the repository at this point in the history
* upstream/main:
  chore: release v1.3.12
  ignore pnp files
  Fix validation card name
  Add language and json style in config
  Validate cardholder name on the frontend with a new reg exp
  chore: release v1.3.11
  update yarn
  Fix error order status
  chore: release v1.3.10
  Remove unnecessary depends
  Fix error save credentials from the admin
  • Loading branch information
moneimagento committed Dec 11, 2024
2 parents 36e0043 + 099d740 commit 9bfa90c
Show file tree
Hide file tree
Showing 21 changed files with 218 additions and 13,880 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
.composer.lock

# Yarn
/build/.pnp.*
/build/.yarn/*
!/build/.yarn/patches
!/build/.yarn/plugins
Expand Down
10 changes: 10 additions & 0 deletions Api/Config/MoneiBizumPaymentModuleConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ interface MoneiBizumPaymentModuleConfigInterface

public const SORT_ORDER = 'payment/monei_bizum/sort_order';

public const JSON_STYLE = 'payment/monei_bizum/json_style';

/**
* Check if payment method is enabled
*
Expand Down Expand Up @@ -63,4 +65,12 @@ public function getSpecificCountries(int $storeId = null): string;
* @return int
*/
public function getSortOrder(int $storeId = null): int;

/**
* Get json style for payment method
*
* @param int|null $storeId
* @return array
*/
public function getJsonStyle(int $storeId = null): array;
}
10 changes: 10 additions & 0 deletions Api/Config/MoneiCardPaymentModuleConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface MoneiCardPaymentModuleConfigInterface

public const SORT_ORDER = 'payment/monei_card/sort_order';

public const JSON_STYLE = 'payment/monei_card/json_style';

/**
* Check if payment method is enabled
*
Expand Down Expand Up @@ -73,4 +75,12 @@ public function getSpecificCountries(int $storeId = null): string;
* @return int
*/
public function getSortOrder(int $storeId = null): int;

/**
* Get json style for payment method
*
* @param int|null $storeId
* @return array
*/
public function getJsonStyle(int $storeId = null): array;
}
10 changes: 10 additions & 0 deletions Api/Config/MoneiGoogleApplePaymentModuleConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ interface MoneiGoogleApplePaymentModuleConfigInterface

public const SORT_ORDER = 'payment/monei_google_apple/sort_order';

public const JSON_STYLE = 'payment/monei_google_apple/json_style';

/**
* Check if payment method is enabled
*
Expand Down Expand Up @@ -83,4 +85,12 @@ public function getSpecificCountries(int $storeId = null): string;
* @return int
*/
public function getSortOrder(int $storeId = null): int;

/**
* Get json style for payment method
*
* @param int|null $storeId
* @return array
*/
public function getJsonStyle(int $storeId = null): array;
}
10 changes: 10 additions & 0 deletions Api/Config/MoneiPaymentModuleConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ interface MoneiPaymentModuleConfigInterface

public const PRODUCTION_API_KEY = 'payment/monei/production_api_key';

public const LANGUAGE = 'payment/monei/language';

public const TITLE = 'payment/monei/title';

public const DESCRIPTION = 'payment/monei/description';
Expand Down Expand Up @@ -135,6 +137,14 @@ public function getTestApiKey($storeId = null): string;
*/
public function getProductionApiKey($storeId = null): string;

/**
* Get language
*
* @param int|null $storeId
* @return string
*/
public function getLanguage(int $storeId = null): string;

/**
* Get payment method title
*
Expand Down
27 changes: 18 additions & 9 deletions Model/CheckoutConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;
use Monei\MoneiPayment\Api\Config\MoneiBizumPaymentModuleConfigInterface;
use Monei\MoneiPayment\Api\Config\MoneiCardPaymentModuleConfigInterface;
use Monei\MoneiPayment\Api\Config\MoneiGoogleApplePaymentModuleConfigInterface;
use Monei\MoneiPayment\Api\Config\MoneiPaymentModuleConfigInterface;
Expand All @@ -32,6 +33,7 @@ class CheckoutConfigProvider implements ConfigProviderInterface
private MoneiPaymentModuleConfigInterface $moneiPaymentConfig;
private MoneiCardPaymentModuleConfigInterface $moneiCardPaymentConfig;
private MoneiGoogleApplePaymentModuleConfigInterface $moneiGoogleApplePaymentConfig;
private MoneiBizumPaymentModuleConfigInterface $moneiBizumPaymentModuleConfig;
private StoreManagerInterface $storeManager;
private IsEnabledGooglePayInMoneiAccount $isEnabledGooglePayInMoneiAccount;
private IsEnabledApplePayInMoneiAccount $isEnabledApplePayInMoneiAccount;
Expand All @@ -41,12 +43,14 @@ public function __construct(
MoneiPaymentModuleConfigInterface $moneiPaymentConfig,
MoneiCardPaymentModuleConfigInterface $moneiCardPaymentConfig,
MoneiGoogleApplePaymentModuleConfigInterface $moneiGoogleApplePaymentConfig,
MoneiBizumPaymentModuleConfigInterface $moneiBizumPaymentModuleConfig,
IsEnabledGooglePayInMoneiAccount $isEnabledGooglePayInMoneiAccount,
IsEnabledApplePayInMoneiAccount $isEnabledApplePayInMoneiAccount,
StoreManagerInterface $storeManager
)
{
$this->moneiGoogleApplePaymentConfig = $moneiGoogleApplePaymentConfig;
$this->moneiBizumPaymentModuleConfig = $moneiBizumPaymentModuleConfig;
$this->moneiCardPaymentConfig = $moneiCardPaymentConfig;
$this->isEnabledGooglePayInMoneiAccount = $isEnabledGooglePayInMoneiAccount;
$this->isEnabledApplePayInMoneiAccount = $isEnabledApplePayInMoneiAccount;
Expand All @@ -57,10 +61,12 @@ public function __construct(

public function getConfig(): array
{
$storeId = $this->getStoreId();
return [
'moneiAccountId' => $this->moneiPaymentConfig->getAccountId($this->getStoreId()),
'moneiApiKey' => $this->moneiPaymentConfig->getApiKey($this->getStoreId()),
'isMoneiTestMode' => $this->moneiPaymentConfig->getMode($this->getStoreId()) === Mode::MODE_TEST,
'moneiAccountId' => $this->moneiPaymentConfig->getAccountId($storeId),
'moneiApiKey' => $this->moneiPaymentConfig->getApiKey($storeId),
'isMoneiTestMode' => $this->moneiPaymentConfig->getMode($storeId) === Mode::MODE_TEST,
'moneiLanguage' => $this->moneiPaymentConfig->getLanguage($storeId),
'payment' => [
Monei::CODE => [
'redirectUrl' => $this->urlBuilder->getUrl('monei/payment/redirect'),
Expand All @@ -81,9 +87,10 @@ public function getConfig(): array
Monei::ORDER_STATUS_CANCELED,
Monei::ORDER_STATUS_FAILED,
],
'accountId' => $this->moneiPaymentConfig->getAccountId($this->getStoreId()),
'isEnabledTokenization' => $this->moneiCardPaymentConfig->isEnabledTokenization($this->getStoreId()),
'accountId' => $this->moneiPaymentConfig->getAccountId($storeId),
'isEnabledTokenization' => $this->moneiCardPaymentConfig->isEnabledTokenization($storeId),
'ccVaultCode' => Monei::CC_VAULT_CODE,
'jsonStyle' => $this->moneiCardPaymentConfig->getJsonStyle($storeId)
],
Monei::BIZUM_CODE => [
'redirectUrl' => $this->urlBuilder->getUrl('monei/payment/redirect'),
Expand All @@ -94,13 +101,14 @@ public function getConfig(): array
Monei::ORDER_STATUS_CANCELED,
Monei::ORDER_STATUS_FAILED,
],
'accountId' => $this->moneiPaymentConfig->getAccountId($this->getStoreId())
'accountId' => $this->moneiPaymentConfig->getAccountId($storeId),
'jsonStyle' =>$this->moneiBizumPaymentModuleConfig->getJsonStyle($storeId)
],
Monei::GOOGLE_APPLE_CODE => [
'isEnabledGooglePay' => $this->isEnabledGooglePayInMoneiAccount->execute(),
'isEnabledApplePay' => $this->isEnabledApplePayInMoneiAccount->execute(),
'googleTitle' => $this->moneiGoogleApplePaymentConfig->getGoogleTitle($this->getStoreId()),
'appleTitle' => $this->moneiGoogleApplePaymentConfig->getAppleTitle($this->getStoreId()),
'googleTitle' => $this->moneiGoogleApplePaymentConfig->getGoogleTitle($storeId),
'appleTitle' => $this->moneiGoogleApplePaymentConfig->getAppleTitle($storeId),
'redirectUrl' => $this->urlBuilder->getUrl('monei/payment/redirect'),
'cancelOrderUrl' => $this->urlBuilder->getUrl('monei/payment/cancel'),
'failOrderUrl' => $this->urlBuilder->getUrl('monei/payment/faillastorderbystatus'),
Expand All @@ -109,7 +117,8 @@ public function getConfig(): array
Monei::ORDER_STATUS_CANCELED,
Monei::ORDER_STATUS_FAILED,
],
'accountId' => $this->moneiPaymentConfig->getAccountId($this->getStoreId())
'accountId' => $this->moneiPaymentConfig->getAccountId($storeId),
'jsonStyle' =>$this->moneiGoogleApplePaymentConfig->getJsonStyle($storeId)
],
],
'vault' => [
Expand Down
14 changes: 14 additions & 0 deletions Model/Config/MoneiBizumPaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,18 @@ public function getSortOrder(int $storeId = null): int
$storeId
);
}

/**
* @inheritDoc
*/
public function getJsonStyle(int $storeId = null): array
{
$result = (string) $this->scopeConfig->getValue(
self::JSON_STYLE,
ScopeInterface::SCOPE_STORE,
$storeId
);

return $result ? json_decode($result, true) : [];
}
}
14 changes: 14 additions & 0 deletions Model/Config/MoneiCardPaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,18 @@ public function getSortOrder(int $storeId = null): int
$storeId
);
}

/**
* @inheritDoc
*/
public function getJsonStyle(int $storeId = null): array
{
$result = (string) $this->scopeConfig->getValue(
self::JSON_STYLE,
ScopeInterface::SCOPE_STORE,
$storeId
);

return $result ? json_decode($result, true) : [];
}
}
14 changes: 14 additions & 0 deletions Model/Config/MoneiGoogleApplePaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,18 @@ public function getSortOrder(int $storeId = null): int
$storeId
);
}

/**
* @inheritDoc
*/
public function getJsonStyle(int $storeId = null): array
{
$result = (string) $this->scopeConfig->getValue(
self::JSON_STYLE,
ScopeInterface::SCOPE_STORE,
$storeId
);

return $result ? json_decode($result, true) : [];
}
}
12 changes: 12 additions & 0 deletions Model/Config/MoneiPaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ public function getProductionApiKey($storeId = null): string
);
}

/**
* @inheritDoc
*/
public function getLanguage(int $storeId = null): string
{
return (string) $this->scopeConfig->getValue(
self::LANGUAGE,
ScopeInterface::SCOPE_STORE,
$storeId
);
}

/**
* @inheritDoc
*/
Expand Down
48 changes: 48 additions & 0 deletions Model/Config/Source/Language.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @author Monei Team
* @copyright Copyright © Monei (https://monei.com)
*/

declare(strict_types=1);

namespace Monei\MoneiPayment\Model\Config\Source;

use Magento\Framework\Data\OptionSourceInterface;

/**
* Monei type of payment source model.
*/
class Language implements OptionSourceInterface
{
public const LANGUAGES = [
'en' => 'English',
'es' => 'Spanish',
'ca' => 'Catalan',
'pt' => 'Portuguese',
'de' => 'German',
'it' => 'Italian',
'fr' => 'French',
'nl' => 'Dutch',
'et' => 'Estonian',
'fi' => 'Finnish',
'lv' => 'Latvian',
'no' => 'Norwegian',
'pl' => 'Polish',
'ru' => 'Russian',
];

/**
* @inheritDoc
*/
public function toOptionArray(): array
{
$options = [];
foreach (self::LANGUAGES as $key => $value) {
$options[] = ['label' => __($value), 'value' => $key];
}

return $options;
}
}
Loading

0 comments on commit 9bfa90c

Please sign in to comment.