For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • BedrockAgent
      • CLI Tools
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
        • ai
        • ai_hold
        • ai_message
        • ai_unhold
        • amazon_bedrock
        • answer
        • bind_digit
        • clear_digit_bindings
        • collect
        • connect
        • denoise
        • denoise_stop
        • detect
        • disconnect
        • echo
        • hangup
        • hold
        • join_conference
        • join_room
        • leave_conference
        • leave_room
        • live_transcribe
        • live_translate
        • on
        • pass_
        • pay
        • play
        • play_and_collect
        • queue_enter
        • queue_leave
        • receive_fax
        • record
        • refer
        • send_digits
        • send_fax
        • stream
        • tap
        • transfer
        • unhold
        • user_event
        • wait_for
        • wait_for_ended
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
RELAYCall

pay

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

play

Next
Built with

Start a payment collection session on the call. Collects credit card or other payment information from the caller via DTMF. Returns a PayAction that you can use to stop the payment flow or wait for it to complete.

This method emits calling.call.pay events. See Call Events for payload details.

Parameters

payment_connector_url
strRequired

URL of the payment connector service that processes the payment.

control_id
Optional[str]

Custom control ID. Auto-generated if not provided.

input_method
Optional[str]

How the caller provides payment info.

  • "dtmf" — caller enters digits on the keypad
  • "speech" — caller speaks the payment information
status_url
Optional[str]

URL to receive payment status webhooks.

payment_method
Optional[str]

Payment method type. Valid values: "credit-card".

timeout
Optional[str]

Timeout for the payment session.

max_attempts
Optional[str]

Maximum number of input attempts before failing.

security_code
Optional[str]

Whether to collect CVV.

  • "true" — prompt the caller for the security code
  • "false" — skip security code collection
postal_code
Optional[str]

Whether to collect postal code.

  • "true" — prompt the caller for the postal code
  • "false" — skip postal code collection
min_postal_code_length
Optional[str]

Minimum length for the postal code.

token_type
Optional[str]

Tokenization type for the payment data.

charge_amount
Optional[str]

Amount to charge (e.g., "29.99").

currency
Optional[str]

Currency code (e.g., "USD", "EUR").

language
Optional[str]

Language for payment prompts (e.g., "en").

voice
Optional[str]

Voice for TTS prompts during the payment flow.

description
Optional[str]

Description of the payment/charge.

valid_card_types
Optional[str]

Comma-separated list of accepted card types (e.g., "visa,mastercard,amex").

parameters
Optional[list[dict]]

Additional parameters to pass to the payment connector.

prompts
Optional[list[dict]]

Custom prompts for the payment flow.

on_completed
Optional[Callable[[RelayEvent], Any]]

Callback invoked when the payment operation completes.

Returns

PayAction — An action handle with stop() and wait() methods.

Example

1from signalwire.relay import RelayClient
2
3client = RelayClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7 contexts=["default"],
8)
9
10@client.on_call
11async def handle_call(call):
12 await call.answer()
13 await call.play([{"type": "tts", "text": "We will now collect your payment."}])
14
15 action = await call.pay(
16 payment_connector_url="https://example.com/payment-connector",
17 charge_amount="29.99",
18 currency="USD",
19 security_code="true",
20 postal_code="true",
21 )
22 event = await action.wait()
23
24 state = event.params.get("state", "")
25 if state == "finished":
26 await call.play([{"type": "tts", "text": "Payment processed successfully."}])
27 else:
28 await call.play([{"type": "tts", "text": "Payment failed. Please try again later."}])
29
30 await call.hangup()
31
32client.run()