$values, 'form' => $form, 'entry_id' => $entry_id, 'settings' => $settings, 'attempt' => $attempt ]; $result = Hubspot_Client::upsert_contact( $token, $email, $properties ); if ( is_wp_error( $result ) ) { $data = $result->get_error_data(); Api_Log::log( 'hubspot', $form['id'], '/crm/v3/objects/contacts/batch/upsert', $data['status'] ?? null, $result->get_error_message() ); $this->maybe_retry( $attempt ); self::$pending_context = null; return; } Api_Log::log( 'hubspot', $form['id'], '/crm/v3/objects/contacts/batch/upsert', 200, __( 'Contact created/updated.', 'chargeforms' ) ); self::$pending_context = null; } /** WP-Cron callback — same shape as Mailchimp_Integration::handle_retry(). */ public static function handle_retry( $values, $form, $entry_id, $settings, $attempt ) { ( new self() )->process( $values, $form, $entry_id, $settings, $attempt ); } private function maybe_retry( $attempt ) { if ( ! self::$pending_context || $attempt >= self::MAX_ATTEMPTS ) { return; } $ctx = self::$pending_context; wp_schedule_single_event( time() + self::RETRY_DELAY_SECONDS, self::RETRY_HOOK, [ $ctx['values'], $ctx['form'], $ctx['entry_id'], $ctx['settings'], $ctx['attempt'] + 1 ] ); } }