Skip to main content
All CollectionsIntegrationsZapier
Zapier tutorial: Automated PDF invoices with tax support
Zapier tutorial: Automated PDF invoices with tax support

Learn how to automatically create and send .pdf invoices with an included tax line item

Vesa Vahermaa avatar
Written by Vesa Vahermaa
Updated this week

Welcome to a practical Zapier tutorial! In this guide, you'll learn how to generate and send detailed PDF invoices to your users that can also include tax information.

Since the no-code version of Sharetribe does not have in-built tax support, tax is always considered to be included in any final purchase price.

IMPORTANT: This PDF invoice system is not designed to replace, but rather to complement, the marketplace’s own sent receipts in the transaction confirmation emails. Depending on your needs, you may also need to adapt this tutorial to your own needs, for example when it comes to calculating buyer or seller commission, or any potential shipping fees.

If you haven’t gone through the introduction and the action/event article of our Zapier collection, we encourage you to do so to better understand how things work. If you want to dive straight into action either way, feel free to read on!

What is Zapier?

Zapier is a powerful and versatile tool that allows you to integrate different services to one another. You can learn more about Zapier in our introductory article or through this brief video from Zapier.

What do you need for this tutorial?

External accounts

You will need a Zapier account, which you can sign up for at www.zapier.com. When registering, the process may ask you which Zapier apps you want to use. You can already find and select ‘Sharetribe’ from the list of applications, but you can also add it later.

Note that the free plan with Zapier has a limitation: it's only possible to create single step Zaps with it. So while you can follow through this tutorial, actually using this Zap requires you to have at least a Starter plan for Zapier, which supports multi-step zaps.

You will also need a Google account, or another Zapier-supported email service. This will be used to send the links to the .pdf invoices.

Finally, you will need an account on Cloudlayer.io. Cloudlayer is the service that we will be using to generate the invoices.

How to set up your marketplace

In order for Zapier to be able to draw relevant information from your marketplace, you will need to have some activity there. Since we will be setting up a Zap that sends an email to the participants of a transaction, you should have at least one transaction in your marketplace. You can run this transaction in your Test environment.

IMPORTANT: For this tutorial to work, after creating the listing and having someone buy it, the transaction needs to be in a state where someone has purchased/booked a listing with the correct listing type (i.e., the one for calendar bookings), and the provider has accepted that purchase request. Nothing should have happened in that transaction after that, for example, writing reviews or marking a product as sent.

Getting your Integration API key from Sharetribe Console

  1. Click on “+ Add a new application”

  2. Give the application a descriptive name (like Zapier), and select ‘Integration API’.

  3. Click ‘Add application’.

Important: Copy and paste the Client ID and Client secret to a safe place, like a password manager.

Think of the Client ID and secret as a sort of a password to your marketplace that can be used through other services. Note that you won’t be able to ever see the Client secret to this application again in the Console under any circumstances. Make sure you copy it to a secure place. If you lose it, you will need to create a new application.

Creating a Cloudlayer.io account and setting up an invoice template

You can easily create a Cloudlayer.io account at www.cloudlayer.io. The free account allows you to generate up to 100 invoices, after which you would need to sign up for a paid plan if you want to continue using the service. At the time of writing, their pricing starts at $9 USD per month, for a Starter plan that allows generating up to 1,000 documents per month.

Setting up a template

  1. After creating an account, go to https://app.cloudlayer.io/ to access the Dashboard.

  2. On the left side panel, select ‘Templates’

  3. Click on ‘Add Template’, and select ‘PDF Template’

  4. Select ‘Choose from pdf template gallery

  5. Use the left side filter to filter for the template type ‘Invoice’

  6. Choose any of the templates that suits you best by clicking on it. In this tutorial, the template we use is ‘Highlighted Invoice’.

    1. You can use any other template if you wish, but this means you will need to slightly adapt the following steps to work with your chosen template.

  7. On the page that opens, click ‘Use Template’

  8. Set a name for your invoice template.

  9. Make a note of the ‘Template Id’: you will need this when setting up the Zap!

  10. You do not need to fill out other fields of the template - just click ‘Save & Open Editor.

