Automatically Send PDF Receipts for Chargify Transactions

In this example, we’re going to show you how you can instantly generate (and send) PDF receipts to customers when their card is charged using Chargify. We’ll use Chargify’s webhook feature to send the payment information over to WebMerge for the receipt.

To get started, we’re going to setup our receipt template in WebMerge. From the Documents page in WebMerge, click the New Document button and enter a name for the document (ie Receipt). On the next step, pick the Build Your Own document type and continue.

On the next step, you’re going to be taken to the Document Builder. Here is where we are going to build our document – adding our logo, address, etc. Also, we’ll need to add merge fields for the locations where we want our customer & payment information to go.

Merge fields look like {$FirstName}, {$Address}, {$Amount}, etc. and are simply text that you type right into the document. You can name the merge fields anything you’d like – we’ll map them to the Chargify fields later.

Here’s what our receipt template looks like:

Once we have our template finished, let’s save and then move on to the next step. You’ll be taken to the Settings tab where you can update different options like the type of file that is generated, the name of the file, and more.

For this example, we’re going to generate a PDF and include the transaction ID in the name of the file. Also, we’re going to turn on Debug Mode (turn on Test Mode, then check the box to save the data) and turn on our Field Map under Advanced Settings. We’ll use these a little later when we map the fields from Chargify to our document.

Next, we’re going to setup the email delivery so that our PDF receipt is automatically emailed to our customers. If you jump over to the Deliver tab, you’ll see an email delivery already there. We’re just going to update the settings of that email.

For the To, we’re going to select our customer’s email address (the merge field) so that the email is sent directly to our customer who paid. Feel free to update any of the other settings for the email delivery.

Great work, we’re moving along nicely! Next, we need to setup the Webhook in Chargify so that when a new charge is run through the system, that information is automatically sent over to WebMerge to generate the receipt.

Click on the Merge tab and you’ll see your document’s Merge URL. This is a unique URL that can be used to send data directly to your document. Go ahead and copy that URL.

In order for our webhook to only fire when we receive a new payment, we need to configure the webhook to only send on “Payment Success” event. From the webhooks page, click Configure button and you should see a popup of options. Click the box next to Payment Success and save.

Now that we have our webhook setup, we need to send a payment through so that we can map the data coming from Chargify to the correct merge field in your document. Go ahead and run a new payment through Chargify.

Once you have submitted a payment, let’s go back into WebMerge and go to the Overview tab for your document. Since you have Debug Mode turned on, you should see a View Data button in the Recent Merge section. This is the data that is being sent over by Chargify. Expand the data so you can see all the fields.

For each of the merge fields in your receipt, we need to find the corresponding data field coming over from Chargify. Once you find a field you’re looking for, click on the name and you’ll see the merge code that you need to use to get that field in your document.

Next, open up the Field Map tab and you’ll see a list of all the merge fields in your document. For each of those merge fields, add the corresponding merge code you just grabbed from the debug data popup. This “maps” the data from Chargify to your document.

Once you have all of your fields setup in the Field Map, you’re all done! Go ahead and turn off Debug Mode and you’re ready to start sending receipts from Chargify! But first, run another test, just to make sure everything is working correctly.

Here’s what our receipt looked like:

Congrats, you’re all done! You can now instantly generate all types of documents from Chargify without lifting a finger. Can you think of any other ways that you could use WebMerge to simplify your paperwork process?