pay

View as MarkdownOpen in Claude

Collect and process a credit card payment during the call. Generates a SWML pay verb that walks the caller through entering card details via DTMF or voice, then submits to your payment connector endpoint.

Parameters

opts
objectRequired

Payment configuration object.

opts.paymentConnectorUrl
stringRequired

URL of your payment processing endpoint. SignalWire sends the collected card data to this URL for processing.

opts.inputMethod
stringDefaults to dtmf

How the caller provides card details.

  • "dtmf" — caller enters digits on the keypad
  • "voice" — caller speaks the numbers
opts.statusUrl
string

URL to receive payment status change webhook notifications.

opts.paymentMethod
stringDefaults to credit-card

Payment method type. Currently only "credit-card" is supported.

opts.timeout
numberDefaults to 5

Seconds to wait for the next DTMF digit before timing out.

opts.maxAttempts
numberDefaults to 1

Number of retry attempts if payment collection fails.

opts.securityCode
booleanDefaults to true

Whether to prompt the caller for the card’s security code (CVV).

opts.postalCode
boolean | stringDefaults to true

Whether to prompt for the billing postal code. Pass true to prompt, false to skip, or a string with the actual postal code to use without prompting.

opts.minPostalCodeLength
numberDefaults to 0

Minimum number of digits required for the postal code.

opts.tokenType
stringDefaults to reusable

Payment token type.

  • "one-time" — single-use token
  • "reusable" — token can be charged again later
opts.chargeAmount
string

Amount to charge as a decimal string (e.g., "49.99").

opts.currency
stringDefaults to usd

ISO 4217 currency code (e.g., "usd", "eur").

opts.language
stringDefaults to en-US

Language for TTS payment prompts (e.g., "en-US", "es-MX").

opts.voice
stringDefaults to woman

TTS voice for payment prompts (e.g., "woman", "man").

opts.description
string

Custom description for the payment transaction.

opts.validCardTypes
stringDefaults to visa mastercard amex

Space-separated list of accepted card types.

opts.parameters
PaymentParameter[]

Additional name/value pairs to send to the payment connector. Use createPaymentParameter() to build entries.

opts.prompts
PaymentPrompt[]

Custom prompt configurations to override default payment prompts. Use createPaymentPrompt() to build entries.

opts.aiResponse
stringDefaults to 'The payment status is ${pay_result}, do not mention anything else about collecting payment if successful.'

AI response template after payment completes. The ${pay_result} variable is substituted with the payment outcome. When omitted, the default template is used.

Returns

FunctionResultthis, for chaining.

Example

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult()
4 .pay({
5 paymentConnectorUrl: 'https://payments.example.com/connector',
6 chargeAmount: '49.99',
7 currency: 'usd',
8 });