2020-04-28 10:13:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2023-08-07 10:30:53 +00:00
|
|
|
import { getPaymentMethodData, WC_ASSET_URL } from '@woocommerce/settings';
|
2020-04-28 10:13:48 +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( 'paypal', {} );
|
2020-04-28 10:13:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Content component
|
|
|
|
*/
|
|
|
|
const Content = () => {
|
2021-03-12 14:40:09 +00:00
|
|
|
return decodeEntities( settings.description || '' );
|
2020-04-28 10:13:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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(
|
2023-12-09 13:44:54 +00:00
|
|
|
settings.title || __( 'PayPal', 'woocommerce' )
|
2020-04-29 10:57:58 +00:00
|
|
|
) }
|
|
|
|
/>
|
2020-04-28 10:13:48 +00:00
|
|
|
),
|
2020-04-30 09:52:36 +00:00
|
|
|
placeOrderButtonLabel: __(
|
|
|
|
'Proceed to PayPal',
|
2023-12-09 13:44:54 +00:00
|
|
|
'woocommerce'
|
2020-04-30 09:52:36 +00:00
|
|
|
),
|
2020-04-28 10:13:48 +00:00
|
|
|
content: <Content />,
|
|
|
|
edit: <Content />,
|
|
|
|
canMakePayment: () => true,
|
|
|
|
ariaLabel: decodeEntities(
|
2023-08-07 10:30:53 +00:00
|
|
|
settings?.title ||
|
2023-12-09 13:44:54 +00:00
|
|
|
__( 'Payment via PayPal', 'woocommerce' )
|
2020-04-28 10:13:48 +00:00
|
|
|
),
|
2021-01-29 06:28:44 +00:00
|
|
|
supports: {
|
|
|
|
features: settings.supports ?? [],
|
|
|
|
},
|
2020-04-28 10:13:48 +00:00
|
|
|
};
|
|
|
|
|
2020-11-18 22:06:33 +00:00
|
|
|
registerPaymentMethod( paypalPaymentMethod );
|