Orders to accounting
Goal: keep your accounting system in step with RaviFurnitures orders, their GST invoices, online payments and refunds.
Permission: one key with MANAGE_ORDERS only. That permission can also cancel orders and issue refunds through unpublished operations, so guard the key (see Getting started).
Webhook events: ask your contact for one webhook subscribed to ORDER_CREATED, PAYMENT_CAPTURED and ORDER_FULFILLED.
Queries: order, orders, refunds.
Recommended sync pattern
Section titled “Recommended sync pattern”orders has no “changed since” filter, so you can’t ask for recent changes. Let webhooks tell you which order changed, then read that order.
1. On each order event, read the order
Section titled “1. On each order event, read the order”Take the order number from the event (data.number for ORDER_CREATED and ORDER_FULFILLED, data.orderNumber for PAYMENT_CAPTURED). Fetch the order and upsert it by number.
query OrderForAccounting($number: String!) { order(number: $number) { number status createdAt paymentMethod segment buyerGstin interState grandTotal { paise } amountDue { paise } balanceDue { paise } codPaidAt gst { taxableValue { paise } cgst { paise } sgst { paise } igst { paise } } invoice { number issuedAt } creditNotes { number issuedAt amount { paise } reason } lines { sku hsnCode gstRate quantity total { paise } gst { taxableValue { paise } cgst { paise } sgst { paise } igst { paise } } } payments { gateway status amount { paise } refunded { paise } externalOrderId } }}{ "number": "RFO/2026-27/00000" }Don’t book from the webhook body alone. It is a snapshot taken when the event was raised and carries no tax breakdown. For example, ORDER_CREATED always says UNCONFIRMED, even for a cash-on-delivery order that was confirmed in the same step.
2. Book the sale when the invoice exists
Section titled “2. Book the sale when the invoice exists”invoice stays null until the tax invoice is issued. That happens when the order is confirmed. For a made-to-order order the advance does not raise an invoice; the invoice comes once the balance is paid. Re-read the order on PAYMENT_CAPTURED and ORDER_FULFILLED to pick it up.
invoice.number is your stable reference for the sale. The PDF may appear a little later than the number.
3. Record payments
Section titled “3. Record payments”PAYMENT_CAPTURED is sent once for each captured online payment:
- A made-to-order order has two payments, the advance and the balance, so you get two events.
- When one gateway charge pays for a cart split into two orders, you get one event per order, with the same
externalPaymentId.
Key payments on the pair orderNumber + externalPaymentId. Cash-on-delivery and credit payments recorded by staff send no event; read codPaidAt, amountDue and balanceDue from the order instead.
4. Poll refunds
Section titled “4. Poll refunds”There is no refund event. Read refunds on a schedule, newest first, and upsert by id:
query RefundsPage($after: String) { refunds(first: 100, after: $after) { edges { node { id state amount { paise } reason gateway externalRefundId manual createdAt settledAt order { number } } } pageInfo { hasNextPage endCursor } }}- Stop paging when you reach refunds you already hold in a final state.
- Only
SETTLEDmeans the customer has the money. Re-read refunds you hold asREQUESTED,SENDING,ACCEPTEDorUNKNOWNuntil they settle or fail. You can filter withstate, for examplerefunds(state: ACCEPTED). manual: truemeans staff settled it by hand (cash or bank transfer); no gateway reference will follow.- Credit notes appear on the order (
creditNotes).
5. Catch cancellations
Section titled “5. Catch cancellations”There is no cancellation event either. On a schedule, re-read with order(number:) every order you still hold as open (not FULFILLED or CANCELED). You can also page orders(status: CANCELED), but that list is ordered by when the order was placed, not when it was cancelled.
6. Reconcile
Section titled “6. Reconcile”Once a day, page orders(first: 100, after: …) back to the start of your reconciliation window and compare. Webhook deliveries can fail for good (see Webhooks), and this sweep is how you catch them.
Things to know
Section titled “Things to know”- All amounts are whole paise in
paise.amountanddisplayare formatted strings for people; don’t do arithmetic on them. - A cart with both in-stock and made-to-order items becomes two orders that share
orderGroupId. You get anORDER_CREATEDfor each. ORDER_FULFILLEDmeans the last item was dispatched, handed to our delivery crew or made ready for pickup. It is not proof of delivery. Part shipments don’t send it.- Orders created when staff finalise a draft order, or when an institutional customer accepts a quote with their purchase-order number, also send
ORDER_CREATED. - Order numbers look like
RFO/2026-27/00042and never change.
See Webhook events for every field in each event.