In Twilio Studio Flow, how to use 'Gather widget' for one-off dollar/cents Stripe payment amount for 'Capture Payments' widget - twilio

I'm not a developer so I'm largely restricted to TWILIO STUDIO FLOW--with decent success.
Attempting now (unsuccessfully) to add an IVR payment option 'Press X to pay your bill'.
When prompted by a Gather widget the caller (customer) enters the bill amount. This gathered value becomes the input parameter to the Capture Payments widget for payment processing by Stripe.com.
I have confirmed that my Twilio-Stripe account 'Default' connection is correct by successfully processing a hard-coded charge amount (using Twilio's example Twiml code).
Since we need customer/callers to enter variable bill amounts, we're doing this via a Gather Input wizard (since I'm not a programmer). I've tried repeatedly to use the Studio Flow 'Capture Payment' wizard with three recurring problems.
Can someone tell me how to convert the digits entered into a dollar-and-cent value (effectively 'nnnn' x .01 = 'nn.nn') OR how to enter a decimal via the telephone touch pad
read back the 'xx dollars and xx cents' amount entered confirmation verbiage before continuing to process payment
Is there perhaps any obscure something else required to get a successful payment via the Flow Pay wizard (other than dragging the connector and providing valid CC credentials)? No matter what I have tried, it does not appear to recognize the DTMF codes and after three attempt (with a valid credit card), it continues to disconnect.
In the gather_confirm_amount widget input box is this verbiage:
You entered the amount of {{widgets.gather_amount_due.Digits | split: "." |
first}} dollars and {{widgets.gather_amount_due.Digits | split: "." | last}}
cents.
If this is correct, press 1.
This value is entered into the 'Charge Card With Amount' field using the following
{{widgets.gather_amount_due.Digits | split: "." | first}} dollars and
{{widgets.gather_amount_due.Digits | split: "." | last}}'''
When user enters into 100 into '''gather_amount_due''' widget I get 'You entered the amount of 100 dollars and 100 cents.'
Obviously, I am trying to return a response 'You entered ONE DOLLARS and ZERO CENTS'.
Also, the Stripe payment prompt says three times 'Please enter your credit card number' and then disconnects due to 3 max attempts. It does not appear to be acknowledging the DTMF inputs at all.
Thank you.

I'm trying to figure out the same issue, maybe you can prompt the customer to use * as the decimal point and then replace the character?
Reading it back to the customer I assume you got figured out? I'm using Studio and if you type in the number say $123.45 and use the say-as interpret-as"currency" and add the number with $ or USD it will dictate it (at least using the Polly voices). I basically looked up SSML tags and figured this out.
<say-as interpret-as="currency">$123.45</say-as>
I assume you debugged the DTMF issue but they say there may be some difficulty with DTMF on international or mobile calls. The other way would to be Speech to Text and may also solve the decimal point issue.

I have successfully been able to accept dollars and cents and read it back.
To have the caller enter dollars and cents you can do 1 of 2 ways. Either have the caller press "star" as a decimal point so for a $10.50 payment they would enter 1,0,*,5,0. Or they can just add 2 digits as cents so for $10.50 they would press 1,0,5,0 and for lets say $5 they would press 5,0,0.
Now we take the {{widgets.gather_amount_due.Digits}} and send it a function widget by placing it in a KEY VALUE function parameter and and taking those digits in the function and converting it into a decimal number like so.
In the examples below the KEY is "amount".
For method without star use this.
exports.handler = function(context, event, callback) {
//bring in amount
const amount = event.amount;
//add decimal
const response = (amount / 100).toFixed(2);
callback(null, response);
};
For method with star key use this.
exports.handler = function(context, event, callback) {
//bring in amount
const amount = event.amount;
//add decimal
const response = amount.replace('*', '.');
callback(null, response);
};
Then take the return of the function {{widgets.YOUR_FUNCTION_NAME.body}} and place it in the "Amount" field of the pay widget and viola! You can also take that same return and place it in a say widget to read back the amount.

Related

OrderClose not working in MQL4 without proper error feedback

So I have this EA that should close 2 trades together under certain conditions. Sometimes it closes only 1/2, sometimes it closes both smoothly. I cannot really pinpoint the times it closes only one and detect a pattern so I can spot the logical error.
P.S.: Obviously the trades are from different pairs running from an EA within 1 chart/pair.
The error message is this:
invalid ticket for OrderClose function
But the trade clearly exists, and i make sure I have it within the int as every time I restart the EA, if trade is already open (detected by comment) it has a message like that:
"Buy trade: [ticket number], recognised."
So I know for fact that it is recognised and within the proper int to be used. Any ideas about the error's source?
OrderClose(TicketA,LotSize,iClose(NULL,0,0),Slippage,clrGray);
OrderClose(TicketB,LotSize,iClose(SymbolB,0,0),Slippage,clrGray);
Will this fix this? I mean... it will be errored out 2/4 close orders... but I don't really care about how beautiful it looks.
OrderClose(TicketA,LotSize,Ask,Slippage,clrGray);
OrderClose(TicketB,LotSize,Bid,Slippage,clrGray);
OrderClose(TicketA,LotSize,Ask,Slippage,clrGray);
OrderClose(TicketB,LotSize,Ask,Slippage,clrGray);
Make sure that you didn't override TicketA or TicketB variable somewhere.
You can use OrderLots() function instead of using LotSize, especially when this value is changing during EA process. Additionally, by checking the OrderType(), you will avoid a mistake at the closing price.
Example:
if(yourCloseCondition){
if(OrderSelect(ticket, SELECT_BY_TICKET)){
if(OrderType() == OP_BUY){
if(OrderClose(ticket, OrderLots(), Bid, 0)){
//Print("success");
}
}
if(OrderType() == OP_SELL){
if(OrderClose(ticket, OrderLots(), Ask, 0)){
//Print("success");
}
}
}
}
Also check docs: OrderClose() and OrderType().
Update:
For different pairs running within 1 chart use close price from MarketInfo
Example:
MarketInfo("EURUSD",MODE_BID);
Check MarketInfo().

Call Directory Extension CallKit does't recognize numbers with more than 9 digits

I'm working with CallKit and developing an app with a Call Directory Extension. I've followed this tutorial and I'm currently test the capability of identify numbers that the user does't have in his contacts and show an ID from my app, but although is working perfectly with numbers of 1 to 9 digits, for example 123456, when I set numbers with 10 or more digits, iOs doesn't recognize the number. After a day and a half of google it, I've have found no information about that. If anyone can help me I'll appreciate it. Thanks in advance.
The method for set the phone numbers for recognize:
private func addAllIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext) {
// Retrieve phone numbers to identify and their identification labels from data store. For optimal performance and memory usage when there are many phone numbers,
// consider only loading a subset of numbers at a given time and using autorelease pool(s) to release objects allocated during each batch of numbers which are loaded.
//
// Numbers must be provided in numerically ascending order.
let allPhoneNumbers: [CXCallDirectoryPhoneNumber] = [ 123456789, 1_888_555_5555 ]
let labels = [ "ID test", "Local business" ]
for (phoneNumber, label) in zip(allPhoneNumbers, labels) {
context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
}
}
With this code, when I simulate a call with the number 123456789, iOS shows the tag "ID test" and that's correct, but if I add any digit, for example 0 at the end: 1234567890, iOS does't show anything when I simulate a call. I don't know if I'm missing something.
Well, after a bunch of tests I could made it work. The point was that the phone must contain the full country code and the area code. So for example 00_52_55_4567_8932 877 or +52_55_4567_8932 both will work. But 55_4567_8932 and 4567_8932 will not work. I hope this can help someone else in the future. Thank you all!

What is the correct way to set StopLoss and TakeProfit in OrderSend() in MetaTrader4 EA?

I'm trying to figure out if there is a correct way to set the Stop Loss (SL) and Take Profit (TP) levels, when sending an order in an Expert Advisor, in MQL4 (Metatrader4). The functional template is:
OrderSend( symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, arrow_color);
So naturally I've tried to do the following:
double dSL = Point*MM_SL;
double dTP = Point*MM_TP;
if (buy) { cmd = OP_BUY; price = Ask; SL = ND(Bid - dSL); TP = ND(Ask + dTP); }
if (sell) { cmd = OP_SELL; price = Bid; SL = ND(Ask + dSL); TP = ND(Bid - dTP); }
ticket = OrderSend(SYM, cmd, LOTS, price, SLIP, SL, TP, comment, magic, 0, Blue);
However, there are as many variations as there are scripts and EA's. So far I have come across these.
In the MQL4 Reference in the MetaEditor, the documentation say to use:
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,
NormalizeDouble(Bid - StopLoss*Point,Digits),
NormalizeDouble(Ask + TakeProfit*Point,Digits),
"My order #2",3,D'2005.10.10 12:30',Red);
While in the "same" documentation online, they use:
double stoploss = NormalizeDouble(Bid - minstoplevel*Point,Digits);
double takeprofit = NormalizeDouble(Bid + minstoplevel*Point,Digits);
int ticket=OrderSend(Symbol(),OP_BUY,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen);
And so it goes on with various flavors, here, here and here...
Assuming we are interested in a OP_BUY and have the signs correct, we have the options for basing our SL and TP values on:
bid, bid
bid, ask
ask, ask
ask, bid
So what is the correct way to set the SL and TP for a BUY?
(What are the advantages or disadvantages of using the various variations?)
EDIT: 2018-06-12
Apart a few details, the answer is actually quite simple, although not obvious. Perhaps because MT4 only show Bid prices on the chart (by default) and not both Ask and Bid.
So because: Ask > Bid and Ask - Bid = Slippage, it doesn't matter which we choose as long as we know about the slippage. Then depending on what price you are following on the chart, you may wish to decide on using one over the other, adding or subtracting the Slippage accordingly.
So when you use the measure tool to get the Pip difference of currently shown prices, vs your "exact" SL/TP settings, you need to keep this in mind.
So to avoid having to put the Slippage in my code above, I used the following for OP_BUY: TP = ND(Bid + dTP); (and the opposite for OP_SELL.)
If you buy, you OP_BUY at Ask and close (SL, TP) at Bid.
If you sell, OP_SELL operation is made at Bid price, and closes at Ask.
Both SL and TP should stay at least within STOP_LEVEL * Point() distance from the current price to close ( Bid for buy, Ask for sell).
It is possible that STOP_LEVEL is zero - in such cases ( while MT4 accepts the order ) the Broker may reject it, based on its own algorithms ( Terms and Conditions may call it a "floating Stoplevel" rule or some similar Marketing-wise "re-dressed" term ).
It is adviced to send an OrderSend() request with zero values of SL and TP and modify it after you see that the order was sent successfully. Sometimes it is not required, sometimes that is even mandatory.
There is no difference between the two links you gave us: you may compute SL and TP and then pass them into the function or compute them based on OrderOpenPrice() +/- distance * Point().
So what is the correct way to set the SL and TP for a BUY ?
There is no such thing as "The Correct Way", there are rules to meet
Level 0: Syntax is to meet the call-signature ( the easiest one )
Level 1: all at Market XTO-s have to meet the right level of the current Price +/- slippage, make sure to repeat a RefreshRates()-test as close to the PriceDOMAIN-levels settings, otherwise they get rejected from the Broker side ( blocking one's trading engine at a non-deterministic add-on RTT-latency ) + GetLastError() == 129 | ERR_INVALID_PRICE
Level 2: yet another rules get set from Broker-side, in theire respective Service / Product definition in [ Trading Terms and Conditions ]. If one's OrderSend()-request fails to meet any one of these, again, the XTO will get rejected, having same adverse blocking effects, as noted in Level 1.
Some Brokers do not allow some XTO situations due to their T&C, so re-read such conditions with a due care. Any single of theirs rule, if violated, will lead to your XTO-instruction to get legally rejected, with all adverse effects, as noted above. Check all rules, as you will not like to see any of the following error-states + any of others, restricted by your Broker's T&C :
ERR_LONG_POSITIONS_ONLY_ALLOWED Buy orders only allowed
ERR_TRADE_TOO_MANY_ORDERS The amount of open and pending orders has reached the limit set by the broker
ERR_TRADE_HEDGE_PROHIBITED An attempt to open an order opposite to the existing one when hedging is disabled
ERR_TRADE_PROHIBITED_BY_FIFO An attempt to close an order contravening the FIFO rule
ERR_INVALID_STOPS Invalid stops
ERR_INVALID_TRADE_VOLUME Invalid trade volume
...
..
.
#ASSUME NOTHING ; Is the best & safest design-side (self)-directive

analyze and validate string and substring

hello I want to select a subchain and analyze it example:
my chain to analyze
NADSU 78000mc0cl0Css
NADBY 7808810008659
PAT 1 21D 089
I need to read and then analyze line by line of a .txt file after that I would like to verify through an if or case cycle that the paramenters could be fulfilled. I clarify the txt file has about 300 lines
the first three characters must be letters with a specific format the following is usually the 4 character or 5 that has a number depends on that number means something and the last is the purchase order number or the amount or type of wrap ... ... this is a generalized idea I'm only giving the minimum to understand ...
Annex example and my code
I put two real cases of the line to analyze
--- here the letters nad = purchase order BY = supplier the remaining one is the purchase order number
NADBY 7808810008659
--- here Pat means = type of payment. the first number = the type of payment if it is one the type of payment is counted if it is two credits. the average 21d = number of days to issue clearance and the 089 = number of days to pay
PAT 1 21D 089
--- here the letters nad = purchase order BY = buyer css = a boxes but it can be ss = minicams
NADSU 78000mc0cl0Css
fileopen ('nombre_doc.txt',r) do |fichero1|
fileopen ('copianombre_doc.txt',w) do |fichero2|
while linea= fichero1.gets
fichero1=gsub(/\s+/,'')

Data Element Type(DET) in Function Point Analysis?

I am studying function point analysis from Alvin Alexander's website.
http://alvinalexander.com/FunctionPoints/
In his example, he is calculating DETs from GUI screen but I cannot understand how he is counting. For example according to him at
http://alvinalexander.com/FunctionPoints/node26.shtml (end of page) DET of Create Project is five while there are only three input fields. Same is with other Screens. Can anyone help me? I'm stuck here.
A DET (Data Element Type) isn't just an input field: it's any piece of information recognizable by the user that crosses the application boundary. Usually, every input field on the screen is indeed a DET, but not always. I'm not going to get into that now, though, since in this particular case all the input fields are indeed DETs. Let's just talk about those 2 DETs that seem unaccounted for.
You should count 3 DETs for the 3 input fields (Project Name, Project Type and Project Description), and also 1 DET for the act of clicking on the Save button. Note that even if there were multiple ways to save the project (clicking on the Save button, pressing Enter etc) you would still count only 1 DET.
As for the fifth DET, I'm assuming the author is counting 1 DET for any messages the application is capable of showing in the process of creating a new project (confirmation message, any error messages, warnings etc). Again, you should only count 1 DET no matter how many possible messages there are. And I said I'm assuming because, while it is correct to count 1 DET for the capability of showing messages (it is, after all, information recognizable by the user that crosses the application boundary), he should have explicitly mentioned at least one message, especially since it's a teaching example.
DET basically count of controls/fields, error message & button/href on UI screen for transaction functions.
- 1 DET for 1 controls/fields.
- 1 DET for all error messages.
- 1 DET for all buttons/hrefs.
eg, 1 Text field = 1 DET
1 Label = 1 DET
1 Radio button group = 1 DET
2 Button (Submit & Cancel) = 1 DET
Total 4 DET.

Resources