22
33namespace Afterpay \Afterpay \Model ;
44
5+ use Afterpay \Afterpay \Model \FeatureFlag \Service \GetCreditMemoOnGrandTotalEnabled ;
56use Magento \Framework \App \Config \ScopeConfigInterface ;
67use Magento \Framework \App \Config \Storage \WriterInterface ;
78use Magento \Framework \App \ResourceConnection ;
1011
1112class Config
1213{
13-
1414 public const XML_PATH_PAYMENT_ACTIVE = 'payment/afterpay/active ' ;
1515 public const XML_PATH_API_MODE = 'payment/afterpay/api_mode ' ;
1616 public const XML_PATH_DEBUG = 'payment/afterpay/debug ' ;
@@ -28,11 +28,9 @@ class Config
2828 public const XML_PATH_MAX_LIMIT = 'payment/afterpay/max_order_total ' ;
2929 public const XML_PATH_CBT_CURRENCY_LIMITS = 'payment/afterpay/cbt_currency_limits ' ;
3030 public const XML_PATH_EXCLUDE_CATEGORIES = 'payment/afterpay/exclude_categories ' ;
31- public const XML_PATH_ALLOW_SPECIFIC_COUNTRIES = 'payment/afterpay/allowspecific ' ;
3231 public const XML_PATH_SPECIFIC_COUNTRIES = 'payment/afterpay/specificcountry ' ;
3332 public const XML_PATH_ALLOWED_MERCHANT_COUNTRIES = 'payment/afterpay/allowed_merchant_countries ' ;
3433 public const XML_PATH_ALLOWED_MERCHANT_CURRENCIES = 'payment/afterpay/allowed_merchant_currencies ' ;
35- public const XML_PATH_PAYPAL_MERCHANT_COUNTRY = 'paypal/general/merchant_country ' ;
3634 public const XML_PATH_ENABLE_REVERSAL = 'payment/afterpay/enable_reversal ' ;
3735 public const XML_PATH_MPID = 'payment/afterpay/public_id ' ;
3836 public const XML_PATH_CASHAPP_PAY_AVAILABLE = 'payment/afterpay/cash_app_pay_available ' ;
@@ -53,22 +51,24 @@ class Config
5351 public const XML_PATH_CART_PAGE_PLACEMENT_AFTER_SELECTOR = 'payment/afterpay/cart_page_placement_after_selector ' ;
5452 public const XML_PATH_CART_PAGE_PLACEMENT_PRICE_SELECTOR = 'payment/afterpay/cart_page_placement_price_selector ' ;
5553
56-
5754 private ScopeConfigInterface $ scopeConfig ;
5855 private WriterInterface $ writer ;
5956 private ResourceConnection $ resourceConnection ;
6057 private SerializerInterface $ serializer ;
58+ private GetCreditMemoOnGrandTotalEnabled $ getCreditMemoOnGrandTotalEnabledService ;
6159
6260 public function __construct (
63- ScopeConfigInterface $ scopeConfig ,
64- WriterInterface $ writer ,
65- ResourceConnection $ resourceConnection ,
66- SerializerInterface $ serializer
61+ ScopeConfigInterface $ scopeConfig ,
62+ WriterInterface $ writer ,
63+ ResourceConnection $ resourceConnection ,
64+ SerializerInterface $ serializer ,
65+ GetCreditMemoOnGrandTotalEnabled $ getCreditMemoOnGrandTotalEnabledService
6766 ) {
6867 $ this ->scopeConfig = $ scopeConfig ;
6968 $ this ->writer = $ writer ;
7069 $ this ->resourceConnection = $ resourceConnection ;
7170 $ this ->serializer = $ serializer ;
71+ $ this ->getCreditMemoOnGrandTotalEnabledService = $ getCreditMemoOnGrandTotalEnabledService ;
7272 }
7373
7474 public function getIsPaymentActive (?int $ scopeCode = null ): bool
@@ -586,7 +586,10 @@ public function getAddLastSelectedShipRate(?int $scopeCode = null): bool
586586 public function getIsCreditMemoGrandTotalOnlyEnabled (?int $ websiteId = null , bool $ fromApi = false ): bool
587587 {
588588 if ($ fromApi ) {
589- $ flagValue = false ; // TODO: replace it with a flag pull
589+ $ flagValue = $ this ->getCreditMemoOnGrandTotalEnabledService ->execute (
590+ $ this ->getPublicId ($ websiteId ),
591+ $ this ->getMerchantCountry (ScopeInterface::SCOPE_WEBSITES , $ websiteId )
592+ );
590593 $ this ->setIsCreditMemoGrandTotalOnlyEnabled ((int )$ flagValue , $ websiteId );
591594
592595 return $ flagValue ;
0 commit comments