# highermark — Next Steps Implementation Guide

> This file is your single source of truth for getting all integrations live.
> Follow each section in order. Locations of every file you need to update are listed explicitly.

---

## 0. Prerequisites

Before anything else, set up **Infisical** (free tier) to store all secrets:

1. Sign up at https://infisical.com
2. Create a project called `highermark`
3. Create environments: `development`, `production`
4. Install the CLI: `npm install -g @infisical/cli`
5. Run `infisical init` in the repo root
6. Add each secret (see sections below) via the Infisical dashboard — **never paste real keys into any `.html` or `.md` file**
7. To inject secrets at build time: `infisical run -- npm run build`

**Why Infisical?**
All environment variables in this project are placeholders. Real keys are rotated regularly and injected at deploy time via environment variables — they are never committed to git or visible on the frontend. The staff dashboard shows placeholder fields only; actual keys live in Infisical / Vercel env vars.

---

## 1. Resend (Email — orders, confirmations, notifications)

**What it does:** Sends order confirmation emails to customers and notification emails to jim@highermark.xyz when a reservation or order form is submitted.

**Sign up:** https://resend.com  
**Docs:** https://resend.com/docs

### Steps

1. Create account at resend.com
2. Verify your domain `highermark.xyz` (add DNS TXT + MX records)
3. Generate an API key under Settings → API Keys
4. **Add to Infisical:** `RESEND_API_KEY=re_xxxx`
5. **Add to Vercel:** Dashboard → Project → Settings → Environment Variables → `RESEND_API_KEY`

### Files to update

| File | What to add |
|------|-------------|
| `api/send-confirmation.js` (create) | Resend SDK call, triggered by Stripe webhook or form submit |
| `api/notify-staff.js` (create) | Sends jim@highermark.xyz a summary on any order |
| `vercel.json` | Add API routes if using Vercel serverless |

### Email triggers

| Event | Recipient | Template |
|-------|-----------|----------|
| User submits order form (Lightning) | User + jim@highermark.xyz | Order summary with event details |
| User submits order form (Card) | User + jim@highermark.xyz | Order summary with Stripe ref |
| Stripe payment confirmed (webhook) | User + jim@highermark.xyz | Payment confirmation + next steps |
| Strike Lightning payment confirmed | jim@highermark.xyz | Lightning payment alert |

### Resend SDK example (Node.js)

```js
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);

await resend.emails.send({
  from: 'highermark <no-reply@highermark.xyz>',
  to: [customerEmail],
  subject: 'Your reservation — New York Nodes in The Sky',
  html: `<p>Hi ${name},</p><p>Your reservation is confirmed...</p>`,
});
```

---

## 2. Stripe (Card payments)

**Sign up:** https://dashboard.stripe.com  
**Docs:** https://stripe.com/docs/webhooks

### Steps

1. Create Stripe account
2. Get API keys: Developers → API keys
3. Create webhook endpoint: Developers → Webhooks → Add endpoint
   - URL: `https://highermark.xyz/api/stripe-webhook`
   - Events: `checkout.session.completed`, `payment_intent.succeeded`
4. **Add to Infisical:**
   - `STRIPE_SECRET_KEY=sk_live_xxxx`
   - `STRIPE_WEBHOOK_SECRET=whsec_xxxx`
   - `STRIPE_PUBLISHABLE_KEY=pk_live_xxxx`

### Files to update

| File | What to add |
|------|-------------|
| `api/stripe-webhook.js` (create) | Verify signature, trigger Resend email, log to reservations |
| `vercel.json` | Route `/api/stripe-webhook` |

### Existing Stripe links (already live)
- NY Nodes card: `https://buy.stripe.com/7sY8wPaLY8r1drMgAb43S0e`
- Raleigh card: `https://buy.stripe.com/eVq3cvbQ2az987s5Vx43S0f`

---

## 3. Strike API (Lightning payment tracking)

**What it does:** Detects when a Lightning invoice is paid and triggers email/reservation logging.

**Sign up:** https://developer.strike.me  
**Docs:** https://developer.strike.me/en/docs

### Steps

1. Create Strike developer account
2. Generate API key
3. Create a webhook subscription for `payment.updated` events
4. **Add to Infisical:** `STRIKE_API_KEY=xxxx`
5. Create endpoint `api/strike-webhook.js` to receive payment events

### Files to update

| File | What to add |
|------|-------------|
| `api/strike-webhook.js` (create) | Verify, log payment, trigger Resend notification |
| `docs/reservations.md` | Manual log until webhook is live |

---

## 4. Cerebras API (Fast LLM inference for highermark AI)

**Sign up:** https://api.cerebras.ai  
**Docs:** https://inference-docs.cerebras.ai

### Steps