Editing a template

Now, you can edit the template freely. For instance, you can remove and add fields based on what you want to be displayed on the invoice.

One thing you may want to remove from the template is the buyer and seller addresses. These are not collected by default on Sharetribe marketplaces. You can do this with the steps below:

  1. Scroll down until you can see lines 25 to 29, and remove them. The lines you remove should say:

    <p class="text-slate-500">{{ address1 }}</p>
    <p class="text-slate-500">
    {{ city }},&nbsp;{{ state_province_region }} {{ zip_postal_code }}
    </p>
    <p class="text-slate-500">{{ country }}</p>

  2. After removing these lines, scroll down further, until you can see the lines 62 to 67, and remove them. The lines you remove should say:

    <div class="">{{ bill_to_address1 }}</div>
    <div class="">
    {{ bill_to_city }}, {{ bill_to_state_province_region }}{{bill_to_zip_postal_code }}
    </div>
    <div class="">{{ bill_to_country }}</div>
  3. You do not need to remove or edit other parts of the template. Things like ‘Due date’, phone number, email address, and so on are automatically hidden from the template if they are not set up in Zapier, so you don’t need to worry about those. Of course, if you want to, you can make other changes to the template at your discretion!

  4. After you’re ready, click ‘Save’ in the top right corner, and then ‘Exit’. The template will be saved to your Cloudlayer account, and now you can reference it in Zapier with the Template Id we mentioned in the last section.

Creating the invoice Zap, step by step

