discourse/plugins/discourse-patreon/config/locales/server.en.yml
Rafael dos Santos Silva 8c0a4bb8f9
DEV: Upgrade Patreon plugin to API v2 with v1 backward compatibility (#38871)
## Summary

Patreon API v1 has been deprecated for years and the Patreon team has
requested we migrate to v2 (see
https://meta.discourse.org/t/upgrade-patreon-discourse-plugin-to-api-v2/386701).

Since hundreds of existing customers have v1 OAuth clients, this PR
supports **both versions simultaneously** via an adapter pattern,
controlled by a new `patreon_api_version` site setting (defaults to
`"1"` so no one breaks on upgrade).

### What changed

- **Adapter pattern**: `Patreon::ApiVersion::V1` and `ApiVersion::V2`
modules with identical interfaces for endpoints, response parsing, and
OAuth config. `ApiVersion.current` routes based on the site setting.
- **v2 API support**: campaigns endpoint returns tiers (not rewards),
members fetched separately with cursor-based pagination, v2 identity
endpoint with explicit field selection, v2 OAuth scopes
- **Webhooks accept both formats**: payload version detected from
`data.type` (`"pledge"` → v1, `"member"` → v2), regardless of the site
setting
- **Admin deprecation notice**: `ProblemCheck::PatreonApiV1Deprecated`
warns on the dashboard when still using v1
- **Shared logic unchanged**: rate limiting, PluginStore, group sync,
admin UI all version-agnostic
- Also fixes pre-existing flaky seed/campaign spec failures

### Migration path for existing users

1. Admin sees deprecation warning on dashboard
2. Create a new v2 OAuth client at
https://www.patreon.com/portal/registration/register-clients
3. Update credentials in site settings
4. Switch `patreon_api_version` to `"2"`
5. Creator re-authenticates via Patreon login to get v2-scoped tokens
6. Trigger a manual data sync from the Patreon admin panel

### Future v1 removal

When ready to drop v1: delete `lib/api_version/v1.rb`, the problem
check, the site setting, v1 fixtures, and v1 test contexts — one clean
cut.

## Test plan

- [x] All 41 plugin specs pass (both v1 and v2 contexts)
- [x] Lint passes on all changed files
- [x] Zeitwerk reload passes (`bin/rails runner
"Rails.application.reloader.reload!"`)
- [x] Manual testing with a real Patreon v2 OAuth client
2026-03-30 14:43:34 -03:00

27 lines
2.2 KiB
YAML

en:
site_settings:
patreon_enabled: 'Enable the discourse-patreon plugin'
patreon_login_enabled: 'Enable Patreon Social Login'
patreon_client_id: 'Generated Patreon Client ID'
patreon_client_secret: 'Generated Patreon Client Secret'
patreon_webhook_secret: 'Generated Patreon Webhook Secret'
patreon_creator_discourse_username: "Username of the Discourse account which is used to login through Patreon creator account using 'Patreon Social Login'"
patreon_creator_access_token: "Generated Patreon Creator's Access Token"
patreon_creator_refresh_token: "Generated Patreon Creator's Refesh Token"
patreon_declined_pledges_grace_period_days: "Grace period (in days) before a pledge is declined completely."
max_patreon_api_reqs_per_hr: "Maximum number of Patreon API requests per hour"
max_patreon_api_reqs_per_day: "Maximum number of Patreon API requests per day"
patreon_verbose_log: 'enable verbose logging of patreon payload'
patreon_donation_prompt_enabled: "Enable donation prompt?"
patreon_donation_prompt_show_after_topics: "Show donation prompt after n topics"
patreon_api_version: "Patreon API version. Version 1 is deprecated — create a new OAuth client on Patreon and switch to version 2."
patreon_donation_prompt_campaign_url: "Donation prompt campaign URL"
errors:
patreon_creator_username_not_set: "You need to set the Patreon Creator Discourse Username setting before enabling Patreon Login."
dashboard:
problem:
access_token_invalid: "Patreon Creator's access and refresh token values are incorrect. You must copy-paste new tokens from <a href='https://www.patreon.com/platform/documentation/clients'>Patreon website</a> to <a href='%{base_path}/admin/site_settings/category/all_results?filter=patreon'>site settings</a>."
patreon_api_v1_deprecated: "You are using Patreon API v1, which is deprecated. Please <a href='https://www.patreon.com/portal/registration/register-clients'>create a new v2 OAuth client on Patreon</a>, update your credentials, and switch to API v2 in <a href='%{base_path}/admin/site_settings/category/all_results?filter=patreon_api_version'>site settings</a>."
patreon:
error:
invalid_response: "Invalid response from Patreon API"