PluginProbe
PayPlug for WooCommerce (Official) / 3.1.0
PayPlug for WooCommerce (Official) v3.1.0
3.1.0 3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 All 102 releases
payplug / resources / js / frontend / wc-payplug-wero-blocks.js

wc-payplug-wero-blocks.js in PayPlug for WooCommerce (Official) 3.1.0, at resources/js/frontend/wc-payplug-wero-blocks.js

59 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { registerPaymentMethod } from '@woocommerce/blocks-registry';
3 import { decodeEntities } from '@wordpress/html-entities';
4 import { getSetting } from '@woocommerce/settings';
5
6 const settings = getSetting( 'wero_data', {} );
7 const defaultLabel = __('Gateway method title', 'payplug');
8 const label = decodeEntities( settings?.title ) || defaultLabel;
9 const allowed_country_codes = settings?.allowed_country_codes;
10
11 /**
12 * Content component
13 */
14 const Content = () => {
15 return window.wp.htmlEntities.decodeEntities( settings?.description || '' );
16 };
17 /**
18 * Label component
19 *
20 */
21 const Label = () => {
22 return (
23 <span style={{ width: '100%' }}>
24 {label}
25 <Icon />
26 </span>
27 )
28 }
29
30 const Icon = () => {
31 return (
32 <img src={settings?.icon.src} alt={settings?.icon.icon_alt} className="payplug-payment-icon" style={{float: 'right'}}/>
33 )
34 }
35
36 /**
37 * Payplug payment method config object.
38 */
39 const Wero = {
40 name: "wero",
41 label: <Label />,
42 content: <Content />,
43 edit: <Content />,
44 canMakePayment: data => {
45 if (allowed_country_codes.includes(data.billingData.country)) {
46 return true;
47 } else {
48 return false;
49 }
50 },
51 ariaLabel: label,
52 supports: {
53 features: settings.supports,
54 },
55 };
56
57 // Register the defined payment method object
58 registerPaymentMethod( Wero );
59