-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/mag 565 #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v4.6.1
Are you sure you want to change the base?
Feature/mag 565 #325
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Payplug\Payments\Observer; | ||
|
|
||
| use Magento\Framework\Event\ObserverInterface; | ||
| use Magento\Framework\Event\Observer; | ||
| use Payplug\Payments\Service\InitEnvQa; | ||
|
|
||
| class InitEnvQaOnFrontDispatch implements ObserverInterface | ||
| { | ||
| public function __construct( | ||
| private readonly InitEnvQa $initEnvQa | ||
| ) { | ||
| } | ||
|
|
||
| public function execute(Observer $observer): void | ||
| { | ||
| $this->initEnvQa->execute(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Payplug\Payments\Plugin; | ||
|
|
||
| use Magento\Framework\App\RequestInterface as Request; | ||
| use Magento\Webapi\Controller\Rest; | ||
| use Payplug\Payments\Service\InitEnvQa; | ||
|
|
||
| class InitEnvQaOnRestDispatch | ||
| { | ||
| public function __construct( | ||
| private readonly InitEnvQa $initEnvQa | ||
| ) { | ||
| } | ||
|
|
||
| public function beforeDispatch(Rest $subject, Request $request): array | ||
| { | ||
| $this->initEnvQa->execute(); | ||
|
|
||
| return [$request]; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Payplug\Payments\Service; | ||
|
|
||
| use Magento\Framework\App\Config\ScopeConfigInterface; | ||
| use Payplug\Core\APIRoutes as BaseAPIRoutes; | ||
|
|
||
| class InitEnvQa | ||
| { | ||
| public const XML_PATH_ENABLE_QA = 'payplug_payments/qa/enable'; | ||
| private const XML_PATH_PAYPLUG_API_URL_KEY = 'payplug_payments/qa/api_url'; | ||
| private const XML_PATH_PAYPLUG_SERVICE_URL_KEY = 'payplug_payments/qa/service_url'; | ||
|
|
||
| public function __construct( | ||
| private readonly ScopeConfigInterface $scopeConfig | ||
| ) { | ||
| } | ||
|
|
||
| public function execute(): bool | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Version with additional optims :
|
||
| { | ||
| $apiUrl = $this->scopeConfig->getValue(self::XML_PATH_PAYPLUG_API_URL_KEY); | ||
| $serviceUrl = $this->scopeConfig->getValue(self::XML_PATH_PAYPLUG_SERVICE_URL_KEY); | ||
|
|
||
| if ($this->isQaEnabled() === false || empty($apiUrl) || empty($serviceUrl)) { | ||
| return false; | ||
| } | ||
|
|
||
| BaseAPIRoutes::setApiBaseUrl($apiUrl); | ||
| BaseAPIRoutes::setServiceBaseUrl($serviceUrl); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| public function isQaEnabled(): bool | ||
| { | ||
| return $this->scopeConfig->isSetFlag(self::XML_PATH_ENABLE_QA); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?php | ||
|
|
||
| namespace Payplug\Payments\ViewModel; | ||
|
|
||
| use Magento\Framework\App\Config\ScopeConfigInterface; | ||
| use Magento\Framework\View\Element\Block\ArgumentInterface; | ||
| use Magento\Store\Model\ScopeInterface; | ||
| use Payplug\Payments\Service\InitEnvQa; | ||
|
|
||
| class UrlProvider implements ArgumentInterface | ||
| { | ||
| private const XML_PATH_PAYPLUG_SECURE_URL_KEY = 'payplug_payments/qa/secure_url'; | ||
| private const XML_PATH_PAYPLUG_INTEGRATED_PAYMENT_JS_URL_KEY = 'payplug_payments/qa/integrated_payment_js_url'; | ||
| private const DEFAULT_SECURE_URL = 'https://secure.payplug.com'; | ||
| private const DEFAULT_INTEGRATED_PAYMENT_JS_URL = 'https://cdn.payplug.com/js/integrated-payment/v1/index'; | ||
| private const APPLEPAY_SDK_URL = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js'; | ||
|
|
||
| public function __construct( | ||
| private readonly ScopeConfigInterface $scopeConfig, | ||
| private readonly InitEnvQa $initEnvQa | ||
| ) { | ||
| } | ||
|
|
||
| public function getPayplugSecureUrl(): string | ||
| { | ||
| $customSecureUrl = $this->scopeConfig->getValue(self::XML_PATH_PAYPLUG_SECURE_URL_KEY); | ||
|
|
||
| if ($this->initEnvQa->isQaEnabled() === true && $customSecureUrl) { | ||
| return $customSecureUrl; | ||
| } | ||
|
|
||
| return self::DEFAULT_SECURE_URL; | ||
| } | ||
|
|
||
| public function getPayplugIntegratedPaymentJsUrl(): string | ||
| { | ||
| $customIntegratedPaymentJsUrl = $this->scopeConfig->getValue(self::XML_PATH_PAYPLUG_INTEGRATED_PAYMENT_JS_URL_KEY); | ||
|
|
||
| if ($this->initEnvQa->isQaEnabled() === true && $customIntegratedPaymentJsUrl) { | ||
| return $customIntegratedPaymentJsUrl; | ||
| } | ||
|
|
||
| return self::DEFAULT_INTEGRATED_PAYMENT_JS_URL; | ||
| } | ||
|
|
||
| public function isApplePayEnabled(): bool | ||
| { | ||
| return $this->scopeConfig->isSetFlag('payment/payplug_payments_apple_pay/active', ScopeInterface::SCOPE_STORE); | ||
| } | ||
|
|
||
| public function getApplePaySdkUrl(): string | ||
| { | ||
| return self::APPLEPAY_SDK_URL; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,13 @@ | |
| <field id="client_data"/> | ||
| <field id="access_token_data"/> | ||
| </group> | ||
| <group id="qa"> | ||
| <field id="enable"/> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a |
||
| <field id="api_url"/> | ||
| <field id="service_url"/> | ||
| <field id="secure_url"/> | ||
| <field id="integrated_payment_js_url"/> | ||
| </group> | ||
| </section> | ||
| <section id="payment" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1"> | ||
| <group id="payplug_payments_standard" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| <observer name="payplug_payments_section_payment_saved" instance="Payplug\Payments\Observer\PaymentConfigObserver"/> | ||
| </event> | ||
| <event name="controller_action_predispatch"> | ||
| <observer name="payplug_payments_init_env_qa_on_front_dispatch" instance="Payplug\Payments\Observer\InitEnvQaOnFrontDispatch" /> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a huge fan of doing this on every request. Could we be more precise and specific (maybe only on certain layout handles and mandatory ones?) |
||
| <observer name="payplug_payments_display_notice" instance="Payplug\Payments\Observer\DisplayNoticeObserver" /> | ||
| </event> | ||
| <event name="controller_action_predispatch_sales_order_creditmemo_new"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
| <type name="Magento\Webapi\Controller\Rest"> | ||
| <plugin name="payplug_payments_init_env_qa_on_rest_dispatch" type="Payplug\Payments\Plugin\InitEnvQaOnRestDispatch"/> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a huge fan of doing this on every request. Could we be more precise and specific ? |
||
| </type> | ||
| </config> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,11 @@ | |
| xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
| <body> | ||
| <referenceBlock name="head.components"> | ||
| <block class="Payplug\Payments\Block\Formjs" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"/> | ||
| <block class="Magento\Framework\View\Element\Template" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <arguments> | ||
| <argument name="urlProviderViewModel" xsi:type="object">Payplug\Payments\ViewModel\UrlProvider</argument> | ||
| </arguments> | ||
| </block> | ||
| </referenceBlock> | ||
|
|
||
| <referenceContainer name="product.info.form.content"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,11 @@ | |
| <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
| <body> | ||
| <referenceBlock name="head.components"> | ||
| <block class="Payplug\Payments\Block\Formjs" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"/> | ||
| <block class="Magento\Framework\View\Element\Template" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <arguments> | ||
| <argument name="urlProviderViewModel" xsi:type="object">Payplug\Payments\ViewModel\UrlProvider</argument> | ||
| </arguments> | ||
| </block> | ||
| </referenceBlock> | ||
|
|
||
| <referenceContainer name="checkout.cart.totals.container"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,11 @@ | |
| <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
| <body> | ||
| <referenceBlock name="head.components"> | ||
| <block class="Payplug\Payments\Block\Formjs" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"/> | ||
| <block class="Magento\Framework\View\Element\Template" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <arguments> | ||
| <argument name="urlProviderViewModel" xsi:type="object">Payplug\Payments\ViewModel\UrlProvider</argument> | ||
| </arguments> | ||
| </block> | ||
| </referenceBlock> | ||
| <referenceBlock name="checkout.root"> | ||
| <arguments> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,11 @@ | |
| <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
| <body> | ||
| <referenceBlock name="head.components"> | ||
| <block class="Payplug\Payments\Block\Formjs" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"/> | ||
| <block class="Magento\Framework\View\Element\Template" name="payplug_payments_formjs" template="Payplug_Payments::checkout/formjs.phtml"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <arguments> | ||
| <argument name="urlProviderViewModel" xsi:type="object">Payplug\Payments\ViewModel\UrlProvider</argument> | ||
| </arguments> | ||
| </block> | ||
| </referenceBlock> | ||
| </body> | ||
| </page> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null;