index.js (1780B)
1 /* 2 This program is free software: you can redistribute it and/or modify 3 it under the terms of the GNU General Public License as published by 4 the Free Software Foundation, either version 3 of the License, or 5 (at your option) any later version. 6 7 This program is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 GNU General Public License for more details. 11 12 You should have received a copy of the GNU General Public License 13 along with this program. If not, see <https://www.gnu.org/licenses/>. 14 */ 15 16 import { sprintf, __ } from '@wordpress/i18n'; 17 import { registerPaymentMethod } from '@woocommerce/blocks-registry'; 18 import { decodeEntities } from '@wordpress/html-entities'; 19 import { getSetting } from '@woocommerce/settings'; 20 21 const settings = getSetting('gnutaler_data', {}); 22 23 const defaultLabel = __( 24 'GNU Taler', 25 'woocommerce-gateway-gnutaler' 26 ); 27 const label = decodeEntities(settings.title) || defaultLabel; 28 29 /** 30 * Content component 31 */ 32 const Content = () => { 33 return decodeEntities(settings.description || ''); 34 }; 35 36 /** 37 * Label component 38 * 39 * @param {*} props Props from payment API. 40 */ 41 const Label = (props) => { 42 const { PaymentMethodLabel } = props.components; 43 return <PaymentMethodLabel text ={ label } />; 44 }; 45 46 /** 47 * GNU Taler payment method config object. 48 */ 49 const GnutalerPaymentMethod = { 50 name: 'gnutaler', 51 label: <Label />, 52 content: <Content />, 53 edit: <Content />, 54 canMakePayment: () => true, 55 ariaLabel: label, 56 supports: { 57 features: settings.supports, 58 }, 59 }; 60 61 registerPaymentMethod( GnutalerPaymentMethod );