1. Sign up and generate API key
2. **Add to Infisical:** `CEREBRAS_API_KEY=xxxx`
3. Models to use: `llama3.1-8b` (fast/cheap), `llama3.1-70b` (capable)
4. Update `highermark-ai.html` → replace simulated responses with real API calls via a serverless function

### Files to update

| File | What to add |
|------|-------------|
| `api/cerebras-chat.js` (create) | Proxy endpoint that calls Cerebras, returns streamed response |
| `highermark-ai.html` | Replace `simulateStream()` with `fetch('/api/cerebras-chat', {...})` |
| `docs/cerebrasapi.md` | Already exists — update with your API key name |

---

## 5. OpenRouter API (Multi-model routing)

**Sign up:** https://openrouter.ai  
**Docs:** https://openrouter.ai/docs

### Steps

1. Create account, get API key
2. **Add to Infisical:** `OPENROUTER_API_KEY=sk-or-v1-xxxx`
3. Create `api/openrouter-chat.js` proxy
4. Wire column 2 (OpenRouter) in `highermark-ai.html` to this endpoint

### Files to update

| File | What to add |
|------|-------------|
| `api/openrouter-chat.js` (create) | Proxy to OpenRouter with model selection |
| `highermark-ai.html` | Column 2 calls `fetch('/api/openrouter-chat', {...})` |

---

## 6. Grok API / X Auth (for Hermes & @jimsbr integration)

**Sign up:** https://x.ai  (Grok API) + https://developer.twitter.com (X Auth)  
**Docs:** https://docs.x.ai/docs

### Steps

1. Apply for Grok API access at https://x.ai
2. Get X developer app credentials for OAuth (for Hermes agent flows)
3. **Add to Infisical:**
   - `GROK_API_KEY=xai-xxxx`
   - `X_CLIENT_ID=xxxx`
   - `X_CLIENT_SECRET=xxxx`
4. Wire column 3 (Claude/Grok) in `highermark-ai.html` when ready

### Files to update

| File | What to add |
|------|-------------|
| `api/grok-chat.js` (create) | Proxy to Grok API |
| `api/x-auth.js` (create) | OAuth flow for X/Hermes |
| `docs/highermarkarchitectureone.md` | Already exists, update Grok section |

---

## 7. Reservation Tracking

Until webhooks are fully live, reservations are tracked in `docs/reservations.md`.

Once Resend + Stripe webhooks are live, auto-populate a database (Supabase free tier recommended):

1. Sign up at https://supabase.com
2. Create table `reservations` with columns: `id, event, name, contact, payment_method, amount, created_at, confirmed`
3. **Add to Infisical:** `SUPABASE_URL=xxxx` and `SUPABASE_ANON_KEY=xxxx`
4. Update webhook handlers to insert rows on payment confirmation

---

## 8. Vercel Deployment

```bash
# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

# Set environment variables (one-time, or use Infisical sync)
vercel env add RESEND_API_KEY production
vercel env add STRIPE_SECRET_KEY production
vercel env add STRIKE_API_KEY production
# ...etc
```

**Infisical → Vercel sync:**  
Use the Infisical Vercel integration: https://infisical.com/docs/integrations/cloud/vercel
This auto-syncs your Infisical secrets to Vercel env vars on each deploy.

---

## 9. GTM (Go To Market) — Channels

Placeholders until content is ready. Update links as channels launch:

| Channel | Status | Link |
|---------|--------|------|
| X / Twitter | Active — @jimsbr | https://x.com/jimsbr |
| Discord | Pending | — |
| Reddit | Pending | — |
| Instagram | Pending | — |
| Facebook | Pending | — |
| TikTok | Pending | — |

---

---

## 10. Stripe Payment Intents — X Multiplayer + Premium Tiers

**Products to create in Stripe Dashboard → Products:**

| Product | Price | Description |
|---------|-------|-------------|
| X Multiplayer Access | $2.00 | One-time, local extension download |
| X Multiplayer Premium Gift | $24.00 | 3 months gifted premium to customer account |

### Steps

