Plugin Directory

Changeset 3399333


Ignore:
Timestamp:
11/20/2025 02:49:53 AM (5 months ago)
Author:
maalypay
Message:

feat: update payment block register

Location:
maaly-pay
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • maaly-pay/trunk/assets/js/maaly-pay.js

    r3399327 r3399333  
    1 const { registerExpressPaymentMethod } = window.wc.wcBlocksRegistry;
     1const { registerPaymentMethod } = window.wc.wcBlocksRegistry;
     2const label = window.React.createElement("p", {}, "Maaly Pay")
     3const content = window.React.createElement("p", {}, "Maaly Pay")
    24
    35const options = {
     
    57    title: 'Maaly Pay',
    68    description: 'Getting Crypto Payment using Maaly Pay',
     9    ariaLabel: "Pay with Maaly Pay",
     10    placeOrderButtonLabel: "Pay with Maaly Pay",
    711    gatewayId: 'maaly_pay',
    8     label: <ReactNode />,
    9     content: <ReactNode />,
    10     edit: <ReactNode />,
     12    paymentMethodId: 'maaly_pay',
     13    label: label,
     14    content: content,
     15    edit: null,
    1116    canMakePayment: () => true,
    12     paymentMethodId: 'maaly_pay',
    1317    supports: {
    1418        features: [],
     
    1721};
    1822
    19 registerExpressPaymentMethod(options)
     23registerPaymentMethod(options)
  • maaly-pay/trunk/includes/class-maaly-pay-gateway-blocks.php

    r3399323 r3399333  
    2929        // Load settings for your gateway (if applicable)
    3030        $this->settings = get_option( 'maaly_pay_settings', array() );
     31
     32        $gateways       = WC()->payment_gateways->payment_gateways();
    3133        // Instantiate your main payment gateway class
    32         $this->gateway = new WC_Gateway_Maaly_Pay();
     34        $this->gateway = $gateways($this->name);
    3335    }
    3436
     
    4951    public function get_payment_method_script_handles() {
    5052        wp_register_script(
    51             'maaly-pay-method',
    52             plugins_url( 'assets/js/maaly-pay.js', __FILE__ ), // Path to your frontend script
     53            'wc-maaly-pay-blocks',
     54            // plugins_url( 'assets/js/maaly-pay.js', __FILE__ ), // Path to your frontend script
     55            MAALY_PAY_PLUGIN_URL . 'assets/js/maaly-pay.js',
    5356            [ 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n' ],
    54             false,
     57            '1.1.0',
    5558            true
    5659        );
    5760
    5861        if ( function_exists( 'wp_set_script_translations' ) ) {
    59             wp_set_script_translations( 'maaly-pay-method' );
     62            wp_set_script_translations( 'wc-maaly-pay-blocks' );
    6063        }
    6164
    62         return [ 'maaly-pay-method' ];
     65        return [ 'wc-maaly-pay-blocks' ];
    6366    }
    6467
     
    7275            'title'       => $this->gateway->title,
    7376            'description' => $this->gateway->description,
     77            'supports'    => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] )
    7478            // Add any other data needed by your frontend script
    7579        ];
Note: See TracChangeset for help on using the changeset viewer.