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.1.0 - xxxx-xx-xx =
* Update - Renames and migrates all Payment Request Buttons settings to Express Checkout
* Add - Add a new filter allowing third-party plugins to hook captcha solutions when creating and confirming setup intents
* Dev - Add track events when clicking the "Reconnect to Stripe" button (both in the settings page and the admin notice)
* Update - Removes unnecessary legacy checkout gateway instantiations and UPE disablement code
Expand Down
26 changes: 13 additions & 13 deletions includes/admin/class-wc-rest-stripe-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,28 @@ public function register_routes() {
'payment_request_button_type' => [
'description' => __( 'Express checkout button types.', 'woocommerce-gateway-stripe' ),
'type' => 'string',
'enum' => array_keys( $form_fields['payment_request_button_type']['options'] ),
'enum' => array_keys( $form_fields['express_checkout_button_type']['options'] ),
'validate_callback' => 'rest_validate_request_arg',
],
'payment_request_button_theme' => [
'description' => __( 'Express checkout button themes.', 'woocommerce-gateway-stripe' ),
'type' => 'string',
'enum' => array_keys( $form_fields['payment_request_button_theme']['options'] ),
'enum' => array_keys( $form_fields['express_checkout_button_theme']['options'] ),
'validate_callback' => 'rest_validate_request_arg',
],
'payment_request_button_size' => [
'description' => __( 'Express checkout button sizes.', 'woocommerce-gateway-stripe' ),
'type' => 'string',
// it can happen that `$form_fields['payment_request_button_size']` is empty (in tests) - fixing temporarily.
'enum' => array_keys( isset( $form_fields['payment_request_button_size']['options'] ) ? $form_fields['payment_request_button_size']['options'] : [] ),
// it can happen that `$form_fields['express_checkout_button_size']` is empty (in tests) - fixing temporarily.
'enum' => array_keys( isset( $form_fields['express_checkout_button_size']['options'] ) ? $form_fields['express_checkout_button_size']['options'] : [] ),
'validate_callback' => 'rest_validate_request_arg',
],
'payment_request_button_locations' => [
'description' => __( 'Express checkout locations that should be enabled.', 'woocommerce-gateway-stripe' ),
'type' => 'array',
'items' => [
'type' => 'string',
'enum' => array_keys( $form_fields['payment_request_button_locations']['options'] ),
'enum' => array_keys( $form_fields['express_checkout_button_locations']['options'] ),
],
'validate_callback' => 'rest_validate_request_arg',
],
Expand Down Expand Up @@ -237,10 +237,10 @@ public function get_settings() {
'amazon_pay_button_size' => $this->gateway->get_validated_option( 'amazon_pay_button_size' ),
'amazon_pay_button_locations' => $this->gateway->get_validated_option( 'amazon_pay_button_locations' ),
'is_payment_request_enabled' => $this->gateway->is_payment_request_enabled(),
'payment_request_button_type' => $this->gateway->get_validated_option( 'payment_request_button_type' ),
'payment_request_button_theme' => $this->gateway->get_validated_option( 'payment_request_button_theme' ),
'payment_request_button_size' => $this->gateway->get_validated_option( 'payment_request_button_size' ),
'payment_request_button_locations' => $this->gateway->get_validated_option( 'payment_request_button_locations' ),
'payment_request_button_type' => $this->gateway->get_validated_option( 'express_checkout_button_type' ),
'payment_request_button_theme' => $this->gateway->get_validated_option( 'express_checkout_button_theme' ),
'payment_request_button_size' => $this->gateway->get_validated_option( 'express_checkout_button_size' ),
'payment_request_button_locations' => $this->gateway->get_validated_option( 'express_checkout_button_locations' ),

/* Settings > Payments & transactions */
'is_manual_capture_enabled' => ! $this->gateway->is_automatic_capture_enabled(),
Expand Down Expand Up @@ -540,10 +540,10 @@ private function update_amazon_pay_settings( WP_REST_Request $request ) {
*/
private function update_payment_request_settings( WP_REST_Request $request ) {
$attributes = [
'payment_request_button_type' => 'payment_request_button_type',
'payment_request_button_size' => 'payment_request_button_size',
'payment_request_button_theme' => 'payment_request_button_theme',
'payment_request_button_locations' => 'payment_request_button_locations',
'payment_request_button_type' => 'express_checkout_button_type',
'payment_request_button_size' => 'express_checkout_button_size',
'payment_request_button_theme' => 'express_checkout_button_theme',
'payment_request_button_locations' => 'express_checkout_button_locations',
];

foreach ( $attributes as $request_key => $attribute ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-wc-stripe-inbox-notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function should_show_marketing_note() {
// Make sure Apple Pay is enabled and setup is successful.
$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
$stripe_enabled = isset( $stripe_settings['enabled'] ) && 'yes' === $stripe_settings['enabled'];
$button_enabled = isset( $stripe_settings['payment_request'] ) && 'yes' === $stripe_settings['payment_request'];
$button_enabled = isset( $stripe_settings['express_checkout'] ) && 'yes' === $stripe_settings['express_checkout'];
$registration_complete = isset( $stripe_settings['apple_pay_domain_set'] ) && 'yes' === $stripe_settings['apple_pay_domain_set'];
if ( ! $stripe_enabled || ! $button_enabled || ! $registration_complete ) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct() {
// If UPE is enabled and there are enabled payment methods, we need to load the disable Stripe confirmation modal.
$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
$enabled_upe_payment_methods = WC_Stripe_Payment_Method_Configurations::get_upe_enabled_payment_method_ids();
$upe_payment_requests_enabled = 'yes' === ( $stripe_settings['payment_request'] ?? 'no' );
$upe_payment_requests_enabled = 'yes' === ( $stripe_settings['express_checkout'] ?? 'no' );

if ( ( is_array( $enabled_upe_payment_methods ) && count( $enabled_upe_payment_methods ) > 0 ) || $upe_payment_requests_enabled ) {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_payments_scripts' ] );
Expand Down
28 changes: 14 additions & 14 deletions includes/admin/stripe-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
'default' => 'yes',
'desc_tip' => true,
],
'payment_request' => [
'express_checkout' => [
'title' => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
'label' => sprintf(
/* translators: 1) br tag 2) Stripe anchor tag 3) Apple anchor tag 4) Stripe dashboard opening anchor tag 5) Stripe dashboard closing anchor tag */
Expand All @@ -133,7 +133,7 @@
'default' => 'yes',
'desc_tip' => true,
],
'payment_request_button_type' => [
'express_checkout_button_type' => [
'title' => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
'label' => __( 'Button Type', 'woocommerce-gateway-stripe' ),
'type' => 'select',
Expand All @@ -148,7 +148,7 @@
'custom' => __( 'Custom', 'woocommerce-gateway-stripe' ),
],
],
'payment_request_button_theme' => [
'express_checkout_button_theme' => [
'title' => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
'label' => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
'type' => 'select',
Expand Down Expand Up @@ -189,7 +189,7 @@
'long' => __( 'Text and logo', 'woocommerce-gateway-stripe' ),
],
],
'payment_request_button_locations' => [
'express_checkout_button_locations' => [
'title' => __( 'Payment Request Button Locations', 'woocommerce-gateway-stripe' ),
'type' => 'multiselect',
'description' => __( 'Select where you would like Payment Request Buttons to be displayed', 'woocommerce-gateway-stripe' ),
Expand All @@ -205,7 +205,7 @@
'data-placeholder' => __( 'Select pages', 'woocommerce-gateway-stripe' ),
],
],
'payment_request_button_size' => [
'express_checkout_button_size' => [
'title' => __( 'Payment Request Button Size', 'woocommerce-gateway-stripe' ),
'type' => 'select',
'description' => __( 'Select the size of the button.', 'woocommerce-gateway-stripe' ),
Expand Down Expand Up @@ -293,20 +293,20 @@

if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
// in the new settings, "checkout" is going to be enabled by default (if it is a new WCStripe installation).
$stripe_settings['payment_request_button_locations']['default'][] = 'checkout';
$stripe_settings['express_checkout_button_locations']['default'][] = 'checkout';

// no longer needed in the new settings.
unset( $stripe_settings['payment_request_button_branded_type'] );
unset( $stripe_settings['payment_request_button_height'] );
unset( $stripe_settings['payment_request_button_label'] );
unset( $stripe_settings['express_checkout_button_branded_type'] );
unset( $stripe_settings['express_checkout_button_height'] );
unset( $stripe_settings['express_checkout_button_label'] );
// injecting some of the new options.
$stripe_settings['payment_request_button_type']['options']['default'] = __( 'Only icon', 'woocommerce-gateway-stripe' );
$stripe_settings['payment_request_button_type']['options']['book'] = __( 'Book', 'woocommerce-gateway-stripe' );
$stripe_settings['express_checkout_button_type']['options']['default'] = __( 'Only icon', 'woocommerce-gateway-stripe' );
$stripe_settings['express_checkout_button_type']['options']['book'] = __( 'Book', 'woocommerce-gateway-stripe' );
// no longer valid options.
unset( $stripe_settings['payment_request_button_type']['options']['branded'] );
unset( $stripe_settings['payment_request_button_type']['options']['custom'] );
unset( $stripe_settings['express_checkout_button_type']['options']['branded'] );
unset( $stripe_settings['express_checkout_button_type']['options']['custom'] );
} else {
unset( $stripe_settings['payment_request_button_size'] );
unset( $stripe_settings['express_checkout_button_size'] );
}

if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-gateway-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function __construct() {
$this->saved_cards = 'yes' === $this->get_option( 'saved_cards' );
$this->secret_key = $this->testmode ? $this->get_validated_option( 'test_secret_key' ) : $this->get_validated_option( 'secret_key' );
$this->publishable_key = $this->testmode ? $this->get_validated_option( 'test_publishable_key' ) : $this->get_validated_option( 'publishable_key' );
$this->payment_request = 'yes' === $this->get_option( 'payment_request', 'yes' );
$this->payment_request = 'yes' === $this->get_option( 'express_checkout', 'yes' );

WC_Stripe_API::set_secret_key( $this->secret_key );

Expand Down Expand Up @@ -1236,7 +1236,7 @@ private function validate_field( $field_key, $field_value ) {
* @return bool
*/
public function is_payment_request_enabled() {
return 'yes' === $this->get_option( 'payment_request' );
return 'yes' === $this->get_option( 'express_checkout' );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-stripe-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ public static function should_load_scripts_on_cart_page() {
private static function should_load_scripts_for_prb_location( $location ) {
// Make sure location parameter is sanitized.
$location = in_array( $location, [ 'product', 'cart' ], true ) ? $location : '';
$are_prbs_enabled = self::get_settings( null, 'payment_request' ) ?? 'yes';
$prb_locations = self::get_settings( null, 'payment_request_button_locations' ) ?? [ 'product', 'cart' ];
$are_prbs_enabled = self::get_settings( null, 'express_checkout' ) ?? 'yes';
$prb_locations = self::get_settings( null, 'express_checkout_button_locations' ) ?? [ 'product', 'cart' ];

// The scripts should be loaded when all of the following are true:
// 1. The PRBs are enabled; and
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-stripe-payment-method-configurations.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public static function maybe_migrate_payment_methods_from_db_to_pmc( $force_migr
}

// Add Google Pay and Apple Pay to the list if payment_request is enabled
if ( ! empty( $stripe_settings['payment_request'] ) && 'yes' === $stripe_settings['payment_request'] ) {
if ( ! empty( $stripe_settings['express_checkout'] ) && 'yes' === $stripe_settings['express_checkout'] ) {
$enabled_payment_methods = array_merge(
$enabled_payment_methods,
[ WC_Stripe_Payment_Methods::GOOGLE_PAY, WC_Stripe_Payment_Methods::APPLE_PAY ]
Expand Down
9 changes: 4 additions & 5 deletions includes/class-wc-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ public function init() {
require_once WC_STRIPE_PLUGIN_PATH . '/includes/class-wc-stripe-account.php';

new Allowed_Payment_Request_Button_Types_Update();
// TODO: Temporary disabling the migration as it has a conflict with the new UPE checkout.
// new Migrate_Payment_Request_Data_To_Express_Checkout_Data();
new Migrate_Payment_Request_Data_To_Express_Checkout_Data();
new Sepa_Tokens_For_Other_Methods_Settings_Update();

$this->api = new WC_Stripe_Connect_API();
Expand Down Expand Up @@ -415,8 +414,8 @@ public function migrate_to_new_checkout_experience() {
*/
public function update_prb_location_settings() {
$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
$prb_locations = isset( $stripe_settings['payment_request_button_locations'] )
? $stripe_settings['payment_request_button_locations']
$prb_locations = isset( $stripe_settings['express_checkout_button_locations'] )
? $stripe_settings['express_checkout_button_locations']
: [];
if ( ! empty( $stripe_settings ) && empty( $prb_locations ) ) {
global $post;
Expand All @@ -439,7 +438,7 @@ public function update_prb_location_settings() {
$new_prb_locations[] = 'checkout';
}

$stripe_settings['payment_request_button_locations'] = $new_prb_locations;
$stripe_settings['express_checkout_button_locations'] = $new_prb_locations;
WC_Stripe_Helper::update_main_stripe_settings( $stripe_settings );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function is_account_creation_possible() {
* @return string
*/
public function get_button_type() {
return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default';
return isset( $this->stripe_settings['express_checkout_button_type'] ) ? $this->stripe_settings['express_checkout_button_type'] : 'default';
}

/**
Expand All @@ -117,7 +117,7 @@ public function get_button_type() {
* @return string
*/
public function get_button_theme() {
return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
return isset( $this->stripe_settings['express_checkout_button_theme'] ) ? $this->stripe_settings['express_checkout_button_theme'] : 'dark';
}

/**
Expand All @@ -126,7 +126,7 @@ public function get_button_theme() {
* @return string
*/
public function get_button_height() {
$height = isset( $this->stripe_settings['payment_request_button_size'] ) ? $this->stripe_settings['payment_request_button_size'] : 'default';
$height = isset( $this->stripe_settings['express_checkout_button_size'] ) ? $this->stripe_settings['express_checkout_button_size'] : 'default';
if ( 'small' === $height ) {
return '40';
}
Expand All @@ -144,7 +144,7 @@ public function get_button_height() {
* @return string
*/
public function get_button_radius() {
$height = isset( $this->stripe_settings['payment_request_button_size'] ) ? $this->stripe_settings['payment_request_button_size'] : 'default';
$height = isset( $this->stripe_settings['express_checkout_button_size'] ) ? $this->stripe_settings['express_checkout_button_size'] : 'default';
if ( 'small' === $height ) {
return '2';
}
Expand Down Expand Up @@ -1553,18 +1553,18 @@ public function get_login_confirmation_settings() {
*/
public function get_button_locations() {
// If the locations have not been set return the default setting.
if ( ! isset( $this->stripe_settings['payment_request_button_locations'] ) ) {
if ( ! isset( $this->stripe_settings['express_checkout_button_locations'] ) ) {
return [ 'product', 'cart' ];
}

// If all locations are removed through the settings UI the location config will be set to
// an empty string "". If that's the case (and if the settings are not an array for any
// other reason) we should return an empty array.
if ( ! is_array( $this->stripe_settings['payment_request_button_locations'] ) ) {
if ( ! is_array( $this->stripe_settings['express_checkout_button_locations'] ) ) {
return [];
}

return $this->stripe_settings['payment_request_button_locations'];
return $this->stripe_settings['express_checkout_button_locations'];
}

/**
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
== Changelog ==

= 10.1.0 - xxxx-xx-xx =
* Update - Renames and migrates all Payment Request Buttons settings to Express Checkout
* Add - Add a new filter allowing third-party plugins to hook captcha solutions when creating and confirming setup intents
* Dev - Add track events when clicking the "Reconnect to Stripe" button (both in the settings page and the admin notice)
* Update - Removes unnecessary legacy checkout gateway instantiations and UPE disablement code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function test_migration_executed_when_pmc_enabled_is_not_set() {
// Set pmc_enabled to '' to trigger migration
$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
$stripe_settings['test_connection_type'] = 'connect';
$stripe_settings['payment_request'] = 'yes';
$stripe_settings['express_checkout'] = 'yes';
$stripe_settings['upe_checkout_experience_accepted_payments'] = [ 'link', 'sepa_debit' ];
$stripe_settings['pmc_enabled'] = '';
WC_Stripe_Helper::update_main_stripe_settings( $stripe_settings );
Expand Down
Loading
Loading