| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { registerPaymentMethod } from '@woocommerce/blocks-registry'; |
| 3 |
import { decodeEntities } from '@wordpress/html-entities'; |
| 4 |
import { getSetting } from '@woocommerce/settings'; |
| 5 |
|
| 6 |
const settings = getSetting( 'scalapay_data', {} ); |
| 7 |
const defaultLabel = __('Gateway method title', 'payplug'); |
| 8 |
const label = decodeEntities( settings?.title ) || defaultLabel; |
| 9 |
|
| 10 |
/** |
| 11 |
* Content component |
| 12 |
*/ |
| 13 |
const Content = () => { |
| 14 |
return window.wp.htmlEntities.decodeEntities( settings?.description || '' ); |
| 15 |
}; |
| 16 |
/** |
| 17 |
* Label component |
| 18 |
* |
| 19 |
*/ |
| 20 |
const Label = () => { |
| 21 |
return ( |
| 22 |
<span style={{ width: '100%' }}> |
| 23 |
{label} |
| 24 |
<Icon /> |
| 25 |
</span> |
| 26 |
) |
| 27 |
} |
| 28 |
|
| 29 |
const Icon = () => { |
| 30 |
return ( |
| 31 |
<img src={settings?.icon.src} alt={settings?.icon.icon_alt} className="payplug-payment-icon" style={{float: 'right'}}/> |
| 32 |
) |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Payplug payment method config object. |
| 37 |
*/ |
| 38 |
const Scalapay = { |
| 39 |
name: "scalapay", |
| 40 |
label: <Label />, |
| 41 |
content: <Content />, |
| 42 |
edit: <Content />, |
| 43 |
canMakePayment: () => true, |
| 44 |
ariaLabel: label, |
| 45 |
supports: { |
| 46 |
features: settings.supports, |
| 47 |
}, |
| 48 |
}; |
| 49 |
|
| 50 |
// Register the defined payment method object |
| 51 |
registerPaymentMethod( Scalapay ); |
| 52 |
|