Claude Code Setup

Configure Claude Code CLI to work with RohoPay projects.

Prerequisites

  • Claude Code installed (npm install -g @anthropic-ai/claude-code)
  • An Anthropic account with API access
  • Your RohoPay project repository

Setup

1. Install Claude Code

terminal.shBash
npm install -g @anthropic-ai/claude-code

Verify:

terminal.shBash
claude --version

2. Add RohoPay Context to CLAUDE.md

Create or update CLAUDE.md in your project root to include RohoPay context:

README.mdMarkdown
# RohoPay Integration

## API Base URL
- Production: https://api.rohopay.com

## Documentation
- Official docs: https://docs.rohopay.com
- API reference: https://docs.rohopay.com/api-reference/overview
- Webhooks: https://docs.rohopay.com/api-reference/webhooks
- Machine-readable reference (for AI context): https://docs.rohopay.com/llms.txt
- When unsure about any endpoint, header, error code, or integration flow, consult the docs above before generating code. Treat webhook/redirect status as provisional — always confirm final payment status via the webhook or a status poll.

## Authentication
- All `/api/v1/*` endpoints: `Authorization: Bearer {api_key}`
- Prefix `test_` = sandbox, `live_` = production
- Mutation endpoints REQUIRE `Idempotency-Key: {uuid}` header

## Core Endpoints
- POST /api/v1/collect  — mobile money collection
- POST /api/v1/disburse — mobile money disbursement (live only)
- GET  /api/v1/transactions/:ref — check status
- GET  /api/v1/wallet/balance — wallet balance
- POST /api/v1/checkout — card payment (Visa/MC, api_key in body)
  Response includes `next_action` (type: pin/otp/avs/redirect/none). Most cards
  resolve via inline OTP — no redirect. Only "redirect" needs a bank page.
- POST /api/v1/checkout/:reference/verify-card-otp — submit OTP when
  next_action.type == "otp" (body: { otp })

## Webhook Verification
- All webhooks: HMAC-SHA256 in `X-RohoPay-Signature` header
- Secret from env: ROHOPAY_WEBHOOK_SECRET

## Phone Format
- International format without +: 256XXXXXXXXX (Uganda), 254XXXXXXXXX (Kenya)
- Pattern: ^(256|254|255|250)[0-9]{7,12}$

## Transaction Statuses
- pending → successful | failed (terminal)

## Digital Products
- POST /api/v2/digital/products — create product (session auth)
- POST /api/v2/digital/links — create payment link (session auth)
- GET  /api/v2/public/checkout/:slug — public checkout page data (no auth)
- POST /api/v2/public/checkout/:slug/pay — process payment (rate limited)
- GET  /api/v2/public/checkout/:slug/order/:id — poll order status

## Test Cards
- Mastercard (RohoPay sandbox): 5531 8866 5214 2950 | CVV 564 | Expiry 09/32
  Completes via next_action.type == "otp"; test-mode OTP is 12345

## Test Mobile Numbers (RohoPay sandbox, test_ key only)
- Success:        011177777(0-9) / 25611177777(0-9)
- Failed:         011177799(0-9) / 25611177799(0-9)
- Pending:        011177778(0-9) / 25611177778(0-9)
- SentToVendor:   011177779(0-9) / 25611177779(0-9)

## Available Skills
- /rohopay-collect    — mobile money collection handler
- /rohopay-webhook    — webhook handler with HMAC verification
- /rohopay-card       — card payment flow (OTP-first, redirect fallback)
- /rohopay-errors     — error code reference
- /rohopay-digital    — digital products and payment links

## Application Structure
- apps/api — Go backend (Gin) — payment API
- apps/admin — Next.js merchant dashboard
- apps/web — Next.js marketing site
- apps/digital — Next.js digital checkout

3. Start Claude Code

terminal.shBash
cd your-project
claude

Claude will automatically read CLAUDE.md and have full context about your RohoPay integration.

Using Claude for RohoPay Tasks

Generate a Collection Handler

output.txtText
> Write a TypeScript function that collects a mobile money payment
> and polls until it resolves, with proper error handling

Claude will generate code using the correct endpoint, headers, and idempotency patterns.

Debug a Webhook

output.txtText
> My webhook isn't receiving events. Here's my handler: [paste code]

Claude will check the signature verification, response timing, and content-type handling.

Review Integration

output.txtText
> Review my RohoPay integration in src/payments/ for correctness and security

Generate Tests

output.txtText
> Write Jest tests for my RohoPay webhook handler covering:
> - successful payment
> - failed payment  
> - invalid signature
> - missing idempotency key

Project-Level Settings (.claude/settings.json)

Add RohoPay-specific allowed commands to avoid permission prompts:

response.jsonJSON
{
  "permissions": {
    "allow": [
      "Bash(curl:*)",
      "Bash(go test:*)",
      "Bash(pnpm test:*)"
    ]
  },
  "env": {
    "ROHOPAY_API_KEY": "test_xxx",
    "ROHOPAY_WEBHOOK_SECRET": "your-secret"
  }
}

Claude Code Skills

Install the skills to get quick-access slash commands:

terminal.shBash
# After installing skills (see /ai-setup/skills)
/rohopay-collect    — mobile money collection handler
/rohopay-webhook    — webhook handler with HMAC verification
/rohopay-card       — card payment flow (OTP-first, redirect fallback)
/rohopay-errors     — error code reference
/rohopay-digital    — digital products and payment links

Troubleshooting

Claude doesn't know the API endpoints

Make sure CLAUDE.md is in the root of your working directory when you start claude. Claude Code reads CLAUDE.md automatically at startup.

Claude generates wrong phone format

Add this to your CLAUDE.md: "Always use international format for East African phone numbers: remove leading 0, add country code (256 for Uganda, 254 for Kenya)."

Claude uses wrong authentication pattern

Emphasize in CLAUDE.md: "The /api/v1/checkout endpoint takes api_key in the REQUEST BODY, not in the Authorization header. All other /api/v1/* endpoints use Authorization: Bearer header."