(Optional) Importing a pre-existing Zap

  1. Go to www.zapier.com and log in with your account (or create a free one, if you don't already have one)

  2. Open the pre-made Zap for sending calendar booking link emails on Sharetribe here

  3. Click on ‘Try this Zap'

  4. Now, a lot of the work has already been done for you. You can use the steps below to verify that each step will be configured correctly.

Step 1: Find a recent transaction from your marketplace

Connect your Sharetribe account by entering your Client ID and Client secret

  1. Click ‘Continue’ to move to the ‘Trigger’ section

  2. Choose ‘Transaction transitioned’ as the ‘Event type’

  3. Click ‘Continue’ to move to the ‘Test’ section

  4. Test the trigger, and make sure it finds a recent transaction event associated with a digital download listing

  5. Click ‘Continue with the selected record’ to move to the next step

Step 2: Filter the event

We want to only run the zap in a situation where a listing has been bought.

  1. Choose ‘Filter’ as the app from the ‘Built-in tools’ list by Zapier. You can select it from the on-screen list if you see it, or search for it – in search results, it appears as ‘Filter by Zapier’.

  2. Under the ‘Only continue if…’, select the following 3 entries for the lines:

    1. ‘1. Transaction Last Transition’

    2. (Text) Contains

    3. confirm-payment

  3. Test the filter, and make sure it says “Your Zap would have continued for this test data”

    1. Troubleshooting: If this step fails, make sure you selected the right variables, and entered the right texts in the fields. Also, make sure that the last thing that happened in your test transaction was the accepting of the booking request by the provider!

  4. Click ‘Continue’ to move to the next step

Step 3: Get transaction details

  1. Choose ‘Sharetribe’ as the app for this step

  2. Choose “Show Transaction” as the event

  3. In the ‘Account’ section, choose your marketplace account (the one you configured in the last step)

  4. In the ‘Action’ section, select “1. Transaction id: xxxx” from the drop down list. It should be the top option. Do not write it in: you need to select it from the drop down menu.

  5. Under ‘Included relationships’, choose ‘Marketplace’, ‘Listing’, ‘Provider’, ‘Customer’, and either ‘Booking’ or ‘Stock reservation’, depending on whether you have a booking-based or a product-based marketplace. If you use both kinds of listing types, select both.

  6. In ‘Should this step be considered a “success” when nothing is found?’, select ‘No’

Step 4: Format invoice date for the email

The time we get from the marketplace is in a very technical format. We want to include it in the outgoing email in human readable format, and only the date part of it, as the time of the payment is not as important. We need two steps for this: one for the start time, another for the end time.

  1. Choose ‘Formatter by Zapier’ as the app

  2. Choose ‘Date / Time’ as the event

  3. Under ‘Action’, click on the ‘Transform’ dropdown, and choose ‘Format’

  4. In the ‘Input’ field, select from the drop down ‘1. Event Created At: xxx’

  5. In the ‘To Format’, choose YYYY-MM-DD (2006-01-22)

    1. Note that you can also choose a different format if you prefer. This value is what is shown on the pdf invoice, as the invoice date.

  6. In the ‘To Timezone’, select the primary time zone that your marketplace uses. Even though the actual time of the transaction is not shown in the invoice, this will help the invoices have the right date if the transaction happens too close to midnight.

  7. In the ‘From Format’, select ‘YYYY-MM-DDTHH:mm:ssZ (2006-01-22T23:04:05-0000)

  8. In the ‘From Timezone’, select UTC.

  9. Continue and test the action, and make sure it outputs the invoice date in the format you want.

Step 5: Calculate the tax free price of the transaction

Now, we will calculate how much the listing would cost without tax.

  1. Again, choose ‘Formatter by Zapier’ as the app

  2. Choose ‘Numbers’ as the event

  3. In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.

  4. In ‘Operation’, select ‘Divide’

  5. In ‘Values’, select ‘3. Transaction Listing Price Amount: ’ in the top box, and 1XX in the bottom box, where XX is the tax rate involved in these transactions. For example, if the tax rate was 25%, you would write 125.

  6. Continue and test the action, and make sure it outputs the tax value of the transaction. For example, if the listing price was $100 and the tax rate was 25%, the output should be 80.

The tax calculation might seem counter-intuitive. To clarify, the transaction price in the no-code version of Sharetribe always includes tax by default, which means that you have to manually calculate the "tax-free" price. In the example above, we have an item that costs $80 without tax. However, we want to add 25% tax on top of the price. 25%, or one fourth, or one quarter, of $80 is $20. Thus, if you add up the tax-free price of $80 with the 25% tax of $80, you get the total price that includes tax, which is $100.

Step 6: Convert the transaction price to full currency units

As mentioned in the last step, all the transaction prices are denoted in the smallest currency unit (such as with USD, in Cents). Thus, we'll need to divide the transaction price by 100 in order to get the amount in full currency units (such as in USD).

  1. Again, choose ‘Formatter by Zapier’ as the app

  2. Choose ‘Numbers’ as the event

  3. In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.

  4. In ‘Operation’, select ‘Divide’

  5. In ‘Values’, select ‘3. Transaction Listing Price Amount: ’ in the top box, and 100 in the bottom box.

  6. Continue and test the action, and make sure it outputs the tax value of the transaction. For example, if the listing price was $100, the output should also be 100.

Step 7: Calculate the tax portion of the price

Now that we know both the transaction price, as well as its tax free value, we can calculate how much of the price was tax. This is simple: we just deduct the tax free price from the total transaction price.

  1. Again, choose ‘Formatter by Zapier’ as the app

  2. Choose ‘Numbers’ as the event

  3. In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.

  4. In ‘Operation’, select ‘Subtract’

  5. In ‘Values’, select ‘7. Output: XXX ’ in the top box, and '6. Output: XX' in the bottom box.

  6. Continue and test the action, and make sure it outputs the tax value of the transaction. For example, if the listing price was $100 and the tax rate was 25%, the output should be 80. (See Step 5 for the explanation if needed)

Step 8: Round the tax calculation result

In some cases, the result of the tax calculation in the previous step might result in an uneven number, with more than 2 digits after the decimal point. In this step, we’re accounting for those cases, by making sure that the output number from the tax calculation is in a currency format.

  1. Again, choose ‘Formatter by Zapier’ as the app

  2. In ‘Event’, select ‘Numbers’ once again

  3. In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Format Currency’.

  4. In the ‘Input’ field, choose ‘5. Output: XX’. You should see the actual tax value of the transaction here.

  5. In ‘Currency’, select the currency of the marketplace, such as ‘US Dollar’.

  6. In ‘Currency Locale’, choose the locale you want to use for the currency, such as English (United States).

  7. In ‘Currency Format’, choose ‘#,##0.00’.

  8. Continue and test the action, and make sure it outputs the tax value in proper currency units.

Step 9: Calculate listing price

This step is similar to the previous steps, except we’re calculating/rounding the price of the listing in full currency units, such as USD.

  1. Again, choose ‘Formatter by Zapier’ as the app

  2. Choose ‘Numbers’ as the event

  3. In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.

  4. In ‘Operation’, select ‘Divide’

  5. In ‘Values’, select ‘3. Transaction Listing Price Amount: ’ in the top box, and 100 in the bottom box.

  6. Continue and test the action, and make sure it outputs the price in full currency units, such as ‘500’ if the listing price was $500.

Step 10: Calculate total transaction price

This step is not needed, if your marketplace always only deals with one-item transactions. However, if multiple quantities of an item are bought from a product marketplace with inventory, this step can be relevant.

  1. Again, choose ‘Formatter by Zapier’ as the app

  2. Choose ‘Numbers’ as the event

  3. In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.

  4. In ‘Operation’, select ‘Multiply’

  5. In ‘Values’, select ‘3. Transaction Stock Reservation Quantity: XX’ in the top box, and ‘7. Output: XX’ in the bottom box.

    1. Note that if you are running a booking marketplace, 'Stock Reservation Quantity' is not available. However, in this case you should be able to find a value called 'Transaction Line Items Quantity' that includes this information.

  6. Continue and test the action, and make sure it outputs the total transaction price in full currency units, such as ‘1500’ if the unit price was $500 and the transaction included 3 units. Of course, if the test transaction you’re using only includes 1 item, then the output will be the same as in the previous step 7.

Step 11: Create Invoice PDF

This step is the one where we’re finally creating the full invoice. There are many fields to fill here, so this step will require a bit more work than the others.

IMPORTANT: This is a basic invoice template. The only parts of the transaction that are included are the price of the listing, as well as the calculated tax, based on the listing price. This basic template does not calculate or display the buyer or seller commission or any potential shipping fees. If you want to include those in the invoice, you will need to add in additional steps before this invoice creation to calculate them, and edit the invoice template in Cloudlayer to properly display them.

The easiest way to display commission or shipping fees in the invoice is to add additional steps to the zap, retrieve them from the transaction information (Step 3), and calculate/round them similarly as in Step 5 and Step 6. You can then display these fees in the notes section of the invoice.

It can be possible to display the commission and shipping fees as line items with the other numbers but this would require more adaptation of this Zap as well as further customization of the Cloudlayer template.

If you calculate commissions, you may also want to create two invoices: one for the provider, and one for the customer. This of course means that you would also send them separately to the buyer and the seller at the end.

  1. In ‘App’, choose ‘cloudlayer.io’.

  2. In ‘Event’, choose ‘Create Invoice PDF’.

  3. In ‘Account’, log in to your Cloudlayer.io account by entering the API keys that you got from the Cloudlayer dashboard. Move to the ‘Action’ section afterwards.

  4. In the ‘Template Id’, write in the id of your template. You can get this from the Cloudlayer dashboard. For example, it could be ‘u-highlighted-invoice-1’, if you used the Highlighted Invoice template.

  5. In ‘Enable Auto Calculation’, select ‘False’. The in-built auto calculation would *add* tax on top of the already paid transaction price, but here, we assume that the sum that the customer paid already includes the tax.

  6. In ‘Biller Company Name’, select the kind of name you want the invoice to have for the provider. For example, you can choose ‘3. Transaction Provider Profile Display Name: XX’ if you want to use the display name of the user.

  7. In ‘Logo URL’, enter the logo URL of your marketplace. The way you can get this is by going to your marketplace’s regular view (the one that customers use), right-clicking on the logo in the top corner, and selecting ‘Copy image address’. After this, you can paste the URL here. The URL should start with the text https://sharetribe-assets.imgix.net/ and a long string of letters and numbers after that.

  8. Now, the following 5 fields are not strictly necessary. They are the address, city, state, ZIP, and country of the provider (‘Biller’). Normally, it’s not possible to get this information from the providers’ profiles, since this information is not asked during sign up. You can customize your marketplace’s sign up process to collect this information from all users during sign up, and then choose the relevant fields here, if you want. Otherwise, you can just write ‘N/A’ in all the fields, or any other text of your choosing - you will have to write in something, as these fields are mandatory. You can use the Cloudlayer editor to hide these fields from the actual PDF invoices (and you may have already done that at the beginning of this tutorial).

  9. Leave the ‘Biller Phone Number’ field blank, unless you have collected (and want to display) the phone number of the provider in the invoice.

  10. Similarly for the ‘Biller Email’, leave it empty unless you want to display it in the invoice. Note that by default, the users’ emails are not exposed to other users on the marketplace: the marketplace transaction/messaging system does not show the email addresses of the participants unless they explicitly choose to share them.

  11. In the ‘Bill To Name / Company’, choose the customer name, in the way you want it to appear. For example, you can choose ‘3. Transaction Customer Profile Display Name: XX’ if you want to use the display name. You can also choose the first name and/or last name of the customer, if you want.

  12. Again, the following 5 fields are not strictly necessary. They are the address, city, state, ZIP, and country of the customer. Just like with the provider, this information is not available by default from the marketplace system: instead, you can write in generic values such as ‘Adress’ ‘Zip’ etc., or just N/A. Again, you can hide these fields from the actual PDF invoice with the Cloudlayer editor.

  13. In the ‘Product/Service Title’, choose what the title of the invoice will be. For example, you can just choose ‘3. Transaction Listing Title’, in which case the title of the invoice will just be the title of the marketplace listing. You can add text here too: for example, you could write in ‘Invoice for [3. Transaction Listing Title] on [3. Transaction Marketplace Name]’.

  14. Leave ‘Due Date’ empty (the invoice has already been paid)

  15. In ‘Invoice Date’, choose ‘4. Output: XX’ – in an earlier step, we formatted the transaction date for this purpose.

  16. Leave ‘Invoice Number’ and ‘Reference Number’ empty, unless you want to write something here. If you wanted to have a unique identifier for the invoices, you could technically choose ‘1. Transaction ID’, but it is not necessary.

  17. In ‘Currency Code’, select the currency code your marketplace uses, for example USD.

  18. In ‘Default Locale’, select your marketplace locale, such as ‘en-US’.

  19. In ‘Tax Label’, choose the kind of tax label you want to use. You can just write in ‘Tax’, or for example ‘VAT’ (Value Added Tax).

  20. In ‘Tax Percentage’, write the tax percentage you used in step 5 for calculating the tax. For example, ‘10’.

  21. In ‘Subtotal’, choose ‘9. Output: XX’. This is the total price of the listing.

  22. In ‘Total Tax’, choose ‘8. Output: XX’. This is the tax value of the listing.

  23. In ‘Amount’, choose ‘9. Output: XX’. This is the total value of the transaction, tax included. This is the same as the ‘Subtotal’, since the listing price already included tax.

  24. In ‘Notes’, you can write any notes you want, or leave the field empty. For example, you could write something like ‘This is an automatically generated invoice. You can use the marketplace messaging system to contact the other party involved in the transaction, and you can reach the marketplace administrators at contact@example.com’ or any message you want your users to know.

  25. In ‘Terms’, you can similarly write any terms you want the invoice to include, or leave it empty.

  26. Now we move to the ‘Items’ box, where we fill in the listing details. In ‘Title’, choose ‘3. Transaction Listing Title: XX’

  27. In ‘Description’, you can either choose something like ‘3. Transaction Listing Description: XX’, or leave it empty.

  28. In ‘Quantity’, you can choose ‘3. Transaction Stock Reservation Quantity’, if your marketplace has listings with an inventory. If your marketplace always sells products or services one at a time, you can just write in ‘1’.

  29. In ‘Price’, choose ‘9. Output: XX’

  30. In ‘Amount’, choose 9. Output: XX’. This is the same as ‘Price’, unless your marketplace has transactions where multiple items are sold at the same time. Note, however, that if your marketplace does have multi-item transactions like this, you will need to include an additional step that rounds/calculates the actual full price of the transaction.

  31. Test the step and make sure it works properly. Note that you will be able to also see your generated invoice in the Cloudlayer dashboard, at: https://app.cloudlayer.io/

Step 12: Wait until the invoice is generated

It takes a short while (usually just a few seconds) for Cloudlayer to generate the PDF invoice. We'll need to add a step to this zap so that it knows to wait until the PDF is generated, and the link for it is available.

IMPORTANT: You can't actually test this kind of zap properly in this editor due to its nature. When you test the zap, you will most likely get the message 'Your Zap would not have continued for this test data'. The reason will most likely be that the Cloudlayer Status is marked as 'pending' instead of 'success'. However, when the zap is actually published and running, it will keep waiting until the status changes to 'success' before moving to the next step.

  1. In the ‘App’, choose ‘Filter by Zapier’

  2. When setting up the filter, under 'Only continue if', choose '9. Status' from the drop down menu

  3. Select (Text) Contains

  4. Write in 'success'

  5. As explained earlier, you can't really test this step within the editor itself, so you can move to Step 11.

Step 13: Send PDF invoice email

In this step, we’ll send the email to the participants of the transaction.

As pointed out earlier, this Zap / invoice template does not display the customer or provider commission. If you want to include those, you may want to generate two invoices: one for the customer, and one for the provider.

  1. In the ‘App’, choose ‘Gmail’ (or your preferred Zapier-compatible email provider)

  2. In the ‘Event’, choose ‘Send email’

  3. In the ‘Account’ step, choose the email account that you want the automated emails to come from. Note that this will be visible to both participants of the transaction as the sender email, so it should be clear that the email account is associated with your marketplace.

  4. Under ‘Action’, select two recipients in the ‘To’ field: ‘3. Transaction Customer Email’, and ‘3. Transaction Provider Email’. Make sure that these are on separate lines, so the email is sent separately to both participants.

  5. In the email ‘Subject’, you can add a mixture of text and variables. For example:

    1. PDF invoice for ‘3. Transaction Listing Title: xxx’ on ‘3. Transaction Marketplace Name:xxx’

  6. In the ‘Body’ section, you can again type a mixture of text and variables. Again, the variables that you need to choose from the drop down menu instead of writing/copying them are listed in bold letters. For example:

Hello there,

It is the ’3. Transaction Marketplace Name’ team. You can find a PDF invoice for your recent transaction of ’3. Transaction Listing Title:’ from this address:

‘9. Asset URL: No data’

Thank you for doing business on our marketplace! Let us know at example@example.com if you have any questions.

Regards,

The ‘3. Transaction Marketplace Name’ team

7. If you want, you can test the step within the editor, though the variable '9. Asset URL' will not work properly due to the limitations in the testing system. However, you can still make sure that the provider and the customer that were involved in your test transaction get the emails as expected, even if the link is not included in the test.

Proper testing

Since the Cloudlayer step can't be tested properly within the zap editor, you should test it in a 'regular' way. What this means is that you can publish the Zap from the top bar, and then make a regular transaction on your marketplace. If everything works well, the Zap will listen in to the transaction system, pick it up, and then generate a proper invoice and send it via email to the participants of the transaction within a few minutes.

It is a good idea to go through the invoice thoroughly, and perhaps do a few different kinds of test transactions (with different quantities and listing types, if applicable). Then, based on how those invoices look to you, you can make changes to either the Zap, or the invoice template using the Cloudlayer editor.

Final thoughts

Thanks for reading this tutorial about creating a Zap for automatically sending PDF invoices to your marketplace users! Feel free to read through other parts of our Zapier guide as well: the introduction and the article about Events and Actions. Also, check out our other Zap templates from this article.

Please get in touch with us through your Console or from the bottom right section of this page from the chat widget if you have any questions about this guide, or anything else. We'll be happy to help!

Did this answer your question?