Skip to content

Add API to get products from a store receipt - #12

Open
amuelli wants to merge 1 commit into
aliyss:masterfrom
amuelli:feat/receipt-products
Open

amuelli wants to merge 1 commit into
aliyss:masterfrom
amuelli:feat/receipt-products

Conversation

@amuelli

@amuelli amuelli commented Nov 12, 2026

Copy link
Copy Markdown

Summary

Adds support for the store receipt products endpoint:

GET https://account.migros.ch/ma/api/user/receipt/{transactionId}/product

This returns the products of a Cumulus receipt grouped by category as JSON, complementing the existing getCumulusReceipts (list) and getCumulusReceipt (HTML detail) methods.

Changes

  • src/api/cumulus/receipts.ts — new getCumulusReceiptProducts({ transactionId }, cookies) plus the ICumulusReceiptProductsOptions interface.
  • src/api/interfaces/receipts.ts — typed response interfaces (ICumulusReceiptProduct, ICumulusReceiptProductsResponse, etc.) matching the observed API payload.
  • src/api/MigrosAPI.ts — instance method MigrosAPI.account.cumulus.getCumulusReceiptProducts(...).
  • src/index.ts — exports ICumulusReceiptProductsOptions.
  • tests/cumulus-receipt-products.test.ts — integration test following the existing receipt test pattern.
  • README.md — documents the new method with a usage example.

Important detail

Unlike the existing receipt endpoints, this /product endpoint requires the X-MA-INITIATOR: migros-online header in addition to the CSRF token; without it Migros responds with HTTP 500. This was captured from the browser request (HAR) and is now set in the request headers.

Bug fix

getCumulusReceipt read the receipt id from cumulusReceiptOptions.receiptId, but the option is declared (and documented) as transactionId, so the HTML receipt request was hitting an /undefined URL. Fixed to use transactionId.

Notes

  • energyEfficiency and version are typed as string | null; both were null in the captured response, so they are intentionally loose.

Implements the account.migros.ch receipt products endpoint
(`GET /ma/api/user/receipt/{transactionId}/product`), which returns the
products of a Cumulus receipt grouped by category as JSON.

This endpoint requires the `X-MA-INITIATOR: migros-online` header in
addition to the CSRF token, otherwise it responds with HTTP 500.

Also fixes a bug in getCumulusReceipt which read the receipt id from
`receiptId` instead of the declared `transactionId` option, causing the
HTML receipt request to hit an `/undefined` URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant