Metadata-Version: 2.5
Name: entirius-django-checkout-import-from-magento-api
Version: 2.0.1
Summary: Order status import from a Magento 2 store into the Entirius checkout over the Magento REST API
Project-URL: Homepage, https://docs.entirius.com/
Project-URL: Documentation, https://github.com/entirius/entirius-django-checkout-import-from-magento-api/tree/develop/docs
Project-URL: Repository, https://github.com/entirius/entirius-django-checkout-import-from-magento-api
Project-URL: Changelog, https://github.com/entirius/entirius-django-checkout-import-from-magento-api/releases
Project-URL: Issues, https://github.com/entirius/entirius-django-checkout-import-from-magento-api/issues
Author: Entirius
License-Expression: MPL-2.0
License-File: LICENSE
Keywords: checkout,django,ecommerce,entirius,magento,magento2,order-status
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business
Requires-Python: >=3.11
Requires-Dist: django>=5.0
Requires-Dist: entirius-django-checkout>=9.0.0
Requires-Dist: entirius-py-bievents>=2.0.0
Requires-Dist: entirius-py-magento2-sdk>=2.0.0
Provides-Extra: dev
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: test
Requires-Dist: dj-database-url; extra == 'test'
Requires-Dist: psycopg[binary]; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-django; extra == 'test'
Description-Content-Type: text/markdown

# entirius-django-checkout-import-from-magento-api

A Django module that imports order statuses from a Magento 2 store into
Entirius, the open-source modular ecommerce platform, over REST. It is the return path of the order export: Magento
processes the order and its status comes back to the checkout.

[![PyPI](https://img.shields.io/pypi/v/entirius-django-checkout-import-from-magento-api.svg)](https://pypi.org/project/entirius-django-checkout-import-from-magento-api/)
[![Python](https://img.shields.io/pypi/pyversions/entirius-django-checkout-import-from-magento-api.svg)](https://pypi.org/project/entirius-django-checkout-import-from-magento-api/)
[![License: MPL-2.0](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/entirius/entirius-django-checkout-import-from-magento-api/blob/develop/LICENSE)

## What it does

- Reads the Magento status of one order, or of every order created in the last days.
- Updates the checkout order when Magento reports it on hold, canceled or complete.
- Confirms a processing order once Magento holds an invoice for it.
- Keeps the Magento response, a success flag and the attempt count per order.

## Installation

```shell
uv add entirius-django-checkout-import-from-magento-api
pip install entirius-django-checkout-import-from-magento-api
```

```python
INSTALLED_APPS = [
    ...
    "django_checkout",
    "django_checkout_import_from_magento_api",
]
```

`django_checkout` brings its own app requirements. Required settings: `MAGENTO2_URL_FOR_CHECKOUT_EXPORT` and
`MAGENTO2_TOKEN_FOR_CHECKOUT_EXPORT`.
The module also reads `BI_ENVIRONMENT` and `BI_BUSINESS_UNIT` (BI events) at import time, without a default.

Both settings are shared with `entirius-django-checkout-export-to-magento-api`: one Magento endpoint serves the
export and the status import. Reference: https://github.com/entirius/entirius-django-checkout-import-from-magento-api/blob/develop/AGENTS.md (section Settings).

## Quick start

```python
# settings.py
MAGENTO2_URL_FOR_CHECKOUT_EXPORT = "https://magento.example.com/rest/"
MAGENTO2_TOKEN_FOR_CHECKOUT_EXPORT = "<api-token>"

# a shell or a scheduled job
from django.core.management import call_command

call_command("import-orders-status-from-magento", days=7)
```

`days` is how far back orders are looked up by creation date (default 1). One order:
`import-order-status-from-magento <order_id>`.

## Requirements

- Python 3.11 or newer, Django 5.0 or newer.
- PostgreSQL.
- A Magento 2 store with a REST API integration token.
- Entirius packages pulled in: `entirius-django-checkout` (orders and status updates), `entirius-py-magento2-sdk`
  (Magento 2 REST client), `entirius-py-bievents` (BI events).

## Documentation

- Module docs (management commands, process logging): https://github.com/entirius/entirius-django-checkout-import-from-magento-api/tree/develop/docs
- Entirius documentation: https://docs.entirius.com/
- Releases: https://github.com/entirius/entirius-django-checkout-import-from-magento-api/releases

## Part of Entirius

This module runs inside the Entirius backend service (Volkanos) and reads order statuses back from an existing
Magento 2 store.

- Backend service: https://github.com/entirius/entirius-service-volkanos
- Docker harness: https://github.com/entirius/entirius-zeno
- Checkout module: https://github.com/entirius/entirius-django-checkout
- Magento 2 SDK it uses: https://github.com/entirius/entirius-py-magento2-sdk
- Sibling bridges: https://github.com/entirius/entirius-django-checkout-export-to-magento-api,
  https://github.com/entirius/entirius-django-pim-export-to-magento-api,
  https://github.com/entirius/entirius-django-accounts-export-to-magento-api

## Development

```shell
make install     # sync dependencies (uv)
make check       # lint + format check (ruff)
make test        # test suite (pytest + pytest-django, needs PostgreSQL via DATABASE_URL)
```

Development and agent instructions: https://github.com/entirius/entirius-django-checkout-import-from-magento-api/blob/develop/AGENTS.md

## License

Mozilla Public License 2.0 (MPL-2.0) — see https://github.com/entirius/entirius-django-checkout-import-from-magento-api/blob/develop/LICENSE.
