@@ -925,78 +925,90 @@ public function test_update_payment_token() {
925
925
}
926
926
927
927
/**
928
- * Tests that UPE methods are enabled if Stripe is enabled and the account is connected to the platform.
928
+ * Tests that UPE methods are enabled if Stripe is enabled and the method is enabled in the PMC,
929
+ * for accounts with PMC sync.
929
930
*/
930
931
public function test_upe_method_enabled () {
931
932
$ stripe_settings = WC_Stripe_Helper::get_stripe_settings ();
932
933
$ stripe_settings ['enabled ' ] = 'yes ' ;
933
934
$ stripe_settings ['test_connection_type ' ] = 'connect ' ;
935
+ $ stripe_settings ['pmc_enabled ' ] = 'yes ' ;
934
936
WC_Stripe_Helper::update_main_stripe_settings ( $ stripe_settings );
935
937
936
- $ this ->mock_payment_method_configurations ( [ WC_Stripe_Payment_Methods::LINK ], [] );
937
-
938
- $ link_upe_method = new WC_Stripe_UPE_Payment_Method_Link ();
938
+ $ this ->mock_payment_method_configurations ( [ WC_Stripe_Payment_Methods::LINK , WC_Stripe_Payment_Methods::CASHAPP_PAY ], [] );
939
+ $ link_upe_method = new WC_Stripe_UPE_Payment_Method_Link ();
940
+ $ cashapp_upe_method = new WC_Stripe_UPE_Payment_Method_Cash_App_Pay ();
941
+ $ wechat_upe_method = new WC_Stripe_UPE_Payment_Method_Wechat_Pay ();
939
942
$ this ->assertTrue ( $ link_upe_method ->is_enabled () );
943
+ $ this ->assertTrue ( $ cashapp_upe_method ->is_enabled () );
944
+ $ this ->assertFalse ( $ wechat_upe_method ->is_enabled () );
940
945
}
941
946
942
947
/**
943
- * Tests that UPE methods are not enabled if Stripe is disabled.
948
+ * Tests that UPE methods are not enabled if Stripe is disabled,
949
+ * for accounts with PMC sync.
944
950
*/
945
951
public function test_upe_method_disabled () {
946
- $ stripe_settings = WC_Stripe_Helper::get_stripe_settings ();
947
- $ stripe_settings ['enabled ' ] = 'no ' ;
952
+ $ stripe_settings = WC_Stripe_Helper::get_stripe_settings ();
953
+ $ stripe_settings ['enabled ' ] = 'no ' ;
954
+ $ stripe_settings ['test_connection_type ' ] = 'connect ' ;
955
+ $ stripe_settings ['pmc_enabled ' ] = 'no ' ;
948
956
WC_Stripe_Helper::update_main_stripe_settings ( $ stripe_settings );
949
957
950
- $ this ->mock_payment_method_configurations ( [ WC_Stripe_Payment_Methods::LINK ], [] );
951
-
952
- $ link_upe_method = new WC_Stripe_UPE_Payment_Method_Link ();
958
+ $ this ->mock_payment_method_configurations ( [ WC_Stripe_Payment_Methods::LINK , WC_Stripe_Payment_Methods::CASHAPP_PAY ], [] );
959
+ $ link_upe_method = new WC_Stripe_UPE_Payment_Method_Link ();
960
+ $ cashapp_upe_method = new WC_Stripe_UPE_Payment_Method_Cash_App_Pay ();
961
+ $ wechat_upe_method = new WC_Stripe_UPE_Payment_Method_Wechat_Pay ();
953
962
$ this ->assertFalse ( $ link_upe_method ->is_enabled () );
963
+ $ this ->assertFalse ( $ cashapp_upe_method ->is_enabled () );
964
+ $ this ->assertFalse ( $ wechat_upe_method ->is_enabled () );
954
965
}
955
966
956
967
/**
957
- * Tests that UPE methods are only enabled if Stripe is enabled and the account is not connected to the platform.
968
+ * Tests that UPE methods are only enabled if Stripe is enabled and the method is enabled in the local settings,
969
+ * for accounts with no PMC sync.
958
970
*/
959
- public function test_upe_method_enabled_for_non_connected_accounts () {
971
+ public function test_upe_method_enabled_no_pmc_sync () {
960
972
// Enable Stripe and reset the accepted payment methods.
961
- $ stripe_settings = WC_Stripe_Helper::get_stripe_settings ();
962
- $ stripe_settings ['enabled ' ] = 'yes ' ;
963
- $ stripe_settings ['upe_checkout_experience_accepted_payments ' ] = [];
973
+ $ stripe_settings = WC_Stripe_Helper::get_stripe_settings ();
974
+ $ stripe_settings ['enabled ' ] = 'yes ' ;
975
+ $ stripe_settings ['test_connection_type ' ] = 'connect ' ;
976
+ $ stripe_settings ['pmc_enabled ' ] = 'no ' ;
977
+ $ stripe_settings ['upe_checkout_experience_accepted_payments ' ] = [
978
+ WC_Stripe_Payment_Methods::LINK ,
979
+ WC_Stripe_Payment_Methods::CASHAPP_PAY ,
980
+ ];
964
981
WC_Stripe_Helper::update_main_stripe_settings ( $ stripe_settings );
965
982
966
- // For each method we'll test the following combinations:
967
- $ stripe_enabled_settings = [ 'yes ' , 'no ' , '' ];
968
- $ upe_method_enabled_options = [ true , false ];
969
-
970
- foreach ( WC_Stripe_UPE_Payment_Gateway::UPE_AVAILABLE_METHODS as $ payment_method ) {
971
- foreach ( $ stripe_enabled_settings as $ stripe_enabled ) {
972
- foreach ( $ upe_method_enabled_options as $ upe_method_enabled_option ) {
973
- // CARD is always enabled for UPE and non connected accounts.
974
- if ( WC_Stripe_Payment_Methods::CARD === $ payment_method ::STRIPE_ID && ! $ upe_method_enabled_option ) {
975
- continue ;
976
- }
977
-
978
- // Update the settings.
979
- $ stripe_settings ['enabled ' ] = $ stripe_enabled ;
980
-
981
- $ payment_method_index = array_search ( $ payment_method ::STRIPE_ID , $ stripe_settings ['upe_checkout_experience_accepted_payments ' ] );
982
- if ( $ upe_method_enabled_option && false === $ payment_method_index ) {
983
- $ stripe_settings ['upe_checkout_experience_accepted_payments ' ][] = $ payment_method ::STRIPE_ID ;
984
- } elseif ( ! $ upe_method_enabled_option && false !== $ payment_method_index ) {
985
- unset( $ stripe_settings ['upe_checkout_experience_accepted_payments ' ][ $ payment_method_index ] );
986
- }
987
-
988
- WC_Stripe_Helper::update_main_stripe_settings ( $ stripe_settings );
989
-
990
- // Verify that the payment method is enabled/disabled.
991
- $ payment_method_instance = new $ payment_method ();
992
- // The UPE method is only enabled if Stripe is enabled and the method is enabled in the settings.
993
- if ( 'yes ' === $ stripe_enabled && $ upe_method_enabled_option ) {
994
- $ this ->assertTrue ( $ payment_method_instance ->is_enabled () );
995
- } else {
996
- $ this ->assertFalse ( $ payment_method_instance ->is_enabled () );
997
- }
998
- }
999
- }
1000
- }
983
+ $ link_upe_method = new WC_Stripe_UPE_Payment_Method_Link ();
984
+ $ cashapp_upe_method = new WC_Stripe_UPE_Payment_Method_Cash_App_Pay ();
985
+ $ wechat_upe_method = new WC_Stripe_UPE_Payment_Method_Wechat_Pay ();
986
+ $ this ->assertTrue ( $ link_upe_method ->is_enabled () );
987
+ $ this ->assertTrue ( $ cashapp_upe_method ->is_enabled () );
988
+ $ this ->assertFalse ( $ wechat_upe_method ->is_enabled () );
989
+ }
990
+
991
+ /**
992
+ * Tests that UPE methods are only enabled if Stripe is enabled and the method is enabled in the local settings,
993
+ * for accounts with no PMC sync.
994
+ */
995
+ public function test_upe_method_disabled_no_pmc_sync () {
996
+ // Enable Stripe and reset the accepted payment methods.
997
+ $ stripe_settings = WC_Stripe_Helper::get_stripe_settings ();
998
+ $ stripe_settings ['enabled ' ] = 'yes ' ;
999
+ $ stripe_settings ['test_connection_type ' ] = 'connect ' ;
1000
+ $ stripe_settings ['pmc_enabled ' ] = 'no ' ;
1001
+ $ stripe_settings ['upe_checkout_experience_accepted_payments ' ] = [
1002
+ WC_Stripe_Payment_Methods::LINK ,
1003
+ WC_Stripe_Payment_Methods::CASHAPP_PAY ,
1004
+ ];
1005
+ WC_Stripe_Helper::update_main_stripe_settings ( $ stripe_settings );
1006
+
1007
+ $ link_upe_method = new WC_Stripe_UPE_Payment_Method_Link ();
1008
+ $ cashapp_upe_method = new WC_Stripe_UPE_Payment_Method_Cash_App_Pay ();
1009
+ $ wechat_upe_method = new WC_Stripe_UPE_Payment_Method_Wechat_Pay ();
1010
+ $ this ->assertTrue ( $ link_upe_method ->is_enabled () );
1011
+ $ this ->assertTrue ( $ cashapp_upe_method ->is_enabled () );
1012
+ $ this ->assertFalse ( $ wechat_upe_method ->is_enabled () );
1001
1013
}
1002
1014
}
0 commit comments