Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the new split UPE the default experience. #5542

Merged
Merged
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
11 changes: 8 additions & 3 deletions includes/admin/class-wc-rest-upe-flag-toggle-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,17 @@ private function update_is_upe_enabled( WP_REST_Request $request ) {
$is_upe_enabled = $request->get_param( 'is_upe_enabled' );

if ( $is_upe_enabled ) {
update_option( WC_Payments_Features::UPE_FLAG_NAME, '1' );
update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' );
return;
}

// marking the flag as "disabled", so that we can keep track that the merchant explicitly disabled it.
update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' );
// If the legacy UPE flag has been enabled, we need to disable the legacy UPE flag.
if ( '1' === get_option( WC_Payments_Features::UPE_FLAG_NAME ) ) {
update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' );
} else {
// marking the flag as "disabled", so that we can keep track that the merchant explicitly disabled it.
update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, 'disabled' );
}

// resetting a few other things:
// removing the UPE payment methods and _only_ leaving "card",
Expand Down
3 changes: 3 additions & 0 deletions includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,9 @@ private function finalize_connection( $state, $mode ) {
// user might not have agreed to TOS yet.
update_option( '_wcpay_onboarding_stripe_connected', [ 'is_existing_stripe_account' => false ] );

// Automatically enable split UPE for new stores.
update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' );

wp_safe_redirect(
add_query_arg(
[
Expand Down
2 changes: 1 addition & 1 deletion includes/migrations/class-track-upe-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function maybe_track() {
return;
}

$upe_value = get_option( \WC_Payments_Features::UPE_FLAG_NAME, 'not-set' );
$upe_value = get_option( \WC_Payments_Features::UPE_SPLIT_FLAG_NAME, 'not-set' );

// Don't trigger the track event when the flag isn't set.
if ( 'not-set' !== $upe_value ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static function maybe_enable_upe_feature_flag() {
}

// Enable UPE, deletes the note and redirect to onboarding task.
update_option( WC_Payments_Features::UPE_FLAG_NAME, '1' );
update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' );
self::possibly_delete_note();

$wcpay_settings_url = admin_url( 'admin.php?page=wc-admin&path=/payments/additional-payment-methods' );
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/migrations/test-class-track-upe-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function set_up() {
parent::set_up();

delete_option( Track_Upe_Status::IS_TRACKED_OPTION );
delete_option( WC_Payments_Features::UPE_FLAG_NAME );
delete_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME );
}

/**
Expand All @@ -39,7 +41,7 @@ public function tear_down() {
* Make sure the 'wcpay_upe_enabled' event is registered when upe is enabled.
*/
public function test_track_enabled_on_upgrade() {
update_option( WC_Payments_Features::UPE_FLAG_NAME, '1' );
update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' );

Track_Upe_Status::maybe_track();

Expand All @@ -54,7 +56,7 @@ public function test_track_enabled_on_upgrade() {
}

public function test_track_disabled_on_upgrade() {
update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' );
update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, 'disabled' );

Track_Upe_Status::maybe_track();

Expand Down