document.addEventListener('DOMContentLoaded', function() {
  if (!window.wc || !window.wc.components) {
    alert('WooCommerce Blocks components are not available.');
    return;
  }

  const { registerPaymentMethod } = window.wc.wcBlocksRegistry;
  const { createElement } = wp.element;
  const { PaymentMethodLabel } = window.wc.components;

  const settings = {
    name: 'uplatnica',
    label: 'Opšta uplatnica',
    content: createElement(PaymentMethodLabel, { text: 'Opšta uplatnica' }),
    edit: createElement('div', null, 'Podešavanje Opšte uplatnice'),
    canMakePayment: function() {
      console.log('Checking if payment can be made');
      return true;
    },
    supports: {
      features: [ 'products' ]
    }
  };

  registerPaymentMethod(settings);
});
