Skip to content

Commit 84c7638

Browse files
authored
Merge pull request #33 from cmdotcom-plugins/release
Release CBC implementation
2 parents db32001 + 7b8caec commit 84c7638

File tree

9 files changed

+228
-0
lines changed

9 files changed

+228
-0
lines changed

Api/Config/ConfigInterface.php

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface ConfigInterface
3737
public const XML_PATH_PAYMENT_CREDIT_CARD_ALLOWED_TYPES = 'payment/cm_payments_creditcard/allowed_cctypes';
3838
public const XML_PATH_PAYMENT_BANCONTACT_PROFILE = 'payment/cm_payments_bancontact/profile';
3939
public const XML_PATH_PAYMENT_BELFIUS_PROFILE = 'payment/cm_payments_belfius/profile';
40+
public const XML_PATH_PAYMENT_CBC_PROFILE = 'payment/cm_payments_cbc/profile';
4041
public const XML_PATH_PAYMENT_KBC_PROFILE = 'payment/cm_payments_kbc/profile';
4142
public const XML_PATH_PAYMENT_AFTERPAY_PROFILE = 'payment/cm_payments_afterpay/profile';
4243
public const XML_PATH_PAYMENT_APPLEPAY_PROFILE = 'payment/cm_payments_applepay/profile';
@@ -140,6 +141,14 @@ public function getBelfiusPaymentProfile(): ?string;
140141
*/
141142
public function getKbcPaymentProfile(): ?string;
142143

144+
/**
145+
* Get Payment Profile for CBC Method
146+
*
147+
* @return ?string
148+
* @throws NoSuchEntityException
149+
*/
150+
public function getCbcPaymentProfile(): ?string;
151+
143152
/**
144153
* Get Payment Profile for AfterPay Method
145154
*

Api/Service/MethodServiceInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface MethodServiceInterface
3030
ConfigProvider::CODE_BANCONTACT,
3131
ConfigProvider::CODE_BELFIUS,
3232
ConfigProvider::CODE_KBC,
33+
ConfigProvider::CODE_CBC,
3334
ConfigProvider::CODE_ELV,
3435
ConfigProvider::CODE_KLARNA,
3536
ConfigProvider::CODE_AFTERPAY,
@@ -50,6 +51,7 @@ interface MethodServiceInterface
5051
'BANCONTACT' => ConfigProvider::CODE_BANCONTACT,
5152
'BELFIUS' => ConfigProvider::CODE_BELFIUS,
5253
'KBC' => ConfigProvider::CODE_KBC,
54+
'CBC' => ConfigProvider::CODE_CBC,
5355
'ELV' => ConfigProvider::CODE_ELV,
5456
'KLARNA' => ConfigProvider::CODE_KLARNA,
5557
'AFTERPAY_OPEN_INVOICE' => ConfigProvider::CODE_AFTERPAY,

Config/Config.php

+15
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ public function getPaymentProfile(string $paymentMethod = null): string
247247
case ConfigProvider::CODE_KBC:
248248
$paymentMethodProfile = $this->getKbcPaymentProfile() ?? $defaultPaymentMethodProfile;
249249
break;
250+
case ConfigProvider::CODE_CBC:
251+
$paymentMethodProfile = $this->getCbcPaymentProfile() ?? $defaultPaymentMethodProfile;
252+
break;
250253
case ConfigProvider::CODE_AFTERPAY:
251254
$paymentMethodProfile = $this->getAfterPayPaymentProfile() ?? $defaultPaymentMethodProfile;
252255
break;
@@ -328,6 +331,18 @@ public function getKbcPaymentProfile(): ?string
328331
);
329332
}
330333

334+
/**
335+
* @inheritDoc
336+
*/
337+
public function getCbcPaymentProfile(): ?string
338+
{
339+
return $this->getConfig(
340+
self::XML_PATH_PAYMENT_CBC_PROFILE,
341+
ScopeInterface::SCOPE_STORES,
342+
(string)$this->storeManager->getStore()->getId()
343+
);
344+
}
345+
331346
/**
332347
* @inheritDoc
333348
*/

