Overview
Card payments in Flexprice allow customers to pay using their previously saved payment methods. This flow is designed for returning customers who have already saved their card details through a payment link withsave_card_and_make_default: true.
Key Features
- Instant Payments: No redirect to external checkout pages
- Saved Payment Methods: Uses customer’s default payment method
- Off-Session Processing: Payments processed without customer interaction
- Automatic Reconciliation: Invoice updates happen automatically
- Secure Processing: All card data handled by Stripe
Card Payment Prerequisites
Customer Requirements
- Existing Customer: Customer must exist in both Flexprice and Stripe
- Default Payment Method: Customer must have a default payment method set in Stripe
- Previous Payment Link: Default payment method created via payment link with
save_card_and_make_default: true
System Requirements
- Stripe Integration: Active Stripe connection configured
- Valid Invoice: Invoice must be finalized and have outstanding amount
- Matching Currency: Payment currency must match invoice currency
Payment Status Flow
Status Transitions for Card Payments
Status Definitions
Creating Card Payments
API Request
Endpoint:POST /api/v1/payments
Headers:
Response
Success Response:Card Payment Configuration
Required Fields
Optional Fields
Payment Method Selection
When creating a card payment, you can specify which payment method to use:- No
payment_method_idprovided: Uses the customer’s default payment method payment_method_idprovided: Uses the specified payment method for this payment
Payment Processing Flow
Payment Validation
Before processing, the system validates:- Invoice Status: Must be finalized and have outstanding amount
- Customer Existence: Customer must exist in both systems
- Amount Matching: Payment amount must match invoice outstanding
- Currency Matching: Payment and invoice currencies must match
Default Payment Method Retrieval
Stripe Payment Intent Creation
The system creates a Stripe Payment Intent with:- Amount: Exact payment amount in smallest currency unit
- Currency: Payment currency
- Customer: Stripe customer ID
- Payment Method: Default payment method ID
- Confirmation: Immediate confirmation (
confirm: true) - Off Session: Set to
truefor saved payment methods
Payment Confirmation
Payment intents are automatically confirmed with the following parameters:Error Handling
Common Card Payment Errors
Error Response Format
Note: All card payment errors follow this standardized format for consistent error handling.
Recovery Flow
- Immediate Failure: Payment status set to
FAILED - Error Logging: Detailed error information recorded
- Customer Notification: Optional failure notification sent
- Alternative Options:
- Retry with payment link flow
- Update payment method via payment link with
save_card_and_make_default: true - Use different payment method
Security Considerations
Payment Security
- Off-Session Payments: All card payments are off-session using saved methods
- PCI Compliance: No card data stored in Flexprice systems
- Stripe Security: All sensitive operations handled by Stripe
- Authentication: Strong Customer Authentication (SCA) compliance
Data Protection
- Encrypted Storage: All payment data encrypted at rest
- Access Controls: Role-based access to payment information
- Audit Logging: All payment operations logged for compliance
- Data Retention: Payment data retained per compliance requirements
Testing Card Payments
Test Environment Setup
- Stripe Test Mode: Use Stripe test keys
- Test Customer: Create customer with saved payment method
- Test Payment Link: First create payment link with
save_card_and_make_default: true - Test Card Payment: Then test card payment flow

