***

title: pay
slug: /reference/typescript/agents/function-result/pay
description: Collect and process a credit card payment during a call.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[create-payment-parameter]: /docs/server-sdks/reference/typescript/agents/function-result/create-payment-parameter

[create-payment-prompt]: /docs/server-sdks/reference/typescript/agents/function-result/create-payment-prompt

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

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**

<ParamField path="opts" type="object" required={true} toc={true}>
  Payment configuration object.
</ParamField>

<Indent>
  <ParamField path="opts.paymentConnectorUrl" type="string" required={true} toc={true}>
    URL of your payment processing endpoint. SignalWire sends the collected card
    data to this URL for processing.
  </ParamField>

  <ParamField path="opts.inputMethod" type="string" default="dtmf" toc={true}>
    How the caller provides card details.

    * `"dtmf"` -- caller enters digits on the keypad
    * `"voice"` -- caller speaks the numbers
  </ParamField>

  <ParamField path="opts.statusUrl" type="string" toc={true}>
    URL to receive payment status change webhook notifications.
  </ParamField>

  <ParamField path="opts.paymentMethod" type="string" default="credit-card" toc={true}>
    Payment method type. Currently only `"credit-card"` is supported.
  </ParamField>

  <ParamField path="opts.timeout" type="number" default="5" toc={true}>
    Seconds to wait for the next DTMF digit before timing out.
  </ParamField>

  <ParamField path="opts.maxAttempts" type="number" default="1" toc={true}>
    Number of retry attempts if payment collection fails.
  </ParamField>

  <ParamField path="opts.securityCode" type="boolean" default="true" toc={true}>
    Whether to prompt the caller for the card's security code (CVV).
  </ParamField>

  <ParamField path="opts.postalCode" type="boolean | string" default="true" toc={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.
  </ParamField>

  <ParamField path="opts.minPostalCodeLength" type="number" default="0" toc={true}>
    Minimum number of digits required for the postal code.
  </ParamField>

  <ParamField path="opts.tokenType" type="string" default="reusable" toc={true}>
    Payment token type.

    * `"one-time"` -- single-use token
    * `"reusable"` -- token can be charged again later
  </ParamField>

  <ParamField path="opts.chargeAmount" type="string" toc={true}>
    Amount to charge as a decimal string (e.g., `"49.99"`).
  </ParamField>

  <ParamField path="opts.currency" type="string" default="usd" toc={true}>
    ISO 4217 currency code (e.g., `"usd"`, `"eur"`).
  </ParamField>

  <ParamField path="opts.language" type="string" default="en-US" toc={true}>
    Language for TTS payment prompts (e.g., `"en-US"`, `"es-MX"`).
  </ParamField>

  <ParamField path="opts.voice" type="string" default="woman" toc={true}>
    TTS voice for payment prompts (e.g., `"woman"`, `"man"`).
  </ParamField>

  <ParamField path="opts.description" type="string" toc={true}>
    Custom description for the payment transaction.
  </ParamField>

  <ParamField path="opts.validCardTypes" type="string" default="visa mastercard amex" toc={true}>
    Space-separated list of accepted card types.
  </ParamField>

  <ParamField path="opts.parameters" type={"PaymentParameter[]"} toc={true}>
    Additional name/value pairs to send to the payment connector.
    Use [`createPaymentParameter()`][create-payment-parameter] to build entries.
  </ParamField>

  <ParamField path="opts.prompts" type={"PaymentPrompt[]"} toc={true}>
    Custom prompt configurations to override default payment prompts.
    Use [`createPaymentPrompt()`][create-payment-prompt] to build entries.
  </ParamField>

  <ParamField path="opts.aiResponse" type="string" default="'The payment status is ${pay_result}, do not mention anything else about collecting payment if successful.'" toc={true}>
    AI response template after payment completes. The `${pay_result}` variable
    is substituted with the payment outcome. When omitted, the default template
    is used.
  </ParamField>
</Indent>

## **Returns**

[`FunctionResult`][functionresult] -- `this`, for chaining.

## **Example**

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult()
  .pay({
    paymentConnectorUrl: 'https://payments.example.com/connector',
    chargeAmount: '49.99',
    currency: 'usd',
  });
```