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

# pay

> Collect and process a credit card payment during a call.

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

**`opts`** `object` — required

Payment configuration object.

---

**`opts.paymentConnectorUrl`** `string` — required

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

---

**`opts.inputMethod`** `string` — default: 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`** `string` — default: credit-card

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

---

**`opts.timeout`** `number` — default: 5

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

---

**`opts.maxAttempts`** `number` — default: 1

Number of retry attempts if payment collection fails.

---

**`opts.securityCode`** `boolean` — default: true

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

---

**`opts.postalCode`** `boolean | string` — default: 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`** `number` — default: 0

Minimum number of digits required for the postal code.

---

**`opts.tokenType`** `string` — default: 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`** `string` — default: usd

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

---

**`opts.language`** `string` — default: en-US

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

---

**`opts.voice`** `string` — default: woman

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

---

**`opts.description`** `string`

Custom description for the payment transaction.

---

**`opts.validCardTypes`** `string` — default: 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()`][create-payment-parameter] to build entries.

---

**`opts.prompts`** `PaymentPrompt[]`

Custom prompt configurations to override default payment prompts.
Use [`createPaymentPrompt()`][create-payment-prompt] to build entries.

---

**`opts.aiResponse`** `string` — default: '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**

[`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',
  });
```