PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.0
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.0
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
better-payment / assets / js / woocommerce-blocks.js

woocommerce-blocks.js in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.4.0, at assets/js/woocommerce-blocks.js

53 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Better Payment (Stripe) — WooCommerce blocks checkout registration.
3 *
4 * Hand-authored (NOT produced by any webpack build — there is no src/
5 * counterpart). It is a plain registration shim for a redirect gateway with
6 * no fields: it surfaces the title/description configured on the gateway and
7 * lets WooCommerce handle the rest via process_payment().
8 *
9 * Dependencies (registered handle deps): wc-blocks-registry, wc-settings,
10 * wp-element, wp-html-entities.
11 */
12 ( function () {
13 'use strict';
14
15 const registry = window.wc?.wcBlocksRegistry;
16 const settingsApi = window.wc?.wcSettings;
17 const element = window.wp?.element;
18 const htmlEntities = window.wp?.htmlEntities;
19
20 if ( ! registry || ! settingsApi || ! element ) {
21 return;
22 }
23
24 const PAYMENT_METHOD_NAME = 'better_payment_stripe';
25 const settings = settingsApi.getSetting(
26 PAYMENT_METHOD_NAME + '_data',
27 {}
28 );
29
30 const decode = ( value ) =>
31 htmlEntities?.decodeEntities
32 ? htmlEntities.decodeEntities( value )
33 : value;
34
35 const label = decode( settings.title ?? '' ) || 'Better Payment';
36 const description = decode( settings.description ?? '' );
37
38 const Label = () => element.createElement( 'span', null, label );
39 const Content = () => element.createElement( 'div', null, description );
40
41 registry.registerPaymentMethod( {
42 name: PAYMENT_METHOD_NAME,
43 label: element.createElement( Label ),
44 content: element.createElement( Content ),
45 edit: element.createElement( Content ),
46 ariaLabel: label,
47 canMakePayment: () => true,
48 supports: {
49 features: settings.supports ?? [ 'products' ],
50 },
51 } );
52 } )();
53