@aquarian-metals/coin-moebius-stripe
v2.0.0
Published
Stripe provider for Coin Moebius — browser checkout entry plus a server-only webhook verifier under the ./server subpath.
Maintainers
Readme
@aquarian-metals/coin-moebius-stripe
Stripe provider for Coin Moebius.
Two entries in one package:
@aquarian-metals/coin-moebius-stripe— browser entry, kicks off Stripe Checkout.@aquarian-metals/coin-moebius-stripe/server— Node-only webhook verifier. Never import this from browser code.
Install
For the browser:
npm install @aquarian-metals/coin-moebius-stripeFor server-side webhook verification, additionally install the official Stripe SDK (declared as an optional peer so it stays out of browser bundles):
npm install stripeUse — browser
import createStripeProvider from '@aquarian-metals/coin-moebius-stripe';
import { createPaymentManager } from '@aquarian-metals/coin-moebius';
const payments = createPaymentManager({
providers: [
createStripeProvider({
publishableKey: import.meta.env.VITE_STRIPE_KEY,
// optional — defaults to '/api/checkout/stripe'
sessionEndpoint: '/api/create-stripe-session',
}),
],
});Use — server
import { registerVerifier } from '@aquarian-metals/coin-moebius-server';
import { createStripeVerifier } from '@aquarian-metals/coin-moebius-stripe/server';
registerVerifier(
'stripe',
createStripeVerifier({
endpointSecret: process.env.STRIPE_WEBHOOK_SECRET,
// Optional but recommended — pass your secret key so the same Stripe
// instance can be reused for refunds / retrieval calls in this function.
secretKey: process.env.STRIPE_SECRET_KEY,
}),
);See the main README for the full quick-start.
Subscriptions
The verifier surfaces five normalized subscription event types on top of the existing one-time payment events:
subscription.createdsubscription.renewedsubscription.payment_failedsubscription.canceledsubscription.updated
Branch on event.kind === 'subscription' and switch on event.type. See docs/subscriptions.md in the repo for the full walkthrough.
For cancellation, the package also exports a helper that returns a hosted Stripe Customer Portal URL. The buyer manages cancellation, card updates, and receipt downloads inside Stripe's UI:
import { getStripePortalUrl } from '@aquarian-metals/coin-moebius-stripe/server';
const url = await getStripePortalUrl({
secretKey: process.env.STRIPE_SECRET_KEY,
customerId: 'cus_buyer_abc',
returnUrl: 'https://you.example/account',
});You must enable the Customer Portal once in your Stripe Dashboard before this call succeeds.
License
MIT — see LICENSE.
