Search code examples
asteriskfreepbxdialplan

Gotoif how to set it to allow a 3 or 4 digit response to meet the condition


Was wondering if anyone can help me currently I only accept 3 cvv numbers and I need to chage this to 4 but I can't find any where online how to put a range in this statement.

exten => s,n,GotoIf($[${LEN(${vrCC_CCV})}=3]?wait:cc_ccvinv)

Visa/Mastercard are fine with 3 didits but American Express requires the four digits on front of the card.

Any assistance would be greatful.


Solution

  • Like any other language asterisk support AND/OR in expressions.

    https://www.voip-info.org/asterisk-cmd-gotoif/

    Example 2
    
    
    ; Are the first three digits of the returned value of ${ENUM} are
    ;  either SIP or IAX?  If not,  we ignore and pass to normal
    ;  dialing path at priority 4.
    ;
    exten => _011X.,2,GotoIf($[$["${ENUM:0:3}" = "SIP"] | $["${ENUM:0:3}" = "IAX"]]?3:4)
    

    More info about expressions in dialplan

    https://www.voip-info.org/asterisk-expressions/