1414
1515class RegistrationService {
1616
17- private const REGISTRATION_TOKEN_KEY = 'ppcp_agentic_registration_token ' ;
18- private const ERROR_REGISTRATION_FAILED = 'registration_failed ' ;
19- private const ERROR_DEREGISTRATION_FAILED = 'deregistration_failed ' ;
20- private const ERROR_WEBHOOK_REQUEST = 'webhook_request_failed ' ;
21- private const ERROR_WEBHOOK_RESPONSE = 'webhook_response_failed ' ;
17+ private const REGISTRATION_TOKEN_KEY = 'ppcp_agentic_registration_token ' ;
18+ private const ERROR_REGISTRATION_FAILED = 'registration_failed ' ;
19+ private const ERROR_WEBHOOK_REQUEST = 'webhook_request_failed ' ;
20+ private const ERROR_WEBHOOK_RESPONSE = 'webhook_response_failed ' ;
2221
2322 private AgenticWebhookConfiguration $ webhook_urls ;
2423 private MerchantMetadataProvider $ metadata_provider ;
@@ -69,7 +68,6 @@ public function register() {
6968
7069 do_action ( 'woocommerce_paypal_payments_store_sync_registered ' );
7170 } else {
72- $ this ->delete_registration_token ();
7371 $ this ->logger ->error (
7472 'Registration failed: Endpoint rejected registration ' ,
7573 array (
@@ -92,6 +90,12 @@ public function register() {
9290 /**
9391 * Deregister store from PayPal Agentic Commerce.
9492 *
93+ * Deregistration is fire-and-forget: the local token is always removed and the
94+ * deregistered action always fires, regardless of the endpoint's response. A
95+ * rejection (e.g. "store not found") means the store is already gone on the
96+ * endpoint's side, which is the desired outcome, not a reason to retry. Failures
97+ * are still logged.
98+ *
9599 * @return RegistrationResult|WP_Error|null Null if the store was not registered.
96100 */
97101 public function deregister () {
@@ -111,11 +115,7 @@ public function deregister() {
111115 'error_message ' => $ result ->get_error_message (),
112116 )
113117 );
114-
115- return $ result ;
116- }
117-
118- if ( ! $ result ->success ) {
118+ } elseif ( ! $ result ->success ) {
119119 $ this ->logger ->error (
120120 'Deregistration failed: Endpoint rejected deregistration ' ,
121121 array (
@@ -124,11 +124,6 @@ public function deregister() {
124124 'message ' => $ result ->message ,
125125 )
126126 );
127-
128- return new WP_Error (
129- self ::ERROR_DEREGISTRATION_FAILED ,
130- $ result ->error ?? 'Deregistration failed '
131- );
132127 }
133128
134129 $ this ->delete_registration_token ();
0 commit comments