Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Changelog ***

= 10.3.0 - xxxx-xx-xx =
* Dev - Deprecates and replaces PRBs classes with ECE equivalents
* Dev - Renames all express checkout related frontend hooks
* Dev - Removes deprecated legacy checkout settings retrieval methods
* Dev - Removes all references to the UPE-enabled feature flag
Expand Down
78 changes: 78 additions & 0 deletions includes/admin/class-wc-stripe-express-checkout-controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Admin page for UPE Customize Express Checkouts.
*
* @since 10.3.0
*/
class WC_Stripe_Express_Checkout_Controller {
public function __construct() {
add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] );
add_action( 'wc_stripe_gateway_admin_options_wrapper', [ $this, 'admin_options' ] );
}

/**
* Load admin scripts.
*/
public function admin_scripts() {
// Webpack generates an assets file containing a dependencies array for our built JS file.
$script_asset_path = WC_STRIPE_PLUGIN_PATH . '/build/express-checkout-settings.asset.php';
$asset_metadata = file_exists( $script_asset_path )
? require $script_asset_path
: [
'dependencies' => [],
'version' => WC_STRIPE_VERSION,
];
wp_register_script(
'wc-stripe-express-checkout-settings',
plugins_url( 'build/express-checkout-settings.js', WC_STRIPE_MAIN_FILE ),
$asset_metadata['dependencies'],
$asset_metadata['version'],
true
);
wp_set_script_translations(
'wc-stripe-express-checkout-settings',
'woocommerce-gateway-stripe'
);
wp_enqueue_script( 'wc-stripe-express-checkout-settings' );

$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
$params = [
'key' => WC_Stripe_Mode::is_test() ? $stripe_settings['test_publishable_key'] : $stripe_settings['publishable_key'],
'locale' => WC_Stripe_Helper::convert_wc_locale_to_stripe_locale( get_locale() ),
'is_ece_enabled' => WC_Stripe_Feature_Flags::is_stripe_ece_enabled(),
];
wp_localize_script(
'wc-stripe-express-checkout-settings',
'wc_stripe_express_checkout_settings_params',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use a different object name here, we also need to update the global in client/entrypoints/express-checkout-settings/express-checkout-preview-component.js (and the corresponding tests) that depend on it:

Image

$params
);

wp_register_style(
'wc-stripe-express-checkout-settings',
plugins_url( 'build/express-checkout-settings.css', WC_STRIPE_MAIN_FILE ),
[ 'wc-components' ],
$asset_metadata['version']
);
wp_enqueue_style( 'wc-stripe-express-checkout-settings' );
}

/**
* Prints the admin options for the gateway.
* Remove this action once we're fully migrated to UPE and move the wrapper in the `admin_options` method of the UPE gateway.
*/
public function admin_options() {
global $hide_save_button;
$hide_save_button = true;
$return_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' );
$header = __( 'Customize express checkouts', 'woocommerce-gateway-stripe' );
$return_text = __( 'Return to Stripe', 'woocommerce-gateway-stripe' );

WC_Stripe_Helper::render_admin_header( $header, $return_text, $return_url );

echo '<div class="wrap"><div id="wc-stripe-express-checkout-settings-container"></div></div>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use a different Id here, we also need to update it in client/entrypoints/express-checkout-settings/index.js, otherwise the Express Checkout settings page won't load:

const container = document.getElementById(
'wc-stripe-payment-request-settings-container'
);
if ( container ) {
createRoot( container ).render( <ExpressCheckoutPage /> );
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Admin page for UPE Customize Express Checkouts.
*
* @since 5.4.1
*
* @deprecated 10.3.0 Moved to includes/admin/class-wc-stripe-express-checkout-controller.php
*/
class WC_Stripe_Payment_Requests_Controller {
public function __construct() {
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public function init() {
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-settings-controller.php';

if ( isset( $_GET['area'] ) && 'payment_requests' === $_GET['area'] ) {
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-payment-requests-controller.php';
new WC_Stripe_Payment_Requests_Controller();
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-express-checkout-controller.php';
new WC_Stripe_Express_Checkout_Controller();
} elseif ( isset( $_GET['area'] ) && 'amazon_pay' === $_GET['area'] && WC_Stripe_Feature_Flags::is_amazon_pay_available() ) {
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-amazon-pay-controller.php';
new WC_Stripe_Amazon_Pay_Controller();
Expand Down
Loading
Loading