Twilio Integration
Add PCI-compliant voice payments to a voice application you’ve built directly on Twilio. This guide is for developers who orchestrate their own call flow using TwiML or the Twilio REST API — if you’re using a voice agent platform like VAPI, Retell, or Outbox, see the platform-specific guides or Custom Platform guide instead.How It Works
1
Your app creates a payment session
When your call flow needs to collect a payment, your server calls the Maven API with the amount and caller’s phone number.
2
Your app transfers the caller
Maven returns a phone number. Your server responds with TwiML that dials that number, preserving the original caller ID.
3
Maven collects the payment
Maven handles the entire card collection conversation — card number, expiry, CVV, and ZIP code. Your app is never exposed to card data (PCI compliant).
4
Caller returns to your app
After payment, Maven transfers the caller back to your
callback number. You receive a webhook with the payment result.Prerequisites
- A Maven account with an API key
- An app with a payment gateway connected
- A Twilio account with a phone number
Step 1 — Create a Payment Session
When your call flow reaches the payment step, create a session from your server:Step 2 — Transfer with TwiML
Respond to the Twilio webhook with a<Dial> that transfers the caller to Maven’s payment line. The critical detail: set callerId to the customer’s phone number, not your Twilio number.
Step 3 — Handle the Result
After the payment completes and the caller is transferred back, Twilio hits youraction URL. You can look up the session result:
Full Example
Here’s a minimal FastAPI app that handles the complete flow:Caller ID Verification
If sessions are created but calls aren’t connecting, verify the session exists for the right number:callerId on your <Dial> doesn’t match the caller you passed to session creation.
Next
Webhooks
Get notified when sessions complete.
API Reference
Explore the full API.
Testing
Test with test cards and test mode keys.
Custom Platform
Integrating via a voice agent platform instead?
