Skip to content

WFL-217 | Add support for workflows endpoints#913

Merged
RosieWatson merged 26 commits into
mainfrom
rosie/wfl-217-purchases-js-add-workflow-endpoint-support-2
Jun 12, 2026
Merged

WFL-217 | Add support for workflows endpoints#913
RosieWatson merged 26 commits into
mainfrom
rosie/wfl-217-purchases-js-add-workflow-endpoint-support-2

Conversation

@RosieWatson

@RosieWatson RosieWatson commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Motivation / Description

Add support for workflow endpoints to be used

Here's the flow for both paths in presentPaywall:

Standard Paywall

  1. Resolve offering (from param or getOfferings().current)
  2. workflowsEndpointEnabled is false → skip workflow fetch
  3. Validate offering.paywallComponents and offering.uiConfig exist
  4. Mount Paywall component with the offering's paywall data

Workflow

  1. Resolve offering (same as above)
  2. workflowsEndpointEnabled is true → call getWorkflows(appUserId) to get a list of all published workflows
  3. Find one whose offering_id matches offering.identifier
  4. If a match is found → call getWorkflowById(appUserId, workflowId) to fetch the full workflow data (handles inline or CDN redirect responses)
  5. Convert the workflow data to nav data via workflowDataToNavData
  6. If any step in 4–5 fails → warn and fall back to the standard paywall (or throw if there's no paywall to fall back to)
  7. Mount Workflow component instead of Paywall

Key differences

  • Two extra network requests for workflows (getWorkflows + getWorkflowById) vs none for standard paywalls
  • Workflows are gated behind workflowsEndpointEnabled: true in FlagsConfig (internal, defaults false)
  • The offering is still required for both paths — workflows use offering.identifier to find the right workflow, and offering.availablePackages for the purchase flow
  • Locale: workflow uses selectedLocale (raw from params/browser), paywall uses finalLocale (calculated from offering.paywallComponents localisations)

Note

Medium Risk
Changes core paywall presentation and purchase locale paths when the flag is on, plus extra network/CDN fetches; default-off flag limits exposure but fallback logic affects error behavior for workflow-only offerings.

Overview
Adds workflow-backed paywalls behind the internal flag workflowsEndpointEnabled (default false). When enabled, presentPaywall loads paywall workflows from new subscriber APIs, picks one whose offering_id matches the offering, fetches full workflow payload (inline or CDN), and mounts the Workflow UI instead of Paywall, with warn-and-fallback to the classic paywall when fetch or nav conversion fails.

Introduces getWorkflows and getWorkflowById on the backend (including use_cdn follow-up fetches), response types, and MSW coverage. Paywall validation and locale handling are adjusted so workflow-only offerings can work without paywallComponents until fallback is required; purchase from workflows uses selectedLocale for checkout. Paywall event tests now waitFor mount because presentation can be async before the UI is mounted.

Reviewed by Cursor Bugbot for commit 2376ba9. Bugbot is set up for automated code reviews on this repo. Configure here.

@RosieWatson RosieWatson marked this pull request as draft June 10, 2026 07:51
@RosieWatson RosieWatson marked this pull request as ready for review June 10, 2026 09:35
@RosieWatson RosieWatson requested a review from a team June 10, 2026 09:48
Comment thread src/networking/backend.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts
Comment thread src/main.ts Outdated
Comment thread src/main.ts
Comment thread src/main.ts
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
@RosieWatson RosieWatson requested a review from vegaro June 12, 2026 08:52

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for making the changes!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2376ba9. Configure here.

Comment thread src/main.ts
@RosieWatson RosieWatson merged commit 5e565a2 into main Jun 12, 2026
7 checks passed
@RosieWatson RosieWatson deleted the rosie/wfl-217-purchases-js-add-workflow-endpoint-support-2 branch June 12, 2026 09:59
RCGitBot added a commit that referenced this pull request Jun 16, 2026
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add Slovenian support for paywalls (#932) via Monika Mateska
(@MonikaMateska)
* [WEB-4279] Discount line items in native wallets (#905) via James
O'Donnell (@james-od)

## RevenueCatUI SDK
### ✨ New Features
* WFL-217 | Add support for workflows endpoints (#913) via Rosie Watson
(@RosieWatson)

### 🔄 Other Changes
* [AUTOMATIC] Update generated error codes (#931) via RevenueCat Git Bot
(@RCGitBot)
* Danger: block manual edits to generated error codes (#930) via Álvaro
Brey (@AlvaroBrey)
* Add update-error-codes workflow (#926) via Álvaro Brey (@AlvaroBrey)
* test(e2e): add full Paddle E2E coverage to webbilling-demo (WST-564)
(#925) via Roger Solé (@rogersole)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Version and changelog-only changes with no runtime logic modified in
this PR.
> 
> **Overview**
> **Automatic release** that publishes **1.43.0** by aligning version
metadata everywhere it is duplicated: `.version`, `package.json`,
`src/helpers/constants.ts`, and the docs redirect in
`scripts/docs/index.html` (1.42.4 → 1.43.0).
> 
> `CHANGELOG.md` and `CHANGELOG.latest.md` are updated to document what
ships in this release (already merged elsewhere): **Slovenian paywall
locale**, **discount line items in native wallets**, **RevenueCatUI
workflows endpoints**, regenerated error codes plus CI/Danger
guardrails, and expanded Paddle E2E coverage in webbilling-demo.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ef5e9f3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants