@pure-tools/monetka
v0.4.0
Published
Pluggable payment provider abstraction for Angular apps
Maintainers
Readme
@pure-tools/monetka
Pluggable payment provider abstraction for Angular apps. One service, swap providers via config.
Supported providers: Stripe · Lemon Squeezy · Paddle
Install
npm install @pure-tools/monetkaSetup
// app.config.ts
import { providePayments } from '@pure-tools/monetka';
providePayments({
provider: 'stripe', // 'stripe' | 'lemon-squeezy' | 'paddle'
publicKey: environment.stripePublicKey,
})Usage
payments = inject(PaymentService);
payments.openCheckout({ email, successUrl })
payments.validateLicense('KEY')
payments.getSubscriptionStatus(customerId)In-app purchases (iOS / Android)
Apple and Google require their own billing for digital unlocks inside native apps, so Stripe/Paddle/Lemon Squeezy checkout can't be used there. Use the in-app provider on native platforms, backed by a store bridge. monetka does not import any store SDK; you pass one in.
npm i @revenuecat/purchases-capacitor # in the web app AND the Capacitor projectimport { Capacitor } from '@capacitor/core';
import { Purchases } from '@revenuecat/purchases-capacitor';
import { providePayments, revenueCatBridge } from '@pure-tools/monetka';
const native = Capacitor.isNativePlatform();
providePayments(native
? {
provider: 'in-app',
publicKey: '',
productId: 'pro_lifetime', // App Store Connect / Play Console product id
bridge: revenueCatBridge(Purchases, {
apiKey: Capacitor.getPlatform() === 'ios' ? 'appl_...' : 'goog_...',
}),
}
: { provider: 'stripe', publicKey: 'pk_...', productId: 'price_...' });await payment.openCheckout({ userId: user.id }); // native purchase sheet
if (payment.canRestorePurchases) { // App Store review requires a Restore button
await payment.restorePurchases(user.id);
}Always pass your auth userId: RevenueCat uses it as the app user id, so its webhook can grant access in your database. Treat CheckoutResult.entitlements as a UI hint only; the server webhook is the source of truth.
Custom store SDK: implement InAppPurchaseBridge (purchase, restore, getEntitlements).
Notes
- Stripe and Paddle require serverless API routes (
/api/create-checkout-session,/api/subscription-status) - Lemon Squeezy validates licenses directly against their public API
