Stripe Webhook Setup
Automate subscription management by connecting Stripe webhooks to your Base44 app
checkout.session.completedPayment completed - activate subscription
Action: Update provider.subscription_status = 'active'
invoice.payment_succeededRecurring payment successful
Action: Update provider.last_payment_date, next_billing_date
invoice.payment_failedPayment failed
Action: Update provider.subscription_status = 'past_due', send notification
customer.subscription.deletedSubscription cancelled
Action: Update provider.subscription_status = 'cancelled', pricing_tier = 'basic'
customer.subscription.trial_will_endTrial ending in 3 days (Stripe sends this)
Action: Send reminder email (optional - we handle this in app)
Implementation Options
Build your own webhook handler using Node.js, Python, or any backend framework.
- ✓ Full customization
- ✓ Real-time updates
- ✓ Complete control
- ⚠️ Requires server hosting
Use automation platforms to connect Stripe to Base44 without coding.
- ✓ No coding required
- ✓ Quick setup (30 min)
- ✓ Visual workflow
- ⚠️ Monthly subscription cost
Current system - users manage via Stripe portal, you update manually.
- ✓ Already working
- ✓ Zero cost
- ✓ Simple to maintain
- ⚠️ Requires manual checks
// Stripe Webhook Handler (Backend Required)
// This needs to run on a server, not in Base44 frontend
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const express = require('express');
const app = express();
// Webhook endpoint
app.post('/webhook', express.raw({type: 'application/json'}), async (req, res) => {
const sig = req.headers['stripe-signature'];
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, webhookSecret);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle the event
switch (event.type) {
case 'checkout.session.completed':
const session = event.data.object;
// Update Base44: Mark subscription as active
await updateProviderSubscription(session.customer, {
subscription_status: 'active',
stripe_customer_id: session.customer,
stripe_subscription_id: session.subscription
});
break;
case 'invoice.payment_succeeded':
const invoice = event.data.object;
// Update payment dates
await updateProviderPayment(invoice.customer, {
last_payment_date: new Date().toISOString(),
next_billing_date: new Date(invoice.lines.data[0].period.end * 1000).toISOString()
});
break;
case 'invoice.payment_failed':
const failedInvoice = event.data.object;
// Mark as past due and notify
await updateProviderSubscription(failedInvoice.customer, {
subscription_status: 'past_due'
});
await sendPaymentFailedEmail(failedInvoice.customer_email);
break;
case 'customer.subscription.deleted':
const subscription = event.data.object;
// Downgrade to basic plan
await updateProviderSubscription(subscription.customer, {
subscription_status: 'cancelled',
pricing_tier: 'basic'
});
break;
}
res.json({received: true});
});
// Helper functions to update Base44
async function updateProviderSubscription(stripeCustomerId, updates) {
// Call Base44 API to update provider
const response = await fetch('https://api.base44.com/entities/Provider', {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${process.env.BASE44_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filter: { stripe_customer_id: stripeCustomerId },
updates: updates
})
});
return response.json();
}
app.listen(3000, () => console.log('Webhook server running on port 3000'));Create Zapier Account
Sign up at zapier.com (free plan available)
Connect Stripe
Add Stripe as trigger: "New Successful Payment"
Add Webhooks Action
Configure HTTP PATCH request to Base44 API
1. Create a Zap in Zapier
2. Trigger: Stripe → New Payment
3. Action: HTTP Request → PATCH Base44 Provider
URL: https://api.base44.com/entities/Provider/{provider_id}
Headers: Authorization: Bearer YOUR_BASE44_KEY
Body: { "subscription_status": "active" }- Verify Webhook Signatures
Always validate Stripe's signature to prevent fraudulent requests
- Use HTTPS
Webhook endpoint must be HTTPS for Stripe to send events
- Store Secrets Securely
Never commit API keys or webhook secrets to version control
- Handle Idempotency
Stripe may send same event multiple times - design for this
1. Use Stripe CLI
stripe listen --forward-to localhost:3000/webhook
2. Trigger Test Events
stripe trigger payment_intent.succeeded
3. Monitor in Dashboard
View webhook events in Stripe Dashboard → Developers → Webhooks
