initial commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
export const PAYMENT_METHOD_NAME = 'paypal';
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 decodeEntities( settings.description || '' );
|
||||
};
|
||||
|
||||
const paypalPaymentMethod = {
|
||||
name: PAYMENT_METHOD_NAME,
|
||||
label: (
|
||||
<img
|
||||
src={ `${ WC_ASSET_URL }/images/paypal.png` }
|
||||
alt={ decodeEntities(
|
||||
settings.title || __( 'PayPal', 'woocommerce' )
|
||||
) }
|
||||
/>
|
||||
),
|
||||
placeOrderButtonLabel: __(
|
||||
'Proceed to PayPal',
|
||||
'woocommerce'
|
||||
),
|
||||
content: <Content />,
|
||||
edit: <Content />,
|
||||
canMakePayment: () => true,
|
||||
ariaLabel: decodeEntities(
|
||||
settings.title ||
|
||||
__( 'Payment via PayPal', 'woocommerce' )
|
||||
),
|
||||
supports: {
|
||||
features: settings.supports ?? [],
|
||||
},
|
||||
};
|
||||
|
||||
registerPaymentMethod( paypalPaymentMethod );
|
Reference in New Issue
Block a user