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.
NOTE: 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!
About 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 you need for this tutorial
External accounts
Zapier Account
Create a Zapier account if you don’t already have one. You can sign up at www.zapier.com.
During registration, Zapier may ask which apps you plan to use. You can enter Sharetribe at this point or add it later.
Cloudlayer.io account
This is the service we use to generate the invoices
You can sign up at https://cloudlayer.io
Any Zapier-supported email service
In this tutorial, we use Gmail
This is used for sending the invoices
It's a good idea to use the same email as you use for the outgoing email from your marketplace
How to set up your marketplace
Marketplace activity
You should have a recent transaction on your marketplace
This will be used as the test invoice, from which the invoice is generated
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.
Setting up an invoice template on Cloudlayer
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
After creating an account, go to https://app.cloudlayer.io/ to access the Dashboard.
On the left side panel, select ‘Templates’
Click on ‘Add Template’, and select ‘PDF Template’
Select ‘Choose from pdf template gallery
Use the left side filter to filter for the template type ‘Invoice’
Choose any of the templates that suits you best by clicking on it. In this tutorial, the template we use is ‘Highlighted Invoice’.
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.
On the page that opens, click ‘Use Template’
Set a name for your invoice template.
Make a note of the ‘Template Id’: you will need this when setting up the Zap!
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:
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 }}, {{ state_province_region }} {{ zip_postal_code }}
</p>
<p class="text-slate-500">{{ country }}</p>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>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!
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.
Getting your Integration API key from Console
Navigate to Build > Advanced > Applications
Click on “+ Add a new application”
Give the application a descriptive name (like Zapier), and select ‘Integration API’.
Click ‘Add application’.
Important: Copy and paste the Client ID and Client secret to a safe place, like a password manager.
IMPORTANT: Think of the Client ID and Secret as a sort of a password to your marketplace that can be used to access your marketplace data 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 the Zap, step by step
(Optional) Importing a pre-existing Zap
Go to www.zapier.com and log in with your account (or create a free one, if you don't already have one)
Open the pre-made Zap for sending calendar booking link emails on Sharetribe here
Click on ‘Try this Zap'
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
Click ‘Continue’ to move to the ‘Trigger’ section
Choose ‘Transaction transitioned’ as the ‘Event type’
Click ‘Continue’ to move to the ‘Test’ section
Test the trigger, and make sure it finds a recent transaction event associated with a digital download listing
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.
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’.
Under the ‘Only continue if…’, select the following 3 entries for the lines:
‘1. Transaction Last Transition’
(Text) Contains
confirm-payment
Test the filter, and make sure it says “Your Zap would have continued for this test data”
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!
Click ‘Continue’ to move to the next step
Step 3: Get transaction details
Choose ‘Sharetribe’ as the app for this step
Choose “Show Transaction” as the event
In the ‘Account’ section, choose your marketplace account (the one you configured in the last step)
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.
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.
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.
Choose ‘Formatter by Zapier’ as the app
Choose ‘Date / Time’ as the event
Under ‘Action’, click on the ‘Transform’ dropdown, and choose ‘Format’
In the ‘Input’ field, select from the drop down ‘1. Event Created At: xxx’
In the ‘To Format’, choose YYYY-MM-DD (2006-01-22)
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.
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.
In the ‘From Format’, select ‘YYYY-MM-DDTHH:mm:ssZ (2006-01-22T23:04:05-0000)
In the ‘From Timezone’, select UTC.
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.
Again, choose ‘Formatter by Zapier’ as the app
Choose ‘Numbers’ as the event
In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.
In ‘Operation’, select ‘Divide’
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.
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).
Again, choose ‘Formatter by Zapier’ as the app
Choose ‘Numbers’ as the event
In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.
In ‘Operation’, select ‘Divide’
In ‘Values’, select ‘3. Transaction Listing Price Amount: ’ in the top box, and 100 in the bottom box.
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.
Again, choose ‘Formatter by Zapier’ as the app
Choose ‘Numbers’ as the event
In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.
In ‘Operation’, select ‘Subtract’
In ‘Values’, select ‘7. Output: XXX ’ in the top box, and '6. Output: XX' in the bottom box.
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.
Again, choose ‘Formatter by Zapier’ as the app
In ‘Event’, select ‘Numbers’ once again
In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Format Currency’.
In the ‘Input’ field, choose ‘5. Output: XX’. You should see the actual tax value of the transaction here.
In ‘Currency’, select the currency of the marketplace, such as ‘US Dollar’.
In ‘Currency Locale’, choose the locale you want to use for the currency, such as English (United States).
In ‘Currency Format’, choose ‘#,##0.00’.
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.
Again, choose ‘Formatter by Zapier’ as the app
Choose ‘Numbers’ as the event
In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.
In ‘Operation’, select ‘Divide’
In ‘Values’, select ‘3. Transaction Listing Price Amount: ’ in the top box, and 100 in the bottom box.
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.
Again, choose ‘Formatter by Zapier’ as the app
Choose ‘Numbers’ as the event
In ‘Action’, in the ‘Transform’ drop down menu, choose ‘Perform Math Operation’.
In ‘Operation’, select ‘Multiply’
In ‘Values’, select ‘3. Transaction Stock Reservation Quantity: XX’ in the top box, and ‘7. Output: XX’ in the bottom box.
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.
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.
In ‘App’, choose ‘cloudlayer.io’.
In ‘Event’, choose ‘Create Invoice PDF’.
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.
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.
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.
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.
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.
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).
Leave the ‘Biller Phone Number’ field blank, unless you have collected (and want to display) the phone number of the provider in the invoice.
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.
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.
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.
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]’.
Leave ‘Due Date’ empty (the invoice has already been paid)
In ‘Invoice Date’, choose ‘4. Output: XX’ – in an earlier step, we formatted the transaction date for this purpose.
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.
In ‘Currency Code’, select the currency code your marketplace uses, for example USD.
In ‘Default Locale’, select your marketplace locale, such as ‘en-US’.
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).
In ‘Tax Percentage’, write the tax percentage you used in step 5 for calculating the tax. For example, ‘10’.
In ‘Subtotal’, choose ‘9. Output: XX’. This is the total price of the listing.
In ‘Total Tax’, choose ‘8. Output: XX’. This is the tax value of the listing.
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.
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.
In ‘Terms’, you can similarly write any terms you want the invoice to include, or leave it empty.
Now we move to the ‘Items’ box, where we fill in the listing details. In ‘Title’, choose ‘3. Transaction Listing Title: XX’
In ‘Description’, you can either choose something like ‘3. Transaction Listing Description: XX’, or leave it empty.
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’.
In ‘Price’, choose ‘9. Output: XX’
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.
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.
In the ‘App’, choose ‘Filter by Zapier’
When setting up the filter, under 'Only continue if', choose '9. Status' from the drop down menu
Select (Text) Contains
Write in 'success'
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.
In the ‘App’, choose ‘Gmail’ (or your preferred Zapier-compatible email provider)
In the ‘Event’, choose ‘Send email’
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.
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.
In the email ‘Subject’, you can add a mixture of text and variables. For example:
PDF invoice for ‘3. Transaction Listing Title: xxx’ on ‘3. Transaction Marketplace Name:xxx’
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!