Add Stripe subscription sync

This commit is contained in:
Jon Staab
2026-04-01 16:26:54 -07:00
parent 7e0bd14ef3
commit 05e4eac025
9 changed files with 39 additions and 69 deletions
+11
View File
@@ -12,4 +12,15 @@ Members:
## `pub fn new(query: Query, command: Command, robot: Robot) -> Self`
- Reads environment and populates members
## `pub fn start(&self)`
- Subscribes to `command.notify.notified`
- On `create_relay`, `update_relay`, `activate_relay`, `deactivate_relay`, `fail_relay_sync`, and `complete_relay_sync`, call `self.sync_relay_subscription_item`.
## `pub fn sync_relay_subscription_item(&self, activity: &Activity)`
- Fetch the relay associated with the `activity`
- If the relay has `sync_error`, `synced` is false, `plan` is `free`, or `status` is `inactive`, delete the relay's subscription item using the Stripe api, and clear it with `command.delete_relay_subscription_item`.
- Otherwise, create/update the relay's subscription item to the appropriate Stripe price using the Stripe api and set it with `command.set_relay_subscription_item`.
- This method should be idempotent