Loading...
if (error) returnError: {error.message}
if (!customer) returnCustomer not found
return (Email: {customer.email}
Name: {customer.name}
Has active subscription: {customer.hasActiveSubscription ? 'Yes' : 'No'}
Loading products...
if (error) returnError: {error.message}
return (Payment confirmed!
} returnVerifying payment…
} ``` ## What About the `/api/mdk` Route? The initial setup includes an `/api/mdk` route: ```js theme={null} // app/api/mdk/route.js export { POST } from '@moneydevkit/nextjs/server/route' ``` This is a one-time setup—you export the handler and you're done. Unlike Stripe webhooks, you don't write any event handling code. The route is internal infrastructure that allows your serverless Lightning node to receive payments. You never need to parse events, verify signatures, or handle retries.Registration {registrationId} confirmed!
} returnVerifying payment…
} ``` See the [Customers documentation](/dashboard/customers) for more details. ## Quick Comparison: Checkout Flow{error}
}Verifying payment…
} if (!isCheckoutPaid) { returnPayment has not been confirmed.
} // We set 'name' when calling createCheckout(), and it's accessible here on the success page. console.log('Customer name:', metadata?.name) // "John Doe" return (Payment confirmed. Enjoy your purchase!
{error}
}Verifying payment…
if (!isCheckoutPaid) returnPayment has not been confirmed.
returnPayment confirmed for {metadata?.name ?? 'customer'}.
} ``` This wiring keeps the client pointed at `/api/mdk`, which the Express route handles by delegating to the shared moneydevkit core logic. ## Customers Collect customer information during checkout to track purchases and enable refunds. ```tsx theme={null} const result = await createCheckout({ type: 'AMOUNT', title: 'Product Name', amount: 500, currency: 'USD', successUrl: '/checkout/success', customer: { email: 'customer@example.com', name: 'Jane Doe', externalId: 'user-123' // Your system's user ID }, requireCustomerData: ['email', 'name'] // Show form for missing fields }) ``` See the full [Customers documentation](/dashboard/customers) for details on customer matching, returning customers, and custom fields. ## Product Checkouts Sell products defined in your Money Dev Kit dashboard using `type: 'PRODUCTS'`: ```tsx theme={null} import { useCheckout, useProducts } from '@moneydevkit/replit' const { createCheckout } = useCheckout() const { products } = useProducts() const result = await createCheckout({ type: 'PRODUCTS', product: products[0].id, successUrl: '/checkout/success', }) ``` See the full [Products documentation](/dashboard/products) for details on creating products, pricing options, and pay-what-you-want pricing. # Subscriptions Source: https://docs.moneydevkit.com/subscriptions Set up recurring payments with Lightning-powered subscriptions Subscriptions let you charge customers on a recurring basis using Lightning payments. Customers pay once to start their subscription, then receive renewal reminders before each billing period. ## What are Subscriptions? Subscriptions in moneydevkit work differently from traditional card-based subscriptions: * **No stored payment methods** - Lightning payments are push-based, so customers pay proactively * **Renewal reminders** - Customers receive emails 7, 4, and 1 days before their subscription renews * **Grace period** - If a customer misses a payment, they have 3 days to renew before cancellation * **Instant settlement** - Payments settle immediately in Bitcoin ## SetupLoading...
if (!customer?.hasActiveSubscription) { returnLoading...
if (error) returnError: {error.message}
if (!customer) returnCustomer not found
return (You have an active subscription
) : (No active subscription
)}