# The MAM integration

> Connect Commerce Orbit to MAM Software for stock, prices, trade accounts and orders, try it with the sandbox first, and know what happens when MAM is slow, down or switched off.

Source: https://docs.bifrostorbit.com/commerce/everyone/mam-integration/

MAM Software (Autopart and VAST) is a business system many parts and trade suppliers run their stock, accounts and invoicing in. Commerce Orbit can work with it: MAM stays the source of stock, and optionally prices, while your shop sells from Commerce Orbit and sends each order to MAM.

The integration is off until you switch it on, and you can switch it off again at any time. Open it from the sidebar: **MAM integration**, under **Settings**. The connection settings are on its **Settings** tab, in the **Connection** section. Everyone can see the page; Admins change the settings and switch it on and off; Editors can also run a sync and import parts.

## What it does

The ERP connection is in the Growth and Enterprise plans. See [Plans and the trial](https://docs.bifrostorbit.com/commerce/everyone/plans/).

| | How often | What happens |
| --- | --- | --- |
| **Stock** | Every 15 minutes | Stock of every product with a MAM part number comes from MAM, per branch. |
| **Prices** | Every hour, if you choose | The price in your main currency comes from MAM's list price. |
| **Catalogue** | Every day | Checks which MAM parts your shop has. If you choose, adds a draft product for each new part. |
| **Accounts** | Every night | Checks each linked company's and customer's account: on stop or not, credit limit, balance and branch. |
| **Account prices** | While a linked customer shops | Their account's prices and stock, live, kept for 90 seconds. See below. |
| **Orders** | Within a minute of each order | Sends paid orders and orders on invoice to MAM, and stores MAM's document number on the order. |

You can change how often each sync runs: stock from every 5 minutes to once a day, prices from every 15 minutes, catalogue and accounts from every hour, each up to once a week. **Sync now** runs one straight away.

Commerce Orbit asks MAM for up to 50 parts in one request and only takes a part whose number matches exactly, so a similar part number never sets the wrong stock or price.

## Who wins

- **Stock:** MAM. A product with a MAM part number gets its stock from MAM at every stock sync, overwriting changes made here. See [Stock and locations](https://docs.bifrostorbit.com/commerce/everyone/stock-and-locations/).
- **Prices:** your choice. With MAM prices on, a linked product's price in your main currency comes from MAM's list price. With it off, you set prices here. Prices in other currencies are always yours. MAM's prices don't include VAT; when your prices do, Commerce Orbit adds your VAT rate.
- **Text, photos, collections and SEO:** always Commerce Orbit. MAM has no photos or descriptions to send.
- **What an order costs:** MAM's own price, unless you turn on **Send prices with orders**. Then each line goes with what the customer paid, without VAT, and MAM uses it if MAM Software has set it up to take web prices (parameter P950). Either way, make sure the two agree.
- **Trade customers' prices:** for a signed-in customer whose company, or who themselves, is linked to a MAM account, the account's own price from MAM on every page. See [Customers and companies](https://docs.bifrostorbit.com/commerce/everyone/customers-and-companies/#what-a-linked-customer-sees).

## Sandbox and live

**Sandbox** is a pretend MAM built into Commerce Orbit, with Northwilds parts such as `NW-STORM-SHELL-JACKET`, three branches (`OSL`, `BGN` and `TRD`) with different stock at each, and three trade accounts with prices of their own: `NW1001` (Fjellguidene AS, branch `OSL`) pays 15% under list, 22% on tents and 18% on footwear; `NW1002` (Turlaget Nord, `TRD`) 10% under, 20% on packs and 15% on paddling; `NW1003` (Alpin Hütte GmbH, `BGN`) 12% under and 25% on clothing, and is on stop. Its prices are without 19% VAT, like a real MAM's. The Northwilds example data has a buyer for each account to sign in as. Use it to try everything without touching your real MAM. It behaves like the real thing: answers take a moment, one order in eight doesn't answer the first time, and two switches make it act **down** or **slow** (6 seconds an answer), so you can see what your shop does then.

**Live** talks to your MAM's seller services. Every MAM installation is set up differently, so the values come from MAM Software (or your MAM partner) for your company.

## Connect your own MAM

1. Open **MAM integration** in the sidebar, then the **Settings** tab.
2. Under **Connection**, choose **Your MAM**. The connection fields appear below it.
3. Fill them in from the checklist below, then select **Check connection**.
4. When every step shows a tick, select **Save MAM settings**, then switch the integration on at the top of the page.

Until the address, user name and password are saved, and the supplier ID and sender ID if orders go to MAM, the page opens on **Settings** with a **Connect your MAM** card listing what is missing, and the sidebar shows **Set up** next to **MAM integration**.

### What to ask MAM Software for

| Setting | What it is | Example |
| --- | --- | --- |
| **Address** | The address of your seller services. It must start with `https://`; plain `http://` is refused so the password never travels unencrypted. | `https://mam.northwilds.com/SellerServices/SellerServices.asmx` |
| **User name** and **Password** | The seller services user for your web shop. The password is stored encrypted and only shown as its last characters afterwards. | |
| **Supplier ID in MAM** | Who orders and price requests go to: your company as the seller services know it. It can be a number or your company name, exactly as given. | `Northwilds Supply` |
| **Sender ID** | Who the messages come from: the ID given to your web shop, usually a number. | `1001` |
| **Component name** | The application name sent with each message. Keep `MAM AutoPart` unless you are given another. | `MAM AutoPart` |
| **SOAP version** | Which version of SOAP your seller services take. **Automatic** tries 1.2, then 1.1, and remembers what works, so you only change it if told to. | Automatic |
| **Fill flag** | How MAM fills an order it can't supply in full. Keep `backord` unless it is linked to one of your delivery methods. | `backord` |
| **Send prices with orders** | Whether your MAM takes web prices on orders (parameter P950). Off unless MAM Software says yes. | Off |
| **Document types** | Which documents are searched before an order is sent again. Empty searches all; only fill it in if asked. | `I,C,B,U,L,Q` |
| **Branch codes** | The code of each branch, set on your locations. See [Branches](#branches). | `OSL` |

And from your own team, under **Accounts** on the same tab:

- the **web account:** the MAM account that orders from shoppers without a company go to, such as `WEB001`
- the **catalogue account:** the account whose prices and stock syncs use, usually your standard retail account
- optionally a **carriage part:** a part number for shipping, so the shipping charge goes to MAM as a line of its own

**Wait for MAM**, under **Technical**, is how long syncs and orders wait for an answer: 8 seconds unless you change it, from 2 to 60.

### Check connection

**Check connection** tries the values in the form before you save them, and nothing is ordered or changed in MAM. Give it an account to ask about, and a part number to check the IDs with. It shows a tick, a cross or "not checked" for each step:

1. **Address:** MAM is asked whether it is up.
2. **SOAP version:** which version MAM took.
3. **User name and password:** MAM is asked about the account.
4. **Account:** whether MAM knows it.
5. **Supplier ID, sender ID and component:** MAM is asked for the price of the part, in the same kind of message orders use.

A saved password is only used with the address it was saved for. After changing the address, type the password again. See [MAM troubleshooting](https://docs.bifrostorbit.com/commerce/everyone/mam-troubleshooting/#check-connection) for what each cross means.

## Part numbers, accounts and MAM's limits

MAM accepts only short values, and Commerce Orbit checks them before sending:

| Value | Limit | Where you set it |
| --- | --- | --- |
| Part number | 28 characters | On the product, or on each variant |
| Account number | 11 characters | On the company, and the web and catalogue accounts |
| Order reference | 15 characters | Your order prefix plus the order number, such as `NW1042` |

A product with one variant can have its part number on the product; a product with sizes or colours needs one on each variant.

## Signed-in customers

A customer signs in to the shop with their email address, never with an account number. When they or their company are linked to a MAM account, every price and stock figure they see is that account's, asked for live. See [Customers and companies](https://docs.bifrostorbit.com/commerce/everyone/customers-and-companies/#link-a-customer-or-company-to-mam) for linking accounts and what customers see.

Under **Settings**, **Signed-in customers**:

| Setting | What it does |
| --- | --- |
| **Account prices from MAM** | On unless you switch it off. Off, linked customers see their company's price list and the synced stock. |
| **Keep answers for** | How long an account's prices and stock are kept before MAM is asked again, from 15 seconds to 15 minutes. 90 seconds unless you change it. Checkout always asks again. |
| **Wait on a page for** | How long a page waits for MAM before showing your own price, marked as not yet the customer's. 2.5 seconds unless you change it. |
| **Wait at checkout for** | How long checkout waits for MAM's last check. 5 seconds unless you change it. |

How Commerce Orbit keeps this light for MAM:

- Everything on a page is asked for together, up to 50 parts in one request, and two customers of the same account browsing at once share the request.
- Answers are kept per account for the time above, so moving between pages rarely asks MAM again.
- A page never waits longer than you set. Without an answer, it shows your price marked "Standard price: your account price couldn't be checked just now", and asks again when the page is opened next. After MAM fails, it isn't asked again for 30 seconds.
- Only a part whose number matches exactly gets MAM's price. A similar part number never prices the wrong product.

## Branches

Give each location the code of its MAM **branch**, such as `OSL` for the Oslo warehouse. Stock then comes per branch. Without any branch, MAM's total stock goes to your default location. Orders go to MAM with the default location's branch.

## Import parts

MAM has no way to export its catalogue, so you bring parts in under **Find parts**, by searching or from a file.

- **Search:** search by part number, such as `NW-RIDGE`, to see matching parts with their stock and price, and which you already have. **Import** makes a draft product with MAM's description, price and stock, tagged `from-mam`.
- **From a file:** upload a `.csv` or `.txt` file with part numbers in its first column, one per line, up to 500. A first line such as `Part number` is skipped. Each part MAM knows that isn't a product yet becomes a draft product, as **Import** makes it. Afterwards Commerce Orbit says how many were added, how many were already in your catalogue and how many MAM doesn't know.

Part numbers must match MAM's exactly. Add photos and text to the drafts, then make them active.

## Orders and duplicates

Each placed order goes into a queue as it is placed, so nothing is lost if MAM is busy. Commerce Orbit sends it with the order number as MAM's customer reference.

When MAM doesn't answer, Commerce Orbit doesn't know whether the order arrived. Before it tries again, it searches MAM for a document with that reference, and only sends again if there is none. The same check runs when someone sends an order again by hand. So an order is never entered twice.

Tries wait longer each time, from 2 minutes up to 6 hours, for 10 tries in all. See [MAM troubleshooting](https://docs.bifrostorbit.com/commerce/everyone/mam-troubleshooting/) for orders that are held or failed.

You choose whether card orders go to MAM, or only orders on invoice, and you can stop sending orders altogether while keeping stock and prices.

**Hold orders that fail** is off unless you switch it on. On, an order that MAM doesn't take, or that can't be sent at the first try, isn't tried again by itself: it shows **Held** and waits for someone to check it and send it again from the order page. Admins and Editors get a **MAM order** notification for it. Leave it off to let Commerce Orbit keep trying while MAM is away.

## When MAM is slow or down

Guests never wait for MAM: product pages, carts and the storefront API show them the last synced stock and prices. Signed-in customers with a MAM account wait at most the time in the settings, then see your own prices, clearly marked. At checkout, without MAM's answer in time, the price the customer was shown is used if it is still within the time answers are kept; otherwise the company's price list, and the order's history says so.

When a sync fails, the connection shows **Degraded**. After three failures in a row it shows **Down**, and Admins and Editors get a notification, and another when MAM is back. Orders wait in the queue and go to MAM by themselves when it answers again.

## Switch it off and on

**Switch off** stops every call to MAM. Products from MAM become normal products with their last synced stock and prices, which you can change here. New orders aren't queued for MAM. Orders already in the queue wait.

**Switch on** runs every sync straight away and sends the orders that waited. Orders placed while it was off weren't queued; **Orders to MAM** offers to send them. See [MAM troubleshooting](https://docs.bifrostorbit.com/commerce/everyone/mam-troubleshooting/#orders-not-sent-at-all).

## The sync log

The log lists every sync, connection check and order sent, newest first: when it ran, how long it took, how many parts it saw, changed or couldn't find, and MAM's message when something went wrong. The queue lists each order on its way to MAM, with its tries and the last error.
