# 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: ```bash 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: 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: Created Google Wallet object: Enrolled customer X in merchant Y loyalty program ``` ### Option B — Customer self-enrollment (storefront) 1. Go to: 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 ```sql -- 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 = ; ``` Both `google_class_id` and `google_object_id` should be non-null. --- ## Step 5: Test the storefront dashboard (wallet button) 1. Go to: 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 (), add a stamp or earn points for the enrolled customer's card. Watch terminal for: ``` Updated Google Wallet object for card ``` 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) | | | Storefront | | | Admin panel | |