--- title: "ERP integration playbook for synchronizing cancellations" slug: "erp-integration-playbook-for-synchronizing-cancellations" tags: ["integration", "api", "platform", "events", "ERP integration", "order", "event stream ", "developer", "newstore platform", "order cancellation"] updated: 2024-12-30T17:15:21Z published: 2024-12-30T17:15:21Z canonical: "docs.newstore.com/erp-integration-playbook-for-synchronizing-cancellations" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.newstore.com/llms.txt > Use this file to discover all available pages before exploring further. # ERP integration playbook for synchronizing cancellations NewStore allows you to create financial transactions in an ERP system and sync them with the NewStore platform for all order cancellations. This integration playbook helps you integrate an ERP system used in your business with the NewStore platform, to sync all order cancellations. The integration is achieved via the [Event Stream](/v1/docs/receiving-real-time-data#event-stream). For each order placed in the NewStore platform that is canceled, a credit-memo transaction is created in the ERP, which includes: - Canceled items with prices and taxes - Payment and invoice details of the original order ## Process overview The following sequence diagram represents a typical integration of canceled orders in the NewStore platform with an ERP: In this playbook: 1. NewStore sends the `order.items_cancelled` event when order cancelation has been completed. 2. The integration fetches all necessary details via `graphql`. Payments are processed asynchronously, therefore it may take some time until all payment details are available. 3. The integration requests for the details of the original sales order by calling the [NetSuite Web Services](https://docs.oracle.com/en/cloud/saas/netsuite/nsoa-online-help/toc.htm). 4. The integration requests for the details of the invoice of the original sales order by calling the [NetSuite Web Services](https://docs.oracle.com/en/cloud/saas/netsuite/nsoa-online-help/toc.htm). 5. The integration creates the credit memo transaction in the ERP by calling the ERP's API. ## Exceptions ### ERP unavailable The integration returns a 500 error, and the [Event stream](https://docs.newstore.net/api/webhooks/stream_webhook_sink_hook) retries sending the macro event. ### Payment details unavailable In some cases, it takes more than a few seconds until payment processing at the `PSP` has been completed and the payment details become available in the platform. The integration moves the event into an internal queue (for example, SQS) for to reprocess later, and returns `200`. ## Sample GraphQL Query Here is an example [GraphQL](/v1/docs/graphql-api#graphql) query to retrieve all the information required to create a credit memo transaction in the ERP. ```plaintext query MyQuery {  order(id: "012345Ab-CdEf-GhIj-KlMn-OpQrStUvWxYz", tenant: "dodici") {    externalId    placedAt    demandLocationId    currency    isExchange    isHistorical    channel    channelType    shippingTax    shippingTotal    taxExempt    taxStrategy    taxTotal    subtotal    grandTotal    discounts {      edges {        node {          couponCode        }      }    }    paymentAccount {      instruments {        edges {          node {            paymentMethod            paymentOrigin            paymentProvider            paymentAccountTransactions {              edges {                node {                  amount                  currency                  transactionType                }              }            }          }        }      }    }    items {      edges {        node {          productId          quantity          pricebookPrice          itemDiscounts          orderDiscounts          tax          shippingServiceLevel          fulfillmentLocationId        }      }    }  } } ``` ## ERP integration example with NetSuite For integrations with NetSuite as an ERP system for cancellations, see this [example](/v1/docs/erp-integration-example-with-netsuite-for-cancellations#erp-cancellation-example). **Related topics** - [ERP integration playbook to sync returns](/v1/docs/erp-integration-playbook-to-sync-returns#integ-erp-playbook-returns) - [ERP integration playbook to sync appeasement refunds](/v1/docs/erp-integration-playbook-to-sync-appeasement-refunds#integ-erp-playbook-appeasement) - [ERP integration playbook to sync endless-aisle orders](/v1/docs/erp-integration-playbook-to-sync-endless-aisle-orders#integ-erp-playbook-endless-aisle) - [ERP integration playbook to sync in-store purchases](/v1/docs/erp-integration-playbook-to-sync-in-store-purchases#integ-erp-playbook-instore) - [ERP integration example with NetSuite for cancellations](/v1/docs/erp-integration-example-with-netsuite-for-cancellations#erp-cancellation-example) - [Integrating a payment service provider](/v1/docs/integrating-a-payment-service-provider#integ-psp) - [GraphQL API](/v1/docs/graphql-api#graphql)