JavaScript, Python and Postman examples
Download the examples from Resources. Run them on your server with MEREU_API_URL=https://mereu.md/api/v1 and the key in MEREU_API_KEY.
| File | Purpose |
|---|---|
| mereu-client.mjs / mereu-client.py | Authentication, requests and GET query encoding. |
| crm-sync.mjs / crm-sync.py | One snapshot or changes page with a durable checkpoint. |
| pos-checkout.mjs | Reservation, sale commit, purchase import and refunds. |
| mereu-postman.json | Manual requests with references, UUIDs and amounts to fill in. |
For Python imports, rename the modules to mereu_client.py and crm_sync.py. Python module names cannot contain hyphens.
- CRM: load the saved state and call
syncMereuPage(api, resource, state, commitPage)orsync_mereu_page(api.request, resource, state, commit_page). state=null/Nonestarts a snapshot. Each call processes ONE page and returnsphaseandcursor.- In the callback, reset staging on
reset=true, add non-deleted rows and replace the active dataset only oncomplete=true. In changes mode, apply inserts, updates and deletes. - Commit the checkpoint with the data in one transaction. Let save errors propagate. Schedule the next page in your job queue within the request limit.
- POS:
prepareCheckoutsends only preview, reservation and payment-started through your durablepersistcallback. - Supply UUIDs from your persisted order. Start payment in your system only after the function succeeds and the journal commits.
- After verifying payment, call
commitVerifiedPayment. UserecordVerifiedPurchasefor paid imports andrecordVerifiedReturnfor verified returns. - A journal failure after a response may mean the operation was already applied. Recover the saved request and read its status before replaying it.
In Postman, fill the empty variables and integer money amounts. For commit, copy expected_paid_total from the quote and the revision from payment-started. For refunds, use the original eligible allocation and actual returned cash.