Generating Captive Portal Vouchers

  • Hi,

    Similar to questions asked here:,34176.0.html and here:,42928.0.html I have a question about Voucher Generation - Specifically, how are vouchers generated & stored for later retrieval via csv?

    I would like to automate the provisioning of vouchers at a hotel installation, such that the front-desk employees simply click a button, and have a voucher printed.  While I can build a system to import from CSV, track printed vouchers, and print the next available on demand, it would be far simpler to be able to generate valid keys on the voucher-printer side, than on the firewall, tracking only the roll & roll position.

    It seems like vouchers are deterministic, in that, given the same input values (including RSA keypair,) the output voucher tokens should be identical with each generator run.

    I have git cloned the pfsense master branch, and grep'd for 'voucher' but there appears to be an underlying binary on which the pfsense pages rely.

    Line 151 of services_captiveportal_vouchers.php reads:

    system("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -p {$g['varetc_path']}/voucher_{$cpzone}.private $number $count");

    should this be the result of compiling voucher.c from m0n0wall > v1.3?  are all of the pfSense voucher operations based around manipulating the output of this binary?

  • I have developed a REST API to create, delete and retrieve vouchers. All the info is at this link

  • @jpardobl:

    I have developed a REST API to create, delete and retrieve vouchers.

    Good work, however it solves a different problem (that of not having to give webGUI access) than what the original poster asked for.

    The original post asked for something similar to the commercial offerings which come with a thermal printer and print out one voucher at a time e.g. Zyxel N-4100.

  • @jpardobl:

    I have developed a REST API to create, delete and retrieve vouchers. All the info is at this link

    Javier, it occurred to me that your idea of a pfsense REST API could be applied in other ways, e.g. to remove stale states (probably the most commonly raised VoIP issue in the NAT subforum) e.g. Elastix has a "Monitor Trunk Failures" feature that allows you to invoke an custom AGI script.

  • any of you guys knows an on-demand printer for the vouchers? example, a front desk staff would just press the button in the printer and it will generates the voucher.

    kind regards

  • Hi Guys,

    Is there any best practice on how to retrieve the vouchers?
    Considering that the operator/receptionist may not be technical people.
    How do you guys usually collect the vouchers code and then distribute it?

    Thanks! :)

  • in our experience, after generating the code, we download it as csv file, open and save-as excell, we created a template, ticket-like, have used the 3 column feature in the MS word, populate it with tables and copy pasted the codes. So we had codes in each box, have it printed. Well I got 33 vouchers in an A4, had it cut manually and bundled it like "money" and ready for disposal. No more printed standing-by.

    I know it's kind of old school preparation but it worked for us.

  • Hi Guys,

    How to generate random list of vouchers code?

    The objective is actually to generate random vouchers periodically.
    But it seems that every time I click the blue button (attached screenshot) the list of the voucher is always the same.
    Is this the expected behavior?

    If it is expected behavior, so we just have to keep reusing the same list of vouchers?

    Please help :)


  • in pfsense, once a voucher is expired, you can no longer re-use it. From your attachment you only created 100 tickets. Well we can create upto 1023 of tickets so you no longer worry to have a random. The blue one is a download button. It only downloads a copy of the generated vouchers. So if you already maxed out your tickers, all you need to do is to generate another roll. Instead of the blue button, click the |+| button instead and generate upto 1023 numbers of tickets.

  • Thanks Bro onlineph for the clear explanation. :)
    So I think we have to manually add new Roll, everytime the tickets runs out.

Log in to reply