| 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 |
|