Developer docs

Listening to order and visit events

· Dispense Flow developers

In short

An order usually emits order.created, order.paid and order.shipped, and possibly order.refunded, order.cancelled or dispute.opened. A visit emits flow_session.submitted and then flow_session.approved or flow_session.declined, but only to apps granted read_visits. Events for one install arrive in order; store each event id and ignore repeats.

An order's life

A cart checkout creates the order and captures payment: order.created then order.paid. A prescription order starts with a visit: the patient is charged when they finish the intake and check out, before the provider reviews it, so order.created comes before flow_session.approved or flow_session.declined. A decline is refunded according to the store's policy (a full refund unless the store says otherwise before the patient pays). Shipping arrives as order.shipped with the carrier and tracking number when known, whether the pharmacy shipped it, a dropship supplier did, or the merchant marked it fulfilled.

Refunds from the dashboard emit order.refunded with the amount of that refund; a partial refund can be followed by another. A chargeback emits dispute.opened with the evidence due date.

Subscriptions and memberships

A subscription starts after the provider approves the visit (subscription.created) and renews with subscription.renewed; customers can pause, resume and cancel from their account. Memberships have their own program.* events. Both need read_subscriptions.

Visits are health information

flow_session.* events tie a named customer to a treatment, so they are PHI and need read_visits, which needs our BAA and approval. Even then they carry ids and statuses, never answers or prescriptions.

Duplicates and ordering

Delivery is at least once: a retry after a timeout can repeat an event. Keep the id of every event you processed (a unique index is enough) and skip repeats. One install's events arrive one at a time, oldest first; across stores there is no ordering.

Reconcile with the API

Webhooks tell you something changed. When you need the full current state, read it: GET /v1/app-api/orders/{id}. After an outage, page through /app-api/orders to catch up.

Questions

Do test orders send events?

Yes, with isTest: true in data, so you can filter them out of reporting.