mirror of
https://github.com/Heretek-Games/drop-payment-btcpay.git
synced 2026-10-12 02:05:34 +00:00
main
Closes #9
BTCPay Server
BTCPay Server cryptocurrency payment gateway plugin for Drop indie commerce (#21).
Build
npm ci
npm run build
npm test
npm run typecheck
Configuration
There is no placeholder default: the gateway refuses to build API calls until a real deployment URL is configured. Configuration is read from plugin storage first, then the environment:
| Setting | Storage key | Environment variable |
|---|---|---|
API base URL (e.g. https://btcpayserver.example.org/api/v1) |
apiBaseUrl |
BTCPAY_BASE_URL |
| Store id (e.g. the id from BTCPay's store settings) | storeId |
BTCPAY_STORE_ID |
| API key (Bearer) | - | BTCPAY_API_KEY |
| Webhook signing secret | webhookSecret |
BTCPAY_WEBHOOK_SECRET |
Without a store id the gateway still registers, but every createPaymentIntent
call is rejected: BTCPay invoices are store-scoped.
Without a webhook secret the gateway still registers, but every
handleWebhook call is rejected: verification fails closed rather than
accepting unsigned events.
API behaviour
createPaymentIntentposts JSON to${apiBaseUrl}/stores/${storeId}/invoices(the BTCPay GreenfieldInvoices_CreateInvoiceendpoint) withorderId,amount,currency, andmetadata.orderId, then mapscheckoutLink/urland the invoice status.apiBaseUrlshould be the API root (e.g..../api/v1), not include a store id.handleWebhookverifies theBTCPay-Sigheader first: HMAC-SHA256 over the raw body with the webhook secret, compared in constant time (sha256=prefix or bare hex are both accepted). Event typesInvoiceSettled,InvoicePaymentSettled,InvoicePaidInFull,InvoiceExpired,InvoiceInvalid,InvoiceRefundedare mapped; legacy invoice payloads are mapped viastatus/posData. Unsupported events throw instead of being treated as successful.
Host requirements
The host must pass the raw request body (string or bytes) to
handleWebhook; re-serialized JSON is documented as best-effort only. Header
names are matched case-insensitively.
Languages
TypeScript
81.2%
JavaScript
18.8%