Model/ConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ConfigProvider implements ConfigProviderInterface
3838
public const CODE_BANCONTACT = 'cm_payments_bancontact';
3939
public const CODE_BELFIUS = 'cm_payments_belfius';
4040
public const CODE_KBC = 'cm_payments_kbc';
41+
public const CODE_CBC = 'cm_payments_cbc';
4142
public const CODE_ELV = 'cm_payments_elv';
4243
public const CODE_KLARNA = 'cm_payments_klarna';
4344
public const CODE_AFTERPAY = 'cm_payments_afterpay';

etc/adminhtml/system.xml

+109
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,115 @@
11191119
</field>
11201120
</group>
11211121

1122+
<group id="cm_payments_cbc" translate="label" type="text" sortOrder="70" showInDefault="1"
1123+
showInWebsite="1" showInStore="1">
1124+
<label>CBC by CM.com</label>
1125+
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"
1126+
showInStore="1" canRestore="1">
1127+
<label>Enabled</label>
1128+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1129+
<config_path>payment/cm_payments_cbc/active</config_path>
1130+
</field>
1131+
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
1132+
showInStore="1" canRestore="1">
1133+
<label>Title</label>
1134+
<config_path>payment/cm_payments_cbc/title</config_path>
1135+
<depends>
1136+
<field id="active">1</field>
1137+
</depends>
1138+
</field>
1139+
<field id="profile" translate="label comment" type="text" sortOrder="30" showInDefault="1"
1140+
showInWebsite="1" showInStore="1">
1141+
<label>Profile</label>
1142+
<comment><![CDATA[Configure the CM.com Payment Profile to use. This profile should contain the available
1143+
payment methods you want to show to the customer.]]></comment>
1144+
<config_path>payment/cm_payments_cbc/profile</config_path>
1145+
<depends>
1146+
<field id="active">1</field>
1147+
</depends>
1148+
</field>
1149+
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1"
1150+
showInWebsite="1" showInStore="1" canRestore="1">
1151+
<label>Payment from Applicable Countries</label>
1152+
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
1153+
<config_path>payment/cm_payments_cbc/allowspecific</config_path>
1154+
<depends>
1155+
<field id="active">1</field>
1156+
</depends>
1157+
</field>
1158+
<field id="specificcountry" translate="label" type="multiselect" sortOrder="50" showInDefault="1"
1159+
showInWebsite="1" showInStore="1">
1160+
<label>Payment from Specific Countries</label>
1161+
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
1162+
<can_be_empty>1</can_be_empty>
1163+
<config_path>payment/cm_payments_cbc/specificcountry</config_path>
1164+
<depends>
1165+
<field id="active">1</field>
1166+
</depends>
1167+
</field>
1168+
<field id="allow_specific_currency" translate="label" type="select" sortOrder="51" showInDefault="1"
1169+
showInWebsite="1" showInStore="1" canRestore="1">
1170+
<label>Payment in Applicable Currencies</label>
1171+
<source_model>CM\Payments\Model\Adminhtml\Source\AllSpecificCurrencies</source_model>
1172+
<config_path>payment/cm_payments_cbc/allow_specific_currency</config_path>
1173+
<depends>
1174+
<field id="active">1</field>
1175+
</depends>
1176+
</field>
1177+
<field id="specific_currency" translate="label" type="multiselect" sortOrder="52" showInDefault="1"
1178+
showInWebsite="1" showInStore="1">
1179+
<label>Payment from Specific Currencies</label>
1180+
<source_model>CM\Payments\Model\Adminhtml\Source\Currency</source_model>
1181+
<can_be_empty>1</can_be_empty>
1182+
<config_path>payment/cm_payments_cbc/specific_currency</config_path>
1183+
<depends>
1184+
<field id="active">1</field>
1185+
</depends>
1186+
</field>
1187+
<field id="min_order_total" translate="label" type="text" sortOrder="60" showInDefault="1"
1188+
showInWebsite="1" showInStore="1">
1189+
<label>Minimum Order Total</label>
1190+
<config_path>payment/cm_payments_cbc/min_order_total</config_path>
1191+
<depends>
1192+
<field id="active">1</field>
1193+
</depends>
1194+
</field>
1195+
<field id="max_order_total" translate="label" type="text" sortOrder="70" showInDefault="1"
1196+
showInWebsite="1" showInStore="1">
1197+
<label>Maximum Order Total</label>
1198+
<config_path>payment/cm_payments_cbc/max_order_total</config_path>
1199+
<depends>
1200+
<field id="active">1</field>
1201+
</depends>
1202+
</field>
1203+
<field id="order_expiry_unit" translate="label" type="select" sortOrder="80" showInDefault="1"
1204+
showInWebsite="1" showInStore="1" canRestore="1">
1205+
<label>Order Expiry Unit</label>
1206+
<source_model>CM\Payments\Model\Adminhtml\Source\OrderExpiryUnit</source_model>
1207+
<config_path>payment/cm_payments_cbc/order_expiry_unit</config_path>
1208+
<depends>
1209+
<field id="active">1</field>
1210+
</depends>
1211+
</field>
1212+
<field id="order_expiry_duration" translate="label" type="text" sortOrder="90" showInDefault="1"
1213+
showInWebsite="1" showInStore="1" canRestore="1">
1214+
<label>Order Expiry Duration</label>
1215+
<config_path>payment/cm_payments_cbc/order_expiry_duration</config_path>
1216+
<depends>
1217+
<field id="active">1</field>
1218+
</depends>
1219+
</field>
1220+
<field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1"
1221+
showInStore="1" canRestore="1">
1222+
<label>Sort Order</label>
1223+
<config_path>payment/cm_payments_cbc/sort_order</config_path>
1224+
<depends>
1225+
<field id="active">1</field>
1226+
</depends>
1227+
</field>
1228+
</group>
1229+
1230+
11221231
<group id="cm_payments_elv" translate="label" type="text" sortOrder="80" showInDefault="1"
11231232
showInWebsite="1" showInStore="1">
11241233
<label>ELV by CM.com</label>

