A modern TypeScript/JavaScript library for seamless integration with Iaptic's payment and subscription services, powered by Stripe. Handle one-time purchases, subscriptions, and payment management with developer-friendly APIs.
npm install --save iaptic-js
<!-- UMD version (for direct browser use) -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/iaptic-js.js"></script>
<!-- ES Module version (for modern browsers) -->
<script type="module">
import { IapticJS } from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/iaptic-js.esm.js';
</script>
import { IapticJS } from 'iaptic-js';
// Initialize with your Stripe credentials
const iaptic = IapticJS.createAdapter({
type: 'stripe',
appName: 'my-app', // Your application identifier
apiKey: '1234567890', // Get from Iaptic dashboard
stripePublicKey: 'pk_test_1234567890'
});
// Fetch available products
const { products, subscriptions } = await iaptic.getCatalog();
// Handle purchase flow
async function purchaseProduct(productId: string) {
try {
const result = await iaptic.order({
offerId: productId,
applicationUsername: 'user-123',
successUrl: window.location.href + '/success',
cancelUrl: window.location.href + '/cancel'
});
console.log('Purchase completed:', result);
} catch (error) {
console.error('Payment failed:', error);
}
}
Explore our comprehensive guides:
MIT © Iaptic