Add Stripe subscription sync
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user