Core Concepts
Understanding these core concepts will help you build robust payment integrations with Bridge Payments.
Payment Intents
A Payment Intent represents a single payment transaction. It tracks the payment through its entire lifecycle from creation to completion.
Payment Intent Lifecycle
created → processing → succeeded
↓
failedKey Properties
client_secret: Used by frontend to confirm payment (sensitive, auto-deleted after 24h)status: Current payment state (created,processing,succeeded,failed)amount_cents: Total amount in cents (e.g., 2000 = $20.00)provider_id: Payment provider (stripe,paypal,authorize_net)provider_payment_id: Provider's payment ID for tracking
Payment Flow
- Create Intent: Backend creates payment intent with amount and details
- Confirm Payment: Frontend uses
client_secretto collect payment info - Process: Provider processes the payment
- Sync Status: Backend syncs final status from provider
- Complete: Payment marked as succeeded or failed
Best Practice
Always sync payment status after frontend confirmation to ensure your database reflects the actual payment state.
Payment Methods
A Payment Method represents a saved payment instrument (credit card, bank account, etc.) that can be reused for future payments.
Token-Based (Recommended)
{
"provider_id": "stripe",
"provider_payment_method_token": "pm_1234567890",
"type": "card",
"card_brand": "visa",
"card_last_four": "4242"
}Benefits:
- ✅ PCI compliant (no raw card data)
- ✅ Secure tokenization by provider
- ✅ Recommended for production
Direct Card Data (Development Only)
{
"provider_id": "stripe",
"card_number": "4242424242424242",
"card_exp_month": "12",
"card_exp_year": "2025",
"card_cvc": "123"
}Warning:
- ⚠️ Requires PCI compliance
- ⚠️ Only for development/testing
- ⚠️ Use tokenization in production
Saving Payment Methods
Set setup_future_usage: "off_session" when creating payment intent:
{
"total_cents": 2000,
"currency": "USD",
"setup_future_usage": "off_session", // Save for future use
"provider_id": "stripe"
}Customers
A Customer represents a person or organization that makes payments.
Customer Types
1. Authenticated Users
Linked to Flowless user accounts:
{
"user_id": "user_123",
"email": "[email protected]",
"name": "John Doe",
"is_guest": false
}2. Guest Customers
No account required:
{
"guest_data": {
"email": "[email protected]",
"name": "Guest User",
"phone": "+1234567890"
}
}3. Organization Customers
For business accounts:
{
"organization_id": "org_456",
"email": "[email protected]",
"name": "Company Inc"
}Subscriptions
A Subscription represents recurring payments at regular intervals.
Subscription States
active: Currently active, billing normallytrialing: In trial period, no charges yetpast_due: Payment failed, retryingcanceled: Subscription endedpaused: Temporarily suspended
Billing Intervals
daily- Every dayweekly- Every weekmonthly- Every monthquarterly- Every 3 monthsyearly- Every year
Trial Periods
{
"product_id": "prod_premium",
"payment_method_id": "pm_123",
"trial_days": 14 // 14-day free trial
}Webhooks
Webhooks notify your application about payment events in real-time.
Provider Webhooks
Receive events from payment providers (Stripe, PayPal):
Stripe → Bridge Payments → Database UpdateCommon Events:
payment_intent.succeeded- Payment completedpayment_intent.payment_failed- Payment failedcustomer.subscription.created- New subscriptioninvoice.payment_failed- Subscription payment failed
External Webhooks
Send events to your own services:
Bridge Payments → Your API / Discord / SlackUse Cases:
- Send Discord notifications for failed payments
- Update analytics platforms
- Trigger custom business logic
- Send Slack alerts for new subscriptions
Authentication
Bridge Payments supports multiple authentication methods:
1. Session ID (Recommended)
headers: {
'X-Session-ID': 'session_abc123'
}2. Bearer Token
headers: {
'Authorization': 'Bearer token_xyz789'
}3. Guest Token
For guest checkout:
{
"guest_data": {
"email": "[email protected]",
"name": "Guest User"
}
}Response Formats
Standard Format (Default)
{
"id": "pay_123",
"amount_cents": 2000,
"status": "succeeded"
}Row Mode
Set ROW_MODE=true in environment:
{
"pay_123": {
"amount_cents": 2000,
"status": "succeeded"
}
}Next Steps
- API Reference - Explore all endpoints
- Guest Checkout Guide - Implement guest payments
- Subscription Guide - Set up recurring billing
- Client Libraries - Use official integrations