-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
53 lines (45 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { sprintf, __ } from '@wordpress/i18n';
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { decodeEntities } from '@wordpress/html-entities';
import { getSetting } from '@woocommerce/settings';
const settings = getSetting( 'satispay_data', {} );
const defaultLabel = __(
'Satispay'
);
const defaultDescription = __(
'People Paying People. Choose Satispay and pay with a tap!'
);
const iconUrl = settings.icon;
const label = decodeEntities( settings.title ) || defaultLabel;
/**
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || defaultDescription );
};
/**
* Label component
*
* @param {*} props Props from payment API.
*/
const Label = ( props ) => {
const { PaymentMethodLabel } = props.components;
const icon = <img src={iconUrl} alt={label} name={label} />
return <PaymentMethodLabel text={label} icon={icon} />;
};
/**
* Dummy payment method config object.
*/
const Satispay = {
name: "satispay",
label: <Label />,
content: <Content />,
edit: <Content />,
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings.supports,
},
icon: settings.icon
};
registerPaymentMethod( Satispay );