1. Go to [Stripe Dashboard → Products](https://dashboard.stripe.com/products)
2. Create each product above with one-time pricing
3. Copy the `price_` ID for each product → add to Infisical:
   - `STRIPE_PRICE_XMP_2=price_xxxx`
   - `STRIPE_PRICE_XMP_24=price_xxxx`
4. Create `api/create-payment-intent.js` (see scaffold below)
5. Update `xmultiplayer.html` → replace `STRIPE_LINKS` with your new backend endpoint calls

### Backend Scaffold (`api/create-payment-intent.js`)

```js
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

export default async function handler(req, res) {
  const { tier } = req.body;
  const prices = {
    'xmp-2':  { amount: 200,  desc: 'X Multiplayer access — local extension' },
    'xmp-24': { amount: 2400, desc: 'X Multiplayer — 3mo gifted premium' },
  };
  const p = prices[tier];
  if (!p) return res.status(400).json({ error: 'unknown tier' });

  const intent = await stripe.paymentIntents.create({
    amount: p.amount,
    currency: 'usd',
    description: p.desc,
    automatic_payment_methods: { enabled: true },
    metadata: { tier, source: 'xmultiplayer', timestamp: Date.now() },
  });
  res.json({ clientSecret: intent.client_secret });
}
```

### Webhook: auto-deliver on payment_intent.succeeded

```js
// api/stripe-webhook.js — add this case:
case 'payment_intent.succeeded': {
  const { tier, source } = event.data.object.metadata;
  if (source === 'xmultiplayer') {
    // 1. Log to Supabase reservations table
    // 2. Send download link via Resend to customer email
    // 3. DM @jimsbr via notification if needed
    await resend.emails.send({
      from: 'highermark <no-reply@highermark.xyz>',
      to: [customerEmail],
      subject: tier === 'xmp-24' ? 'X Multiplayer Premium — activating your 3 months' : 'X Multiplayer — your access link',
      html: `<p>Payment confirmed. DM @jimsbr on X with your proof to receive your download link and onboarding.</p>`,
    });
  }
}
```

---

## 11. Arkade.money — QR Code & Invoice Integration

Arkade (`arkade.money`) is used for the **$85.21 Lightning checkout** on the pre-order page. Here's how to wire it fully so every product has a live Arkade QR and invoice.

### What Arkade does

- Generates Lightning invoices tied to product orders
- Provides a hosted checkout page that opens in Lightning wallets
- Can webhook your backend when payment is confirmed
- No KYC required; connects to your own node or a custodial fallback

### How to turn on Arkade QR codes for your products

1. **Create an Arkade account** at [arkade.money](https://arkade.money)
2. **Connect your Lightning node** (LND, CLN, or custodial) in Arkade → Settings → Node
3. **Create a product** for each price point:
   - `$85.21` — highermark device pre-order (Lightning)
   - `$950` — Raleigh Nodes by the Rye (Lightning)
   - `$1,950` — New York Nodes in The Sky (Lightning)
   - `$2` — X Multiplayer access (Lightning)
4. **Copy the product deep link** (format: `https://arkade.money/p/YOUR_PRODUCT_ID`)
5. **Wire it into the site:**
   - In `assets/js/pay.js` → find `arkadeBtn` → replace `href` with your Arkade product URL
   - For node pages: find the `<a href="bitcoin:bc1p...lightning=lnbc..." ...>` deep links and replace with Arkade deep links
6. **Generate QR codes** for each product:
   - Use Arkade's built-in QR embed, OR
   - Run the Python script in `docs/infraforlightning.md §3a` using your Arkade LNURL as the data

### Current price points with Arkade integration

| Product | Amount | File | Element |
|---------|--------|------|---------|
| Device pre-order Lightning | $85.21 | `index.html` | `id="mainQrImg"` + `assets/qr/qr_850.svg` |
| Raleigh Nodes | $950 | `raleigh-nodes.html` | `id="rlUri"` + `assets/img/qr-raleigh-lightning.png` |
| NY Nodes | $1,950 | `ny-nodes.html` | `id="nyLnurl"` + inline QR |
| X Multiplayer | $2 | `xmultiplayer.html` | Lightning address section |

### Arkade webhook (auto-fulfill on payment)

```js
// api/arkade-webhook.js
export default async function handler(req, res) {
  // Verify Arkade signature (check Arkade docs for header name)
  const { product_id, amount, payer_note } = req.body;
  // Log payment, trigger Resend, update Supabase
  res.json({ received: true });
}
```

**Add to Infisical:**
- `ARKADE_API_KEY=your_arkade_key`
- `ARKADE_WEBHOOK_SECRET=your_webhook_secret`

---

## Quick Checklist

- [ ] Infisical project created, all secrets added
- [ ] Resend account + domain verified
- [ ] `api/send-confirmation.js` created and deployed
- [ ] Stripe webhook endpoint live and verified
- [ ] `api/stripe-webhook.js` created and deployed
- [ ] Strike API key added, webhook endpoint created
- [ ] Cerebras API key added, `api/cerebras-chat.js` deployed
- [ ] OpenRouter key added, `api/openrouter-chat.js` deployed
- [ ] Grok API access granted, proxy created
- [ ] Supabase reservations table created
- [ ] Vercel ↔ Infisical sync enabled
- [ ] All channels in GTM section updated with live links
- [ ] Stripe products created for X Multiplayer $2 + $24 tiers
- [ ] `api/create-payment-intent.js` deployed + wired in xmultiplayer.html
- [ ] Arkade account created + node connected
- [ ] Arkade product links wired into pay.js + node pages
- [ ] Arkade QR codes regenerated for all price points
