mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 17:24:48 +00:00
Premium checkout: CoinPay hosted session with URL + QR in the SSH terminal (#156)
Some checks failed
CI / build (push) Has been cancelled
deploy / deploy (push) Has been cancelled
test / test (push) Has been cancelled
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>
This commit is contained in:
parent
8fe601b296
commit
0499cb60f0
7 changed files with 333 additions and 181 deletions
45
internal/payments/qr.go
Normal file
45
internal/payments/qr.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue