2020-04-28 10:13:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { getSetting, WC_ASSET_URL } from '@woocommerce/settings';
|
|
|
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { PAYMENT_METHOD_NAME } from './constants';
|
|
|
|
|
|
|
|
const settings = getSetting( 'paypal_data', {} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {import('@woocommerce/type-defs/registered-payment-method-props').RegisteredPaymentMethodProps} RegisteredPaymentMethodProps
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Content component
|
|
|
|
*/
|
|
|
|
const Content = () => {
|
|
|
|
return <div>{ decodeEntities( settings.description || '' ) }</div>;
|
|
|
|
};
|
|
|
|
|
|
|
|
const paypalPaymentMethod = {
|
|
|
|
name: PAYMENT_METHOD_NAME,
|
|
|
|
label: (
|
2020-04-29 10:57:58 +00:00
|
|
|
<img
|
|
|
|
src={ `${ WC_ASSET_URL }/images/paypal.png` }
|
|
|
|
alt={ decodeEntities(
|
|
|
|
settings.title || __( 'PayPal', 'woo-gutenberg-products-block' )
|
|
|
|
) }
|
|
|
|
/>
|
2020-04-28 10:13:48 +00:00
|
|
|
),
|
|
|
|
content: <Content />,
|
|
|
|
edit: <Content />,
|
2020-04-29 10:57:58 +00:00
|
|
|
icons: null,
|
2020-04-28 10:13:48 +00:00
|
|
|
canMakePayment: () => true,
|
|
|
|
ariaLabel: decodeEntities(
|
|
|
|
settings.title ||
|
|
|
|
__( 'Payment via PayPal', 'woo-gutenberg-products-block' )
|
|
|
|
),
|
|
|
|
};
|
|
|
|
|
|
|
|
registerPaymentMethod( ( Config ) => new Config( paypalPaymentMethod ) );
|