etc/config.xml

+27
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,33 @@
261261
<group>cm</group>
262262
</cm_payments_kbc>
263263

264+
<cm_payments_cbc>
265+
<active>0</active>
266+
<mode>redirect</mode>
267+
<model>CMPaymentsCbcFacade</model>
268+
<order_status>pending</order_status>
269+
<payment_action>initialize</payment_action>
270+
<title>CBC by CM.com</title>
271+
<currency>EUR</currency>
272+
<can_initialize>1</can_initialize>
273+
<can_use_checkout>1</can_use_checkout>
274+
<can_use_internal>1</can_use_internal>
275+
<can_refund>1</can_refund>
276+
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
277+
<is_gateway>1</is_gateway>
278+
<sort_order>7</sort_order>
279+
<allowspecific>0</allowspecific>
280+
<allow_specific_currency>0</allow_specific_currency>
281+
<allow_specific_shipping_method>0</allow_specific_shipping_method>
282+
<allow_specific_customer_group>0</allow_specific_customer_group>
283+
<allow_amount>0</allow_amount>
284+
<custom_payment_link_lifetime>0</custom_payment_link_lifetime>
285+
<transaction_type>redirect</transaction_type>
286+
<order_expiry_unit>HOURS</order_expiry_unit>
287+
<order_expiry_duration>8</order_expiry_duration>
288+
<group>cm</group>
289+
</cm_payments_cbc>
290+
264291
<cm_payments_elv>
265292
<active>0</active>
266293
<mode>redirect</mode>

etc/di.xml

+61
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,67 @@
752752
</virtualType>
753753
<!-- END CM Payments (KBC) Method -->
754754

