2020-07-08 00:39:16 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { getSetting } from '@woocommerce/settings';
|
|
|
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { PAYMENT_METHOD_NAME } from './constants';
|
|
|
|
|
|
|
|
const settings = getSetting( 'bacs_data', {} );
|
|
|
|
const defaultLabel = __(
|
|
|
|
'Direct bank transfer',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
);
|
|
|
|
const label = decodeEntities( settings.title ) || defaultLabel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {import('@woocommerce/type-defs/registered-payment-method-props').RegisteredPaymentMethodProps} RegisteredPaymentMethodProps
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Content component
|
|
|
|
*/
|
|
|
|
const Content = () => {
|
|
|
|
return <div>{ decodeEntities( settings.description || '' ) }</div>;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
};
|
|
|
|
|
2020-11-18 22:06:33 +00:00
|
|
|
registerPaymentMethod( bankTransferPaymentMethod );
|