> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # pay > Collect payment information on a call. [payaction]: /docs/server-sdks/reference/typescript/relay/actions [calling-call-pay]: /docs/server-sdks/reference/typescript/relay/call#events [call-events]: /docs/server-sdks/reference/typescript/relay/call#events Start a payment collection session on the call. Collects credit card or other payment information from the caller via DTMF. Returns a [`PayAction`][payaction] that you can use to stop the payment flow or wait for it to complete. > **Info** > > This method emits [`calling.call.pay`][calling-call-pay] events. See [Call Events][call-events] for payload details. ## **Parameters** **`paymentConnectorUrl`** `string` — required URL of the payment connector service that processes the payment. --- **`controlId`** `string | undefined` Custom control ID. Auto-generated if not provided. --- **`inputMethod`** `string | undefined` How the caller provides payment info. * `"dtmf"` -- caller enters digits on the keypad * `"speech"` -- caller speaks the payment information --- **`chargeAmount`** `string | undefined` Amount to charge (e.g., `"29.99"`). --- **`currency`** `string | undefined` Currency code (e.g., `"USD"`, `"EUR"`). --- **`securityCode`** `string | undefined` Whether to collect CVV (`"true"` or `"false"`). --- **`postalCode`** `string | undefined` Whether to collect postal code (`"true"` or `"false"`). --- **`statusUrl`** `string | undefined` URL to receive payment status webhooks. --- **`paymentMethod`** `string | undefined` Payment method type (e.g., `"credit-card"`). --- **`timeout`** `string | undefined` Timeout for the payment session. --- **`maxAttempts`** `string | undefined` Maximum number of retry attempts for failed input. --- **`minPostalCodeLength`** `string | undefined` Minimum length required for the postal code. --- **`tokenType`** `string | undefined` Type of payment token to generate. --- **`language`** `string | undefined` Language for payment prompts (e.g., `"en"`). --- **`voice`** `string | undefined` Voice for payment prompts. --- **`description`** `string | undefined` Description of the payment or charge. --- **`validCardTypes`** `string | undefined` Comma-separated list of accepted card types (e.g., `"visa,mastercard"`). --- **`parameters`** `Record[] | undefined` Additional payment connector parameters. --- **`prompts`** `Record[] | undefined` Custom prompt overrides for the payment flow. --- **`onCompleted`** `(event: RelayEvent) => void | Promise` Callback invoked when the payment operation completes. --- ## **Returns** `Promise<`[`PayAction`][payaction]`>` -- An action handle with `stop()` and `wait()` methods. ## **Example** ```typescript {13} import { RelayClient } from '@signalwire/sdk'; const client = new RelayClient({ project: process.env.SIGNALWIRE_PROJECT_ID!, token: process.env.SIGNALWIRE_API_TOKEN!, contexts: ['default'] }); client.onCall(async (call) => { await call.answer(); await call.play([{ type: 'tts', text: 'We will now collect your payment.' }]); const action = await call.pay('https://example.com/payment-connector', { chargeAmount: '29.99', currency: 'USD', securityCode: 'true', postalCode: 'true', }); const event = await action.wait(); const state = (event.params.state ?? '') as string; if (state === 'finished') { await call.play([{ type: 'tts', text: 'Payment processed successfully.' }]); } else { await call.play([{ type: 'tts', text: 'Payment failed. Please try again later.' }]); } await call.hangup(); }); await client.run(); ``` > Collect payment information on a call.