--- title: "ERP integration playbook to sync in-store purchases" slug: "erp-integration-playbook-to-sync-in-store-purchases" tags: ["integration", "api", "platform", "events", "ERP integration", "in-store pickup", "selling experience", "event stream ", "developer", "newstore platform"] updated: 2025-02-26T20:03:53Z published: 2025-02-26T20:03:53Z canonical: "docs.newstore.com/erp-integration-playbook-to-sync-in-store-purchases" --- > ## 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 to sync in-store purchases NewStore allows you to create financial transactions in an ERP system and sync them with the NewStore platform for all store orders (in-store purchases). This integration playbook helps you integrate an ERP system used in your business with the NewStore platform, to sync all in-store purchases. The integration is achieved via the [Event Stream](/v1/docs/receiving-real-time-data#event-stream). For each in-store order placed in the NewStore platform, a sales transaction is created in the ERP, which includes: - Purchased items with prices and taxes - Payment details ## Process overview The following sequence diagram represents a typical integration of in-store orders in the NewStore platform with an ERP: ![](https://cdn.document360.io/c2d22fcd-a44b-4e1e-bf3a-84f0ffba0dbe/Images/Documentation/ERP integration playbook to sync in-store purchases.svg?sv=2026-02-06&spr=https&st=2026-11-06T08%3A52%3A43Z&se=2026-11-06T09%3A52%3A43Z&sr=c&sp=r&sig=8Q6IJ%2BR4WXVbxtIZjWRiLB%2FcqkSQh6%2BIZdddKYoSZBo%3D) In this playbook: 1. NewStore sends the `order.opened` event when the in-store purchase has been completed. 2. The integration fetches all necessary details via [GraphQL API](/v1/docs/graphql-api#graphql). Payments are processed asynchronously, therefore it may take some time until all payment details are available. 3. The integration creates a cash and carry sales transaction in the ERP by calling the ERP's API. ## Exceptions ### ERP unavailable The integrations 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`. ## Exchange orders The integration needs the store credit information to create a balanced transaction in the ERP. Consider adding store credit transactions to external payment events. To identify an exchange order, see [Event Stream documentation](/v1/docs/receiving-real-time-data#event-stream). ## Sample GraphQL Query Here is an example [GraphQL](/v1/docs/graphql-api#graphql) query to retrieve all the information required to create a cash and carry sales 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        }      }    }  } } ``` The below is an example of a bad GraphQL query because it uses multiple contexts, and calls the same data in a nested format. All of these can slow down the response times and cause timeouts and slow down the integration. ```plaintext query MyQuery {  order(id: "012345Ab-CdEf-GhIj-KlMn-OpQrStUvWxYz", tenant: "dodici") {    channelType    channel    externalId  }  paymentAccount(id: "012345Ab-CdEf-GhIj-KlMn-OpQrStUvWxYz", tenant: "dodici") {    externalOrderId    instruments {      edges {        node {          id        }      }    }    order {      channel      channelType      externalId    }  }  fulfillmentRequestItem(fulfillmentRequestId: "012345Ab-CdEf-GhIj-KlMn-OpQrStUvWxYz", id: "012345Ab-CdEf-GhIj-KlMn-OpQrStUvWxYz", tenant: "dodici") {    carrier    productId  } } ``` ## ERP integration example with NetSuite For integrations with NetSuite as an ERP system for endless aisle orders, see this [example](/v1/docs/erp-integration-example-with-netsuite-for-in-store-purchases#erp-instore-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 for synchronizing cancellations](/v1/docs/erp-integration-playbook-for-synchronizing-cancellations#integ-erp-playbook-cancellation) - [ERP integration example with NetSuite for in-store purchases](/v1/docs/erp-integration-example-with-netsuite-for-in-store-purchases#erp-instore-example) - [Integrating a payment service provider](/v1/docs/integrating-a-payment-service-provider#integ-psp) - [GraphQL API](/v1/docs/graphql-api#graphql)