755+
<!-- BEGIN CM Payments (CBC) Method -->
756+
<virtualType name="CMPaymentsCbcFacade" type="CMPaymentsFacade">
757+
<arguments>
758+
<argument name="code" xsi:type="const">CM\Payments\Model\ConfigProvider::CODE_CBC</argument>
759+
<argument name="valueHandlerPool" xsi:type="object">CMCbcValueHandlerPool</argument>
760+
<argument name="validatorPool" xsi:type="object">CMCbcValidatorPool</argument>
761+
<argument name="commandPool" xsi:type="object">CMCbcCommandPool</argument>
762+
</arguments>
763+
</virtualType>
764+
765+
<virtualType name="CMCbcValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
766+
<arguments>
767+
<argument name="handlers" xsi:type="array">
768+
<item name="default" xsi:type="string">CMCbcConfigValueHandler</item>
769+
</argument>
770+
</arguments>
771+
</virtualType>
772+
773+
<virtualType name="CMCbcConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
774+
<arguments>
775+
<argument name="configInterface" xsi:type="object">CMCbcGenericConfig</argument>
776+
</arguments>
777+
</virtualType>
778+
779+
<virtualType name="CMCbcValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
780+
<arguments>
781+
<argument name="validators" xsi:type="array">
782+
<item name="country" xsi:type="string">CMCbcCountryValidator</item>
783+
<item name="currency" xsi:type="string">CMCbcCurrencyValidator</item>
784+
</argument>
785+
</arguments>
786+
</virtualType>
787+
788+
<virtualType name="CMCbcCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
789+
<arguments>
790+
<argument name="config" xsi:type="object">CMCbcGenericConfig</argument>
791+
</arguments>
792+
</virtualType>
793+
794+
<virtualType name="CMCbcCurrencyValidator" type="CM\Payments\Gateway\Validator\CurrencyValidator">
795+
<arguments>
796+
<argument name="config" xsi:type="object">CMCbcGenericConfig</argument>
797+
</arguments>
798+
</virtualType>
799+
800+
<virtualType name="CMCbcCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
801+
<arguments>
802+
<argument name="commands" xsi:type="array">
803+
<item name="initialize" xsi:type="string">CMInitializeCommand</item>
804+
<item name="refund" xsi:type="string">CMRefundCommand</item>
805+
</argument>
806+
</arguments>
807+
</virtualType>
808+
809+
<virtualType name="CMCbcGenericConfig" type="Magento\Payment\Gateway\Config\Config">
810+
<arguments>
811+
<argument name="methodCode" xsi:type="const">CM\Payments\Model\ConfigProvider::CODE_CBC</argument>
812+
</arguments>
813+
</virtualType>
814+
<!-- END CM Payments (CBC) Method -->
815+
755816
<!-- BEGIN CM Payments (ELV) Method -->
756817
<virtualType name="CMPaymentsElvFacade" type="CMPaymentsFacade">
757818
<arguments>

view/frontend/layout/checkout_index_index.xml

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
<item name="cm_payments_kbc" xsi:type="array">
5454
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
5555
</item>
56+
<item name="cm_payments_cbc" xsi:type="array">
57+
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
58+
</item>
5659
<item name="cm_payments_elv" xsi:type="array">
5760
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
5861
</item>

view/frontend/web/js/view/payment/method-renderer.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ define([
3333
{type: 'cm_payments_bancontact', component: defaultComponent},
3434
{type: 'cm_payments_belfius', component: defaultComponent},
3535
{type: 'cm_payments_kbc', component: defaultComponent},
36+
{type: 'cm_payments_cbc', component: defaultComponent},
3637
{type: 'cm_payments_elv', component: elvComponent},
3738
{type: 'cm_payments_klarna', component: klarnaComponent},
3839
{type: 'cm_payments_afterpay', component: defaultComponent},

0 commit comments

Comments
 (0)