Files
orion/docs/proposals/google-wallet-local-testing.md
Samir Boulahtit 32e4aa6564 feat: wire Google Wallet into loyalty enrollment, stamps, and points flows
Connect the fully-implemented Google Wallet service to the loyalty module:
- Create wallet class/object on customer enrollment
- Sync wallet passes on stamp and points operations
- Expose wallet URLs in storefront API responses
- Add conditional "Add to Google Wallet" buttons on dashboard and enroll-success pages
- Use platform-wide env var config (not per-merchant DB column)
- Add Google service account patterns to .gitignore
- Add LOYALTY_GOOGLE_* fields to app Settings
- Update deployment docs and add local testing guide

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 10:38:46 +01:00

4.1 KiB

Google Wallet Local Testing — Step-by-Step

All code wiring is complete. This guide walks through end-to-end local testing.

Prerequisites

.env must have:

LOYALTY_GOOGLE_ISSUER_ID=3388000000023089598
LOYALTY_GOOGLE_SERVICE_ACCOUNT_JSON=/home/samir/Documents/PycharmProjects/letzshop-product-import/orion-488322-2232195cbb62.json

Start the server:

python3 -m uvicorn main:app --reload --host 0.0.0.0 --port 8000

No startup errors expected.


Step 1: Log into the FASHIONHUB store panel

URL: http://localhost:8000/platforms/loyalty/store/FASHIONHUB/login

Log in with store credentials.


Step 2: Verify a loyalty program exists

In the store dashboard, check that an active loyalty program exists with stamps or points enabled.

If none exists, create one from Settings > Loyalty:

  • Name: e.g. "Fashion Rewards"
  • Stamps target or Points mode: enable at least one
  • Welcome bonus points: optional, set to e.g. 50 to test points on enrollment

Step 3: Enroll a test customer

Two options:

Option A — Staff enrollment (store panel)

In the store dashboard, go to Loyalty, use "Enroll Customer" by email or customer ID.

Watch terminal for:

Created Google Wallet class: <class_id>
Created Google Wallet object: <object_id>
Enrolled customer X in merchant Y loyalty program

Option B — Customer self-enrollment (storefront)

  1. Go to: http://localhost:8000/platforms/loyalty/storefront/FASHIONHUB/
  2. Log in as a customer (or create an account)
  3. Navigate to Loyalty > "Join Now"
  4. After enrollment, you land on the enroll-success page
  5. Watch terminal for the same Google Wallet creation logs

Step 4: Verify DB records

-- Program should have google_class_id populated
SELECT id, name, google_issuer_id, google_class_id FROM loyalty_programs;

-- Card should have google_object_id populated
SELECT id, card_number, google_object_id, google_object_jwt
FROM loyalty_cards WHERE customer_id = <your_customer_id>;

Both google_class_id and google_object_id should be non-null.


Step 5: Test the storefront dashboard (wallet button)

  1. Go to: http://localhost:8000/platforms/loyalty/storefront/FASHIONHUB/
  2. Log in as the enrolled customer
  3. Go to Account > My Loyalty
  4. Click "Show Card" — a modal appears
  5. The "Add to Google Wallet" button (blue) should be visible
  6. Click it — opens https://pay.google.com/gp/v/save/... in a new tab

If the button doesn't appear, check browser devtools > Network > GET /storefront/loyalty/card response and look at wallet_urls.google_wallet_url.


Step 6: Test stamp/points sync

From the store panel (http://localhost:8000/platforms/loyalty/store/FASHIONHUB/), add a stamp or earn points for the enrolled customer's card.

Watch terminal for:

Updated Google Wallet object for card <card_id>

This confirms the wallet pass updates on the customer's phone in real time.


Step 7: Verify the save URL works

The "Add to Google Wallet" URL is JWT-signed. Behaviour:

  • Demo/test mode (before Google approves your issuer): preview page with unverified issuer warning — this is normal
  • Android: pass gets added to Google Wallet app
  • Desktop: Google shows a "Send to phone" option

Troubleshooting

Symptom Check
No wallet logs on enrollment Verify LOYALTY_GOOGLE_ISSUER_ID and LOYALTY_GOOGLE_SERVICE_ACCOUNT_JSON are set in .env
"Google Wallet not configured" in logs Service account JSON file path is wrong or file is unreadable
Button doesn't appear on dashboard Check GET /storefront/loyalty/card response in devtools — wallet_urls should have a URL
403 from Google API Service account doesn't have Wallet API permissions, or issuer ID mismatch
JWT URL opens but shows error Issuer account may not be approved yet — normal for testing

Key URLs

Panel URL
Store panel (FASHIONHUB) http://localhost:8000/platforms/loyalty/store/FASHIONHUB/login
Storefront http://localhost:8000/platforms/loyalty/storefront/FASHIONHUB/
Admin panel http://localhost:8000/admin/login