mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-08-13 22:37:28 +00:00
payments: call CoinPay REST API directly (drop coinpay CLI dependency)
CreatePremiumCharge/VerifyPremium now POST /payments/create and GET /payments/:id against the CoinPay API (Bearer COINPAY_API_KEY, business_id = AGENTBBS_COINPAY_MERCHANT_ID), so the droplet needs no coinpay CLI installed. The created payment id is stored (store: User.PremiumPayID + premium_pay_id col + SetPremiumPayment); ensurePremium verifies that id on a later connect and grants premium on confirmed/forwarded status. Removed the CLI command-template env knobs; added AGENTBBS_COINPAY_API_URL. Tests: httptest-backed payments_test + store SetPremiumPayment test. Build/vet/gofmt/test green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5c0feda8d4
commit
7fd10c3436
6 changed files with 289 additions and 167 deletions
|
|
@ -67,3 +67,23 @@ func TestGrantPremium(t *testing.T) {
|
|||
t.Fatalf("re-grant: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetPremiumPayment(t *testing.T) {
|
||||
st, err := Open(filepath.Join(t.TempDir(), "t.db"))
|
||||
if err != nil {
|
||||
t.Fatalf("open: %v", err)
|
||||
}
|
||||
defer st.Close()
|
||||
|
||||
u, _ := st.EnsureUser("erin", "member", "SHA256:eee")
|
||||
if u.PremiumPayID != "" {
|
||||
t.Fatal("new user must have no premium pay id")
|
||||
}
|
||||
if err := st.SetPremiumPayment(u.ID, "pay_abc123"); err != nil {
|
||||
t.Fatalf("set: %v", err)
|
||||
}
|
||||
got, _, _ := st.UserByFingerprint("SHA256:eee")
|
||||
if got.PremiumPayID != "pay_abc123" {
|
||||
t.Fatalf("PremiumPayID = %q", got.PremiumPayID)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue