Credit Card Dialplan for Asterisk

Here is a working model for asking the questions needed to process the creditcard. I have also added in this code something called
paylib.py. This file is not complete and renders the code unable to process cards. This is because you have to have to put your
processor's integration code into play in this file. Everything else should work as expected

pyastcc-master.zip Download pyastcc-master.zip

something like the below should be added to your extensions file to run the credit card processing

#include ccext.conf
exten => _X.,n,Goto(ccmain,s,1)



I SUGGEST USING THIS WITH SOME KIND OF SSL CERTIFICATE FOR ENCRYPTION OF THE PHONE CALL OR RTP DATA

All of the below is included in ccext.conf in the compressed tar.gz file

ccext.conf:
[ccmain]
exten => s,1,Wait(2)
exten => s,2,Background(CC/ccintro)
exten => s,3,Macro(askdigits,enteracctnum,6,verifyacct.agi)
exten => s,4,Macro(askdigits,enteramt,8,verifymoney.agi)
exten => s,5,Macro(askdigits,enterzip,5,verifyzip.agi)
exten => s,6,Macro(askdigits,enteraddr,12,verifyaddr.agi)
exten => s,7,Macro(askdigits,entercc,25,verifycc.agi)
exten => s,8,Macro(askdigits,enterexpir,4,verifyexp.agi)
exten => s,9,Macro(askdigits,entercvv2,4,verifycvv2.agi)
exten => s,10,Background(CC/runccnow)
exten => s,11,AGI(runcc.agi|sale|${CCNUM}|${CCEXP}|${CVV2}|${CCAMT}|${ACCT}|${CCZIP}|${CCADDR})
exten => s,12,GOTO(rs-${APPRESULT},1)

exten => rs-ERROR,1,Playback(CC/tryagain)
exten => rs-ERROR,2,Goto(s,4)

exten => rs-APPROVED,1,Playback(CC/approved&CC/yourauthcodeis)
exten => rs-APPROVED,2,SayAlpha(${AUTHCODE})
exten => rs-APPROVED,3,Playback(CC/again&CC/yourauthcodeis)
exten => rs-APPROVED,4,SayAlpha(${AUTHCODE})
exten => rs-APPROVED,5,Playback(CC/thankyou)
exten => rs-APPROVED,6,Hangup()

exten => rs-DECLINED,1,Playback(CC/declined)
exten => rs-DECLINED,2,Goto(s,4)

[macro-askdigits]
exten => s,1,Read(thevalue,CC/${ARG1},${ARG2},skip,4,25)
exten => s,2,AGI(${ARG3}|${thevalue})
exten => s,3,GotoIf($["${verify}" = "0"]?i,1)
exten => i,1,Playback(CC/invalid)
exten => i,2,GotoIf($["${reason}" = ""]?4)
exten => i,3,Playback(CC/${reason})
exten => i,4,Goto(s,1)



Here is the Dialplan I used to create the audio files I needed. In this you will hit # after you make the recording. As well you will need to create a folder for the audio files. I used CC (/var/lib/asterisk/sounds/CC) and included
them in the file listed in this post.

