Accept USDC payments in Go

Nexus takes USDC payments on Algorand. Customers pay from any Algorand wallet (Pera, Defly), you are paid directly, and there is no card processor or approval queue. This is the whole Go integration.

1. Create the checkout (server-side)

Create the session on your server so the price is fixed and the buyer cannot change it. Amounts are integer US cents.

main.go
func checkout(w http.ResponseWriter, r *http.Request) {
	body, _ := json.Marshal(map[string]any{"creatorId": os.Getenv("NEXUS_CREATOR_ID"), "amount": 4900})
	req, _ := http.NewRequest("POST", os.Getenv("NEXUS_URL")+"/v1/sessions", bytes.NewReader(body))
	req.Header.Set("content-type", "application/json")
	req.Header.Set("x-nexus-api-key", os.Getenv("NEXUS_API_KEY"))
	res, err := http.DefaultClient.Do(req)
	if err != nil { http.Error(w, err.Error(), 502); return }
	var s struct{ SessionId, ConfirmToken string }
	json.NewDecoder(res.Body).Decode(&s)
	http.Redirect(w, r, os.Getenv("NEXUS_URL")+"/pay/"+s.SessionId+"?t="+s.ConfirmToken, http.StatusSeeOther)
}

2. Check it before you fulfil the order

Never trust the browser. Nexus matches the payment on-chain and only marks the session completed when the USDC has actually arrived.

// GET /v1/sessions/{id} with the x-nexus-api-key header; fulfil when "status" == "completed".

3. Set it up

Honest limits

See how it works

Using an AI coding agent? Point it at /llms.txt or the OpenAPI spec, or install the Nexus MCP server.