Twilio 有没有办法通过DTMF输入美元/美分?
我目前正在使用以下流程开发一个电话付费系统:Twilio 有没有办法通过DTMF输入美元/美分?,twilio,twilio-twiml,twilio-programmable-voice,Twilio,Twilio Twiml,Twilio Programmable Voice,我目前正在使用以下流程开发一个电话付费系统: 客户在我们的账号 支付金额 -将前2个作为变量传递给Stripe 我面临的问题是如何筹集资金。有没有办法将金额从单个字符串转换为十进制字符串 例如,12300变为123.00 所有的建议都很受欢迎,因为目前的工作原理是只需几美分就添加第三个,但从用户体验/用户界面的角度来看,这感觉很麻烦。我编辑了这个答案,因为我成功地完成了这一点 我用录音室和函数做的 提示调用者使用星号键()作为小数点输入金额。例如,要输入$5.43,他们应该输入543,然后按
客户在我们的账号
支付金额
-将前2个
作为变量传递给Stripe
12300
变为123.00
所有的建议都很受欢迎,因为目前的工作原理是只需几美分就添加第三个
,但从用户体验/用户界面的角度来看,这感觉很麻烦。我编辑了这个答案,因为我成功地完成了这一点
我用录音室和函数做的
提示调用者使用星号键()作为小数点输入金额。例如,要输入$5.43,他们应该输入543,然后按#
然后,我将收集到的数字作为参数发送到函数小部件中,插入“amount”作为键,{{widgets.gather_1.digits}}
作为参数值
我编写了以下函数:
exports.handler = function(context, event, callback) {
const rawamount = event.amount;
const decimalamount = rawamount.replace("*",".");
const response = decimalamount;
callback(null, response);
};
然后在
小部件中,我在AMOUNT字段中插入了{{widget.function_1.body}
您的付款应以美元和美分进行
让我知道这是否有效。如果你需要我的工作室流程的截图,请告诉我
添加:
如果有人想用作模板(有人请求),这里有一个示例流
打开一个空白的Studio流
在“配置”选项卡下的触发器小部件中,单击“显示流JSON”删除所有以前的代码并将代码粘贴到下面的内部并保存
您的流应该会生成
然后创建函数。JSON之后的代码和说明
请注意:虽然流程中可能会弹出一个函数,但您将无法访问它,必须在您的帐户下创建它
{
"description": "A New Flow",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
{
"next": "gather_1",
"event": "incomingCall"
},
{
"event": "incomingRequest"
}
],
"properties": {
"offset": {
"x": 0,
"y": 0
}
}
},
{
"name": "gather_1",
"type": "gather-input-on-call",
"transitions": [
{
"next": "function_1",
"event": "keypress"
},
{
"event": "speech"
},
{
"event": "timeout"
}
],
"properties": {
"voice": "man",
"speech_timeout": "auto",
"offset": {
"x": 30,
"y": 270
},
"loop": 1,
"finish_on_key": "#",
"say": "Please enter an amount, then press pound. To enter with cents use the star key. for example to enter $6.25 press six star two five.",
"language": "en-US",
"stop_gather": true,
"gather_language": "en",
"profanity_filter": "true",
"timeout": 5
}
},
{
"name": "function_1",
"type": "run-function",
"transitions": [
{
"next": "say_play_2",
"event": "success"
},
{
"event": "fail"
}
],
"properties": {
"offset": {
"x": -60,
"y": 530
},
"parameters": [
{
"value": "{{widgets.gather_1.Digits}}",
"key": "amount"
}
],
"url": "https://charcoal-sloth-2579.twil.io/insert-decimal"
}
},
{
"name": "say_play_2",
"type": "say-play",
"transitions": [
{
"next": "pay_1",
"event": "audioComplete"
}
],
"properties": {
"voice": "man",
"offset": {
"x": -59,
"y": 839
},
"loop": 1,
"say": "You entered ${{widgets.function_1.body}}",
"language": "en-US"
}
},
{
"name": "pay_1",
"type": "capture-payments",
"transitions": [
{
"next": "say_play_3",
"event": "success"
},
{
"next": "say_play_4",
"event": "maxFailedAttempts"
},
{
"next": "say_play_4",
"event": "providerError"
},
{
"next": "say_play_4",
"event": "payInterrupted"
},
{
"next": "say_play_4",
"event": "hangup"
},
{
"next": "say_play_4",
"event": "validationError"
}
],
"properties": {
"security_code": true,
"offset": {
"x": -70,
"y": 1140
},
"max_attempts": 2,
"payment_connector": "Stripe_Connector",
"payment_amount": "{{widgets.function_1.body}}",
"currency": "usd",
"language": "en-US",
"postal_code": "false",
"payment_token_type": "one-time",
"timeout": 5,
"valid_card_types": [
"visa",
"master-card",
"amex",
"discover"
]
}
},
{
"name": "say_play_3",
"type": "say-play",
"transitions": [
{
"event": "audioComplete"
}
],
"properties": {
"voice": "man",
"offset": {
"x": -185,
"y": 1433
},
"loop": 1,
"say": "Your payment ${{widgets.function_1.body}}was successful, Thank you.",
"language": "en-US"
}
},
{
"name": "say_play_4",
"type": "say-play",
"transitions": [
{
"event": "audioComplete"
}
],
"properties": {
"voice": "man",
"offset": {
"x": 190,
"y": 1456
},
"loop": 1,
"say": "There was an error with your payment. Goodbye!",
"language": "en-US"
}
}
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": true
}
}
使用以下代码创建函数:
exports.handler = function(context, event, callback) {
const amount = event.amount;
const convert = amount.replace('*', '.');
callback(null, convert);
};
确保在流程中检查function小部件是否选择了正确的函数,并插入以下参数
KEY:amount VALUE:{{{widgets.YOUR_GATHER_widget NAME.body}
我编辑了此答案,因为我成功地完成了此操作
我用录音室和函数做的
提示调用者使用星号键()作为小数点输入金额。例如,要输入$5.43,他们应该输入543,然后按#
然后,我将收集到的数字作为参数发送到函数小部件中,插入“amount”作为键,{{widgets.gather_1.digits}}
作为参数值
我编写了以下函数:
exports.handler = function(context, event, callback) {
const rawamount = event.amount;
const decimalamount = rawamount.replace("*",".");
const response = decimalamount;
callback(null, response);
};
然后在
小部件中,我在AMOUNT字段中插入了{{widget.function_1.body}
您的付款应以美元和美分进行
让我知道这是否有效。如果你需要我的工作室流程的截图,请告诉我
添加:
如果有人想用作模板(有人请求),这里有一个示例流
打开一个空白的Studio流
在“配置”选项卡下的触发器小部件中,单击“显示流JSON”删除所有以前的代码并将代码粘贴到下面的内部并保存
您的流应该会生成
然后创建函数。JSON之后的代码和说明
请注意:虽然流程中可能会弹出一个函数,但您将无法访问它,必须在您的帐户下创建它
{
"description": "A New Flow",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
{
"next": "gather_1",
"event": "incomingCall"
},
{
"event": "incomingRequest"
}
],
"properties": {
"offset": {
"x": 0,
"y": 0
}
}
},
{
"name": "gather_1",
"type": "gather-input-on-call",
"transitions": [
{
"next": "function_1",
"event": "keypress"
},
{
"event": "speech"
},
{
"event": "timeout"
}
],
"properties": {
"voice": "man",
"speech_timeout": "auto",
"offset": {
"x": 30,
"y": 270
},
"loop": 1,
"finish_on_key": "#",
"say": "Please enter an amount, then press pound. To enter with cents use the star key. for example to enter $6.25 press six star two five.",
"language": "en-US",
"stop_gather": true,
"gather_language": "en",
"profanity_filter": "true",
"timeout": 5
}
},
{
"name": "function_1",
"type": "run-function",
"transitions": [
{
"next": "say_play_2",
"event": "success"
},
{
"event": "fail"
}
],
"properties": {
"offset": {
"x": -60,
"y": 530
},
"parameters": [
{
"value": "{{widgets.gather_1.Digits}}",
"key": "amount"
}
],
"url": "https://charcoal-sloth-2579.twil.io/insert-decimal"
}
},
{
"name": "say_play_2",
"type": "say-play",
"transitions": [
{
"next": "pay_1",
"event": "audioComplete"
}
],
"properties": {
"voice": "man",
"offset": {
"x": -59,
"y": 839
},
"loop": 1,
"say": "You entered ${{widgets.function_1.body}}",
"language": "en-US"
}
},
{
"name": "pay_1",
"type": "capture-payments",
"transitions": [
{
"next": "say_play_3",
"event": "success"
},
{
"next": "say_play_4",
"event": "maxFailedAttempts"
},
{
"next": "say_play_4",
"event": "providerError"
},
{
"next": "say_play_4",
"event": "payInterrupted"
},
{
"next": "say_play_4",
"event": "hangup"
},
{
"next": "say_play_4",
"event": "validationError"
}
],
"properties": {
"security_code": true,
"offset": {
"x": -70,
"y": 1140
},
"max_attempts": 2,
"payment_connector": "Stripe_Connector",
"payment_amount": "{{widgets.function_1.body}}",
"currency": "usd",
"language": "en-US",
"postal_code": "false",
"payment_token_type": "one-time",
"timeout": 5,
"valid_card_types": [
"visa",
"master-card",
"amex",
"discover"
]
}
},
{
"name": "say_play_3",
"type": "say-play",
"transitions": [
{
"event": "audioComplete"
}
],
"properties": {
"voice": "man",
"offset": {
"x": -185,
"y": 1433
},
"loop": 1,
"say": "Your payment ${{widgets.function_1.body}}was successful, Thank you.",
"language": "en-US"
}
},
{
"name": "say_play_4",
"type": "say-play",
"transitions": [
{
"event": "audioComplete"
}
],
"properties": {
"voice": "man",
"offset": {
"x": 190,
"y": 1456
},
"loop": 1,
"say": "There was an error with your payment. Goodbye!",
"language": "en-US"
}
}
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": true
}
}
使用以下代码创建函数:
exports.handler = function(context, event, callback) {
const amount = event.amount;
const convert = amount.replace('*', '.');
callback(null, convert);
};
确保在流程中检查功能小部件是否选择了正确的功能,并插入以下参数
键:amount VALUE:{{{widgets.YOUR_GATHER_widget NAME.body}
我将发布代码,我无法阅读您的完整消息请回复评论我将发布代码,我无法阅读您的完整信息,请回复评论