Payment gateway block not working
-
Hi everybody! I’m new to WooCommerce and I’m developing a custom payment gateway. I already developed it for shortcode checkouts, but I want to add support for blocks checkouts. So far I followed?this documentation, but I’m stuck trying to make everything work. I have developed everything (pretty basic tho, I’m just trying to show stuff on the screen so far), including my js and php files, but I’m stuck at trying to make my?
index.js
?to get succesfully compiled. What I’m doing is to run?npm run build
?— which runs?wp-scripts build
–, but I get the following error:?Module not found: Error: Can't resolve '@woocommerce/blocks-registry' in ...
?, so I’m guessing that I’m not importing correctly that module.
I’m not sure if I’m following a correct process to compile, so I explain it (take in consideration that every route that I mention from here on is inside my plugin, i.e.?/wp-content/my_plugin/
):- I created all my js files (currently 1, but anyway) and saved the
index.js
file insrc/
. - Run
npm run build
inside my plugin folder and wait for it to compile my files intobuild/index.js
- Hopefully get my plugin rendered in WooCommerce checkout.
What is it that I’m doing wrong? I also tried to use
const { registerPaymentMethod } = window.wc.wcBlocksRegistry;
(I’m developing a regular payment method, not an express one) instead of importingregisterPaymentMethod
, but I get an error indicating thatwindow.wc
isundefined
.
Hope somebody can help me! - I created all my js files (currently 1, but anyway) and saved the
- The topic ‘Payment gateway block not working’ is closed to new replies.