Add bancontact component

This commit is contained in:
Emili Castells Guasch 2024-08-12 11:54:14 +02:00
parent 60885b2ad9
commit ce25dee734
4 changed files with 17 additions and 7 deletions

View file

@ -0,0 +1,9 @@
export function Bancontact( { config, components } ) {
const { PaymentMethodIcons } = components;
return (
<div>
<PaymentMethodIcons icons={ [ config.icon ] } align="right" />
</div>
);
}

View file

@ -1,12 +1,12 @@
import { registerPaymentMethod } from '@woocommerce/blocks-registry'; import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { Bancontact } from './bancontact-block';
const config = wc.wcSettings.getSetting( 'ppcp-bancontact_data' ); const config = wc.wcSettings.getSetting( 'ppcp-bancontact_data' );
console.log( config );
registerPaymentMethod( { registerPaymentMethod( {
name: config.id, name: config.id,
label: <div dangerouslySetInnerHTML={ { __html: config.title } } />, label: <div dangerouslySetInnerHTML={ { __html: config.title } } />,
content: <div>Hi there!</div>, content: <Bancontact config={ config } />,
edit: <div></div>, edit: <div></div>,
ariaLabel: config.title, ariaLabel: config.title,
canMakePayment: () => { canMakePayment: () => {

View file

@ -63,14 +63,14 @@ class BancontactPaymentMethod extends AbstractPaymentMethodType {
*/ */
public function get_payment_method_script_handles() { public function get_payment_method_script_handles() {
wp_register_script( wp_register_script(
'ppcp-bancontact-checkout-block', 'ppcp-bancontact-payment-method',
trailingslashit( $this->module_url ) . 'assets/js/bancontact-checkout-block.js', trailingslashit( $this->module_url ) . 'assets/js/bancontact-payment-method.js',
array(), array(),
$this->version, $this->version,
true true
); );
return array( 'ppcp-bancontact-checkout-block' ); return array( 'ppcp-bancontact-payment-method' );
} }
/** /**
@ -81,6 +81,7 @@ class BancontactPaymentMethod extends AbstractPaymentMethodType {
'id' => $this->name, 'id' => $this->name,
'title' => $this->gateway->title, 'title' => $this->gateway->title,
'description' => $this->gateway->description, 'description' => $this->gateway->description,
'icon' => esc_url( 'https://www.paypalobjects.com/images/checkout/alternative_payments/paypal_bancontact_color.svg' ),
); );
} }
} }

View file

@ -9,8 +9,8 @@ module.exports = {
target: 'web', target: 'web',
plugins: [ new DependencyExtractionWebpackPlugin() ], plugins: [ new DependencyExtractionWebpackPlugin() ],
entry: { entry: {
'bancontact-checkout-block': path.resolve( 'bancontact-payment-method': path.resolve(
'./resources/js/bancontact-checkout-block.js' './resources/js/bancontact-payment-method.js'
), ),
}, },
output: { output: {