| 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( 'wero_data', {} ); |
| 7 |
const defaultLabel = __('Gateway method title', 'payplug'); |
| 8 |
const label = decodeEntities( settings?.title ) || defaultLabel; |
| 9 |
const allowed_country_codes = settings?.allowed_country_codes; |
| 10 |
|
| 11 |
/** |
| 12 |
* Content component |
| 13 |
*/ |
| 14 |
const Content = () => { |
| 15 |
return window.wp.htmlEntities.decodeEntities( settings?.description || '' ); |
| 16 |
}; |
| 17 |
/** |
| 18 |
* Label component |
| 19 |
* |
| 20 |
*/ |
| 21 |
const Label = () => { |
| 22 |
return ( |
| 23 |
<span style={{ width: '100%' }}> |
| 24 |
{label} |
| 25 |
<Icon /> |
| 26 |
</span> |
| 27 |
) |
| 28 |
} |
| 29 |
|
| 30 |
const Icon = () => { |
| 31 |
return ( |
| 32 |
<img src={settings?.icon.src} alt={settings?.icon.icon_alt} className="payplug-payment-icon" style={{float: 'right'}}/> |
| 33 |
) |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Payplug payment method config object. |
| 38 |
*/ |
| 39 |
const Wero = { |
| 40 |
name: "wero", |
| 41 |
label: <Label />, |
| 42 |
content: <Content />, |
| 43 |
edit: <Content />, |
| 44 |
canMakePayment: data => { |
| 45 |
if (allowed_country_codes.includes(data.billingData.country)) { |
| 46 |
return true; |
| 47 |
} else { |
| 48 |
return false; |
| 49 |
} |
| 50 |
}, |
| 51 |
ariaLabel: label, |
| 52 |
supports: { |
| 53 |
features: settings.supports, |
| 54 |
}, |
| 55 |
}; |
| 56 |
|
| 57 |
// Register the defined payment method object |
| 58 |
registerPaymentMethod( Wero ); |
| 59 |
|