mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-11-29 15:31:53 +00:00
Some checks failed
CI / build (push) Has been cancelled
deploy / deploy (push) Has been cancelled
test / test (push) Has been cancelled
join@ now creates a CoinPay checkout session (POST /checkout/sessions) instead of a single-chain ETH payment: the buyer picks any coin the business accepts or PayPal. The session URL and a half-block QR code of it are shown in the terminal, and the session is polled (GET /checkout/sessions/:id) until paid, Enter, disconnect or expiry. property=bbs.profullstack.com, account_id=handle, customer_email=the verified email (asked for if none is stored), metadata carries pubkey fingerprint, user id and the HMAC ref. Legacy payment ids still verify. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1 KiB
Go
45 lines
1 KiB
Go
package payments
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"rsc.io/qr"
|
|
)
|
|
|
|
// TerminalQR renders text as a QR code made of Unicode half blocks, two module
|
|
// rows per text line, with a quiet zone. Light modules are drawn as blocks so it
|
|
// scans as dark-on-light on the usual light-on-dark terminal. Each line is
|
|
// prefixed with indent. Returns "" if the text cannot be encoded.
|
|
func TerminalQR(text, indent string) string {
|
|
code, err := qr.Encode(text, qr.L)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
const quiet = 2
|
|
n := code.Size
|
|
light := func(x, y int) bool {
|
|
if x < 0 || y < 0 || x >= n || y >= n {
|
|
return true // quiet zone
|
|
}
|
|
return !code.Black(x, y)
|
|
}
|
|
var b strings.Builder
|
|
for y := -quiet; y < n+quiet; y += 2 {
|
|
b.WriteString(indent)
|
|
for x := -quiet; x < n+quiet; x++ {
|
|
top, bot := light(x, y), light(x, y+1)
|
|
switch {
|
|
case top && bot:
|
|
b.WriteString("█")
|
|
case top:
|
|
b.WriteString("▀")
|
|
case bot:
|
|
b.WriteString("▄")
|
|
default:
|
|
b.WriteString(" ")
|
|
}
|
|
}
|
|
b.WriteString("\n")
|
|
}
|
|
return b.String()
|
|
}
|