Skip to main content

Acumatica Middleware

note

The following describes general usage, if you setup your project following getting-started/install then these next steps have already been handled for you.

Acumatica's Plugins depend on @acromedia/gesso-acumatica-middleware to make calls to your Acumatica instance.

Installation

  • pnpm install @acromedia/gesso-acumatica-middleware

Setup

You need an API route setup that loads the Acumatica middleware, the starter kit provides this by default. If Acumatica is not already setup as a provider you should set it up like so.

// src/pages/api/middleware/[...slug].ts
import middleware from '@acromedia/gesso-api-middleware';

import platfromProvider from '@acromedia/gesso-<provider>';
import acumaticaProvider from '@acromedia/gesso-acumatica-middleware';

const providers = {
<commerce platfrom>: platformProvider
acumatica: acumaticaProvider,
};

export default middleware(providers);

Usage

Hooks from the ERP provider that return customer specific data such as Invoices require the user to be logged in. This can be done with the useCustomer hook from your commerce provider.

import commerce from ./commerce;

const { useCustomer } = commerce;

const { login } = useCustomer();

login(email, password);

Once the user is logged in you can use the customer specific ERP hooks. The useCustomer hook will do this automatically to provide the customer object.

info

If you haven't already setup the ERP provider for Acumatica please read these docs.