2020-04-02 17:04:15 +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-04-02 17:04:15 +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( 'cheque', {} );
|
2020-07-15 14:14:41 +00:00
|
|
|
const defaultLabel = __( 'Check payment', 'woo-gutenberg-products-block' );
|
2023-08-07 10:30:53 +00:00
|
|
|
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
|
2020-04-02 17:04:15 +00:00
|
|
|
|
2020-04-03 11:50:54 +00:00
|
|
|
/**
|
2020-04-28 10:13:48 +00:00
|
|
|
* Content component
|
2020-04-03 11:50:54 +00:00
|
|
|
*/
|
2020-04-28 10:13:48 +00:00
|
|
|
const Content = () => {
|
2021-03-12 14:40:09 +00:00
|
|
|
return decodeEntities( settings.description || '' );
|
2020-04-14 06:01:29 +00:00
|
|
|
};
|
|
|
|
|
2020-05-13 15:48:03 +00:00
|
|
|
/**
|
|
|
|
* Label component
|
|
|
|
*
|
|
|
|
* @param {*} props Props from payment API.
|
|
|
|
*/
|
|
|
|
const Label = ( props ) => {
|
|
|
|
const { PaymentMethodLabel } = props.components;
|
2020-08-11 20:44:19 +00:00
|
|
|
return <PaymentMethodLabel text={ label } />;
|
2020-05-13 15:48:03 +00:00
|
|
|
};
|
|
|
|
|
2020-04-29 10:57:58 +00:00
|
|
|
/**
|
|
|
|
* Cheque payment method config object.
|
|
|
|
*/
|
2020-04-02 17:04:15 +00:00
|
|
|
const offlineChequePaymentMethod = {
|
2020-04-09 15:22:34 +00:00
|
|
|
name: PAYMENT_METHOD_NAME,
|
2020-05-13 15:48:03 +00:00
|
|
|
label: <Label />,
|
2020-04-02 17:04:15 +00:00
|
|
|
content: <Content />,
|
2020-04-28 10:13:48 +00:00
|
|
|
edit: <Content />,
|
2020-04-09 11:44:29 +00:00
|
|
|
canMakePayment: () => true,
|
2020-04-29 10:57:58 +00:00
|
|
|
ariaLabel: label,
|
2021-01-29 06:28:44 +00:00
|
|
|
supports: {
|
|
|
|
features: settings?.supports ?? [],
|
|
|
|
},
|
2020-04-02 17:04:15 +00:00
|
|
|
};
|
|
|
|
|
2020-11-18 22:06:33 +00:00
|
|
|
registerPaymentMethod( offlineChequePaymentMethod );
|