mirror of
https://github.com/Heretek-Games/drop-payment-stripe.git
synced 2026-10-12 02:05:34 +00:00
main
Stripe
Stripe payment gateway plugin for Drop indie commerce (#21).
Build
npm ci
npm run build
npm test
npm run typecheck
Configuration
| Environment variable | Purpose |
|---|---|
STRIPE_SECRET_KEY |
Stripe API secret key used for POST /v1/payment_intents |
STRIPE_WEBHOOK_SECRET |
Endpoint signing secret (whsec_...) used to verify webhooks |
Without STRIPE_WEBHOOK_SECRET the gateway still registers, but every
handleWebhook call is rejected: verification fails closed rather than
accepting unsigned events.
API behaviour
createPaymentIntentsendsapplication/x-www-form-urlencodeddata (Stripe's required encoding) withamount,currency,metadata[orderId],receipt_email, and flattenedmetadata[...]entries.client_secret,next_action.redirect_to_url.url, and the intent status are mapped to the SDK result.handleWebhookverifies theStripe-Signatureheader per Stripe's scheme: HMAC-SHA256 over${timestamp}.${rawBody}with the endpoint secret, compared in constant time, rejecting timestamps outside a 300 second tolerance window. Only then is the event parsed and mapped (payment_intent.succeeded,payment_intent.payment_failed,payment_intent.canceled,charge.failed,charge.refunded).
Host requirements
Signature verification only works on the exact bytes Stripe signed. The host
must pass the raw request body (string or bytes) to handleWebhook, not a
re-serialized JSON object. Header names are matched case-insensitively.
Languages
TypeScript
80.2%
JavaScript
19.8%