agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/payments/SKILL.md

payments

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: payments

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When you enable PCI Mode on a Twilio account:

    line 35
  2. Distinctive:

    REST API: When payment is triggered dynamically during an existing call

    line 86
  3. Very specific:

    When payment completes (success or failure), Twilio POSTs to the action URL:

    line 130
  4. Distinctive:

    Test with a small charge

    line 177

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

name: payments description: Twilio Pay PCI-compliant payment guide. Use when implementing credit card capture during voice calls, payment processing, <Pay> verb, tokenization, or PCI compliance patterns.

Payments Development Skill

Guide for Twilio Pay — PCI-compliant payment collection during voice calls. Load this skill when implementing credit card capture, payment processing, or PCI compliance patterns.


Quick Decision: Do You Need Twilio Pay?

ScenarioUse Pay?Alternative
Collect credit card during a callYes—
Process ACH/bank account during a callYes—
Collect payment info via SMS/webNoStripe/payment processor directly
Store cards for future chargesMaybePay with tokenType: 'reusable'
Accept payments without a voice callNoStandard payment gateway

Key insight: Twilio Pay is specifically for collecting payment information during active voice calls via DTMF (touchtone) or speech. It's not a general payment processor — it handles the PCI-compliant capture and tokenization, then you charge through your payment connector.


PCI Mode Warning

PCI Mode is IRREVERSIBLE and ACCOUNT-WIDE.

When you enable PCI Mode on a Twilio account:

  • The <Pay> TwiML verb becomes available
  • DTMF tones for card numbers are masked in logs
  • Recording behavior changes (card digits are silenced)
  • This CANNOT be undone

Always use a subaccount for payments development and testing. Never enable PCI Mode on your main account unless you're certain.

# Create a subaccount for payments testing
twilio api:core:accounts:create --friendly-name "Payments Testing"

Architecture

TwiML Approach (Serverless Functions)

Caller dials in
    ↓
Voice webhook → <Say> greeting → <Pay> verb
    ↓
Twilio prompts for card info via DTMF:
  1. Card number (16 digits)
  2. Expiration date (MMYY)
  3. Security code (3-4 digits)
  4. Postal code (5 digits)
    ↓
statusCallback receives progress events
    ↓
action URL receives tokenized result
    ↓
You charge the token via your payment connector

REST API Approach (MCP Tools)

Active call exists (CallSid)
    ↓
create_payment → initiates DTMF capture
    ↓
update_payment → capture next field or complete
    ↓
get_payment → check status and token

When to use which:

  • TwiML (<Pay> verb): When payment is part of a predefined call flow (IVR)
  • REST API: When payment is triggered dynamically during an existing call

TwiML Pay Verb

Basic Usage

const twiml = new Twilio.twiml.VoiceResponse();

twiml.say('Please enter your credit card information.');

twiml.pay({
  paymentConnector: 'Default',
  chargeAmount: '29.99',
  currency: 'usd',
  paymentMethod: 'credit-card',
  tokenType: 'one-time',
  action: '/pay/payment-complete',
  statusCallback: '/pay/payment-status',
});

Pay Attributes

AttributeRequiredDefaultDescription
paymentConnectorYes—Payment gateway connector name
chargeAmountNo—Amount to charge (e.g., '29.99')
currencyNousdISO currency code
paymentMethodNocredit-cardcredit-card or ach-debit
tokenTypeNoone-timeone-time or reusable
actionYes—URL receiving payment result
statusCallbackNo—URL receiving progress events
timeoutNo5Seconds to wait for input
maxAttemptsNo1Retry attempts on failure
validCardTypesNoallSpace-separated: visa mastercard amex
minPostalCodeLengthNo1Minimum postal code digits
postalCodeNotrueWhether to collect postal code
securityCodeNotrueWhether to collect CVV

Action URL Parameters

When payment completes (success or failure), Twilio POSTs to the action URL:

ParameterDescription
Resultsuccess, payment-connector-error, caller-interrupted, input-matching-failed, internal-error
PaymentTokenTokenized card (use to charge via connector)
PaymentCardNumberLast 4 digits only
PaymentCardTypevisa, mastercard, amex, discover, etc.
ExpirationDateCard expiration (MMYY)
PaymentConfirmationCodeFrom payment connector
ProfileIdFor reusable tokens
CallSidThe call this payment was on

Status Callback Parameters

Progress events during DTMF collection:

ParameterDescription
CaptureField being captured: payment-card-number, expiration-date, security-code, postal-code
ResultCurrent status
PaymentSidPayment session SID (PK prefix)
ErrorCodeError code if failed
ErrorMessageError description

Payment Connectors

Payment connectors bridge Twilio Pay to your payment processor. Configure in Twilio Console.

Supported Processors

ConnectorTypeNotes
StripeDefaultMost common, easiest setup
Braintree—PayPal ecosystem
CardConnect—Enterprise
Chase Paymentech—Enterprise
Generic Pay ConnectorCustomFor other processors

Connector Setup

  1. Console → Voice → Pay Connectors
  2. Select your processor
  3. Enter API credentials
  4. Name it (used in paymentConnector attribute)
  5. Test with a small charge

ACH Debit Payments

For bank account payments instead of credit cards:

twiml.pay({
  paymentConnector: 'Default',
  chargeAmount: '100.00',
  paymentMethod: 'ach-debit',
  action: '/pay/payment-complete',
});

ACH collects:

  • Bank routing number (9 digits)
  • Bank account number

Common Gotchas

  1. PCI Mode is irreversible: Cannot stress this enough. Use a subaccount. Test there first. Only enable on production when ready.
  2. Payment connector must exist: The paymentConnector name in TwiML must match an existing connector in your Console. Typo = failure.
  3. Recordings auto-mask card digits: In PCI Mode, call recordings automatically silence DTMF tones during card entry. You don't need to pause recording manually.
  4. chargeAmount is optional: You can tokenize a card without charging. Useful for saving cards for future use with tokenType: 'reusable'.
  5. Action URL is required: Without an action, you won't receive the payment result. The call will continue but you'll have no token.
  6. DTMF only by default: <Pay> uses DTMF (touchtone) input. Speech input requires additional configuration and is not available in all regions.
  7. maxAttempts resets the entire flow: On retry, the caller re-enters ALL fields, not just the one that failed.
  8. Test with real cards: Twilio Pay doesn't have test card numbers. Use your payment connector's test mode (e.g., Stripe test mode) for development.

MCP Tools Available

create_payment — Initiate payment capture on active call update_payment — Complete, cancel, or capture next field get_payment — Check payment status and token

Function Patterns Available

collect-payment.protected.js — TwiML webhook with <Pay> verb payment-complete.protected.js — Action URL handler payment-status.protected.js — Status callback handler

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.