[ccrecord]
exten => s,1,Answer
exten => s,n,Wait(2)
;record the credit card introduction
exten => s,n,Record(CC/ccintro:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/ccintro)
exten => s,n,Wait(2)
;record the "running credit card now" message
exten => s,n,Record(CC/runccnow:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/runccnow)
exten => s,n,Wait(2)
;record the "enter zipcode" message
exten => s,n,Record(CC/enterzip:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enterzip)
exten => s,n,Wait(2)
;record the "enter address digits now" message
exten => s,n,Record(CC/enteraddr:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enteraddr)
exten => s,n,Wait(2)
;record the "account not found" message
exten => s,n,Record(CC/acctnotfound:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/acctnotfound)
exten => s,n,Wait(2)
;record the "try again" message
exten => s,n,Record(CC/tryagain:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/tryagain)
exten => s,n,Wait(2)
;record the "thank you" message
exten => s,n,Record(CC/thankyou:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/thankyou)
exten => s,n,Wait(2)
;record the "approved" message
exten => s,n,Record(CC/approved:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/approved)
exten => s,n,Wait(2)
;record the "your authcode is" message
exten => s,n,Record(CC/yourauthcodeis:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/yourauthcodeis)
exten => s,n,Wait(2)
;record the "declined" message
exten => s,n,Record(CC/declined:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/declined)
exten => s,n,Wait(2)
;record the "enter expiration date" message
exten => s,n,Record(CC/enterexpir:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enterexpir)
exten => s,n,Wait(2)
;record the "enter credit card number" message
exten => s,n,Record(CC/entercc:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/entercc)
exten => s,n,Wait(2)
;record the "enter cvv2" message
exten => s,n,Record(CC/entercvv2:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/entercvv2)
exten => s,n,Wait(2)
;record the "enter dollar amount" message
exten => s,n,Record(CC/enteramt:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enteramt)
exten => s,n,Wait(2)
;record the "enter account number" message
exten => s,n,Record(CC/enteracctnum:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enteracctnum)
exten => s,n,Wait(2)
;record "again" message
exten => s,n,Record(CC/again:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/again)
exten => s,n,Wait(2)
;record "invalid" message
exten => s,n,Record(CC/invalid:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/invalid)
exten => s,n,Wait(2)
;record "unsupported card type" message
exten => s,n,Record(CC/unsuppcardtype:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/unsuppcardtype)
exten => s,n,Wait(2)
;record "invalid card number" message
exten => s,n,Record(CC/invcardnum:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/invcardnum)
exten => s,n,Wait(2)
;record "invalid card length" message
exten => s,n,Record(CC/invcardlen:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/invcardlen)
exten => s,5,Wait(2)
;record "followed by the pound sign" message
exten => s,6,Record(CC/followpound:ulaw)
exten => s,7,Wait(2)
exten => s,8,Playback(CC/followpound)
exten => s,n,Hangup()


Please email me with any questions or ideas.
schapman1974@gmail.com

15950 Views
Here is a working model for asking the questions needed to process the creditcard. I have also added in this code something called
paylib.py. This file is not complete and renders the code unable to process cards. This is because you have to have to put your
processor's integration code into play in this file. Everything else should work as expected

pyastcc-master.zip Download pyastcc-master.zip

something like the below should be added to your extensions file to run the credit card processing

#include ccext.conf
exten => _X.,n,Goto(ccmain,s,1)



I SUGGEST USING THIS WITH SOME KIND OF SSL CERTIFICATE FOR ENCRYPTION OF THE PHONE CALL OR RTP DATA

All of the below is included in ccext.conf in the compressed tar.gz file

ccext.conf:
[ccmain]
exten => s,1,Wait(2)
exten => s,2,Background(CC/ccintro)
exten => s,3,Macro(askdigits,enteracctnum,6,verifyacct.agi)
exten => s,4,Macro(askdigits,enteramt,8,verifymoney.agi)
exten => s,5,Macro(askdigits,enterzip,5,verifyzip.agi)
exten => s,6,Macro(askdigits,enteraddr,12,verifyaddr.agi)
exten => s,7,Macro(askdigits,entercc,25,verifycc.agi)
exten => s,8,Macro(askdigits,enterexpir,4,verifyexp.agi)
exten => s,9,Macro(askdigits,entercvv2,4,verifycvv2.agi)
exten => s,10,Background(CC/runccnow)
exten => s,11,AGI(runcc.agi|sale|${CCNUM}|${CCEXP}|${CVV2}|${CCAMT}|${ACCT}|${CCZIP}|${CCADDR})
exten => s,12,GOTO(rs-${APPRESULT},1)

exten => rs-ERROR,1,Playback(CC/tryagain)
exten => rs-ERROR,2,Goto(s,4)

exten => rs-APPROVED,1,Playback(CC/approved&CC/yourauthcodeis)
exten => rs-APPROVED,2,SayAlpha(${AUTHCODE})
exten => rs-APPROVED,3,Playback(CC/again&CC/yourauthcodeis)
exten => rs-APPROVED,4,SayAlpha(${AUTHCODE})
exten => rs-APPROVED,5,Playback(CC/thankyou)
exten => rs-APPROVED,6,Hangup()

