Is there a way to enter dollars/cents via DTMF?

独自空忆成欢 提交于 2020-07-09 19:48:58

问题


I'm currently working on a pay-by-phone system with this flow:

  • <Gather> customer's account number with us
  • <Gather> amount to pay
  • <Pay> - with the previous 2 <Gather>s passed as variables to Stripe

The issue I am having is collecting the amount. Is there a way to convert the amount from a single string to a decimal string?

eg. 12300 becomes 123.00

All suggestions welcome as the current working theory is to add a third <Gather> just for the cents but this feels cumbersome from a UX/UI perspective.


回答1:


I edited this answer, since I was successful in accomplishing this.

I did it with STUDIO and FUNCTIONS.

Prompt the caller to enter the amount using star key (*) as a decimal. For example to enter $5.43 they should enter 5*43 and then press #.

then I took the gathered digits and sent them out as a parameter in the FUNCTION widget by inserting "amount" as the KEY and {{widgets.gather_1.digits}} as the VALUE of the parameter.

I wrote the following function:

exports.handler = function(context, event, callback) {

const rawamount = event.amount;
const decimalamount = rawamount.replace("*",".");
const response = decimalamount;

  callback(null, response);
};

then in the <pay> widget I inserted {{widget.function_1.body}} in the AMOUNT field.

Your payment should process with dollars and cents.

Let me know if this worked. If you need screenshots of my studio flow let me know.



来源:https://stackoverflow.com/questions/62324697/is-there-a-way-to-enter-dollars-cents-via-dtmf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!