Studio uses Widgets to represent various parts of Twilio's API that can then be stitched together in your Studio Flow to build out robust applications that require no coding on your part.
New to Twilio Studio? Check out our Getting Started guide!
The Capture Payments Widget allows you to securely capture credit card details on a call and either tokenize or process a payment using a Payment Gateway. This widget uses the underlying TwiML verb <Pay>.
Use of Capture Payments requires PCI Mode to be enabled in Voice Settings. The Widget may not appear in your Widget Library for a couple of minutes after toggling this setting to true.
Currently, the Capture Payments Widget only supports Stripe Pay Connector so you can use this Widget to perform charge and tokenize transactions using Stripe Payment Gateway.
The Capture Payments Widget also accepts a number of configuration options that you can use to configure the call language, max attempts, the duration before timeout, credit card types accepted, and other payment properties.
Name | Description | Default |
---|---|---|
Timeout | Sets the limit in seconds to wait for the caller to press another digit before moving on to validate the digits captured. | 5 |
Max Attempts | Number of times to retry when collecting information. | 2 |
Language | Language to speak when prompting the caller for credit card details. | empty |
Valid Card Types | Credit card types that should be accepted. Allows multiple values. | empty |
Request Security Code | Whether to prompt for credit card security code. | true |
Request Postal Code | Whether to prompt for credit card postal code. | true |
Pay Connector | Unique Name corresponding to the Payment Gateway Connector installed in Twilio Marketplace Add-ons | empty |
Payment Token Type | Select one-time payment or reusable payment. | Resuable |
Charge Card with Amount | Amount to be charged. | empty |
Currency | Currency to use when charging the card. | US Dollar (USD) |
Description | Description of the payment. | empty |
Minimum Postal Code Length | Minimum length of postal code if Request Postal Code is set to true. | empty |
Payment Method | The payment method to be used (credit-card or ach-debit) | credit-card |
Bank Account Type | Bank account type being charged if using ach-debit as the Payment Method | consumer-checking |
These events trigger transitions from this Widget to another Widget in your Flow. For more information on working with Studio transitions, see this guide.
Name | Description |
---|---|
Success | Payment has completed successfully. |
Max Failed Attempts | Maximum number of failed attempts has been reached. |
Provider Error | Error communicating with Payment Provider. |
Pay Interrupted | Payment process interrupted by caller pressing *. |
Hang Up | Caller hung up during payment process. |
Validation Error | Invalid attributes received. |
When the Capture Payments Widget executes, it will have stored the following variables for use throughout your Studio Flow (where MY_WIDGET_NAME
is the name of your actual widget). For more information on working with variables in Studio, see this guide.
Find definitions and examples for these variables at the Payment page.
Name | Liquid Template Language |
---|---|
Expiration Date | {{widgets.MY_WIDGET_NAME.ExpirationDate}} |
Payment Card Number | {{widgets.MY_WIDGET_NAME.PaymentCardNumber}} |
Payment Card Postal Code | {{widgets.MY_WIDGET_NAME.PaymentCardPostalCode}} |
Payment Card Type | {{widgets.MY_WIDGET_NAME.PaymentCardType}} |
Payment Confirmation Code | {{widgets.MY_WIDGET_NAME.PaymentConfirmationCode}} |
Payment Token | {{widgets.MY_WIDGET_NAME.PaymentToken}} |
Security Code | {{widgets.MY_WIDGET_NAME.SecurityCode}} |
This example shows a Flow that enables a customer to pay for their order. The customer will press 1 to confirm the total amount to be charged before they are prompted with questions about their payment information. The call will then notify the customer if their payment was successful. Notice that the connector is not specified which would mean the default Pay Connector is used (the connector with the unique name Default associated with your account).
Learn how to set up your payment provider with Twilio in How to capture your first payment using <Pay>.
Now that you know the basics of the Capture Payments Widget, you may want to learn more about Payments:
We can't wait to see what you build!