exten => rs-DECLINED,1,Playback(CC/declined)
exten => rs-DECLINED,2,Goto(s,4)

[macro-askdigits]
exten => s,1,Read(thevalue,CC/${ARG1},${ARG2},skip,4,25)
exten => s,2,AGI(${ARG3}|${thevalue})
exten => s,3,GotoIf($["${verify}" = "0"]?i,1)
exten => i,1,Playback(CC/invalid)
exten => i,2,GotoIf($["${reason}" = ""]?4)
exten => i,3,Playback(CC/${reason})
exten => i,4,Goto(s,1)



Here is the Dialplan I used to create the audio files I needed. In this you will hit # after you make the recording. As well you will need to create a folder for the audio files. I used CC (/var/lib/asterisk/sounds/CC) and included
them in the file listed in this post.

[ccrecord]
exten => s,1,Answer
exten => s,n,Wait(2)
;record the credit card introduction
exten => s,n,Record(CC/ccintro:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/ccintro)
exten => s,n,Wait(2)
;record the "running credit card now" message
exten => s,n,Record(CC/runccnow:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/runccnow)
exten => s,n,Wait(2)
;record the "enter zipcode" message
exten => s,n,Record(CC/enterzip:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enterzip)
exten => s,n,Wait(2)
;record the "enter address digits now" message
exten => s,n,Record(CC/enteraddr:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enteraddr)
exten => s,n,Wait(2)
;record the "account not found" message
exten => s,n,Record(CC/acctnotfound:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/acctnotfound)
exten => s,n,Wait(2)
;record the "try again" message
exten => s,n,Record(CC/tryagain:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/tryagain)
exten => s,n,Wait(2)
;record the "thank you" message
exten => s,n,Record(CC/thankyou:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/thankyou)
exten => s,n,Wait(2)
;record the "approved" message
exten => s,n,Record(CC/approved:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/approved)
exten => s,n,Wait(2)
;record the "your authcode is" message
exten => s,n,Record(CC/yourauthcodeis:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/yourauthcodeis)
exten => s,n,Wait(2)
;record the "declined" message
exten => s,n,Record(CC/declined:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/declined)
exten => s,n,Wait(2)
;record the "enter expiration date" message
exten => s,n,Record(CC/enterexpir:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enterexpir)
exten => s,n,Wait(2)
;record the "enter credit card number" message
exten => s,n,Record(CC/entercc:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/entercc)
exten => s,n,Wait(2)
;record the "enter cvv2" message
exten => s,n,Record(CC/entercvv2:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/entercvv2)
exten => s,n,Wait(2)
;record the "enter dollar amount" message
exten => s,n,Record(CC/enteramt:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enteramt)
exten => s,n,Wait(2)
;record the "enter account number" message
exten => s,n,Record(CC/enteracctnum:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/enteracctnum)
exten => s,n,Wait(2)
;record "again" message
exten => s,n,Record(CC/again:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/again)
exten => s,n,Wait(2)
;record "invalid" message
exten => s,n,Record(CC/invalid:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/invalid)
exten => s,n,Wait(2)
;record "unsupported card type" message
exten => s,n,Record(CC/unsuppcardtype:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/unsuppcardtype)
exten => s,n,Wait(2)
;record "invalid card number" message
exten => s,n,Record(CC/invcardnum:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/invcardnum)
exten => s,n,Wait(2)
;record "invalid card length" message
exten => s,n,Record(CC/invcardlen:ulaw)
exten => s,n,Wait(2)
exten => s,n,Playback(CC/invcardlen)
exten => s,5,Wait(2)
;record "followed by the pound sign" message
exten => s,6,Record(CC/followpound:ulaw)
exten => s,7,Wait(2)
exten => s,8,Playback(CC/followpound)
exten => s,n,Hangup()


Please email me with any questions or ideas.
schapman1974@gmail.com

15950 Views
Created by: schapman, Last modification: Thu 19 of Mar, 2015 (02:34 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+