Commit graph

1 commit

Author SHA1 Message Date
opencode
0125da76d0 feat(pry): shopify_oauth helper + commerce_sync accepts code flow
Add shopify_oauth.py with the three primitives needed to ship Pry as a
Shopify public app:
  - install_url()        — build the authorize URL with state nonce
  - exchange_code()      — trade callback code for offline access token
  - verify_webhook_hmac() — verify X-Shopify-Hmac-SHA256 on webhooks

Refactor commerce_sync.sync_to_shopify to accept either a static
access_token (current callers) or a (code, shop_domain, api_key,
api_secret) tuple. When the code flow is used the access token is
exchanged transparently via shopify_oauth.exchange_code() before the
product POST loop runs. Empty credentials still return a graceful
{"success": False, ...} dict (existing test contract preserved).

Tests: test_commerce_sync.py (2 pass); install_url sanity-checked in REPL.
2026-07-06 20:33:36 +07:00