2020-07-08 00:39:16 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2023-08-07 10:30:53 +00:00
|
|
|
import { getPaymentMethodData } from '@woocommerce/settings';
|
2020-07-08 00:39:16 +00:00
|
|
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { PAYMENT_METHOD_NAME } from './constants';
|
|
|
|
|
2023-08-07 10:30:53 +00:00
|
|
|
const settings = getPaymentMethodData( 'bacs', {} );
|
2020-07-08 00:39:16 +00:00
|
|
|
const defaultLabel = __(
|
|
|
|
'Direct bank transfer',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
);
|
2023-08-07 10:30:53 +00:00
|
|
|
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
|
2020-07-08 00:39:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Content component
|
|
|
|
*/
|
|
|
|
const Content = () => {
|
2021-03-12 14:40:09 +00:00
|
|
|
return decodeEntities( settings.description || '' );
|
2020-07-08 00:39:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Label component
|
|
|
|
*
|
|
|
|
* @param {*} props Props from payment API.
|
|
|
|
*/
|
|
|
|
const Label = ( props ) => {
|
|
|
|
const { PaymentMethodLabel } = props.components;
|
|
|
|
return <PaymentMethodLabel text={ label } />;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bank transfer (BACS) payment method config object.
|
|
|
|
*/
|
|
|
|
const bankTransferPaymentMethod = {
|
|
|
|
name: PAYMENT_METHOD_NAME,
|
|
|
|
label: <Label />,
|
|
|
|
content: <Content />,
|
|
|
|
edit: <Content />,
|
|
|
|
canMakePayment: () => true,
|
|
|
|
ariaLabel: label,
|
2021-01-29 06:28:44 +00:00
|
|
|
supports: {
|
|
|
|
features: settings?.supports ?? [],
|
|
|
|
},
|
2020-07-08 00:39:16 +00:00
|
|
|
};
|
|
|
|
|
2020-11-18 22:06:33 +00:00
|
|
|
registerPaymentMethod( bankTransferPaymentMethod );
|