The problem at hand
If you have a business outside the EU, you can consider yourself extremely lucky. If, howeverm you are an unlucky EU business owner, you know how hard it is to sell services to other EU citizens. According to the EU VAT directives, the business owner must charge value added tax to all intra-EU transactions. However, if the buyer is a business with a VIES-registered VAT number they must not charge VAT directly. On the contrary, they must transfer the VAT liability to the recipient of the services invoice (the client). To make things even more complicated, from 2013 onwards the VAT rate charged to non-registered individuals and businesses will not be the VAT rate in the business owner's country, but the VAT rate in the recipient's country. The only exception to the rule is selling services to people in your own country, where you have to charge value added tax on the local VAT rate anyway.
Sounds utterly complicated? I only gave you the executive summary!
From a business owner's standpoint, if you are to sell subscriptions on your website, you need a way to find out if a given user lives in EU, if his VAT is VIES-registered and proceed accordingly. The only obstacle is integration.
Thankfully, AMBRA.subs is very extensible, using standard Joomla! plug-ins. One type of plug-ins you can use are the payment gateway plugins. Normally, they just display a button which you can click and go to the payment processor's site, pay and get back to the originating site to enjoy your subscription. My biggest problems with this technology were:
- I didn't want a button, I wanted a form where I could collect user's information.
- The process should be fail-safe, i.e. a non-VIES-registered EU user must be charged VAT.
- The user information should be saved in the database, so returning customers wouldn't have to retype everything.
- I had to be able to get an email with the user's data so that I could issue invoices (email invoices are pretty much out of the question in Greece).
- I didn't want to write a component for that matter.
The proposed solution
I think I used AMBRA.subs plug-in capabilities to an extreme. One of the great things Dioscouri allows you to do in plugins is handle AJAX calls! So, instead of displaying a button, my plugin displays a user registration form which - among everything else - asks for the country. If the country is in EU, VAT is applied, unless the user provides a VAT number. If he does, the VAT number is validated against VIES. If the VAT number is valid, the tax is deducted, otherwise it's added. If the user is in the same EU country as the business, VAT is applied anyway and no VAT number is asked for. Every field is validated client-side using Javascript. When the user "submits" the form, an AJAX call is made to your server. The information is validated server-side. If it's found to be OK, a PayPal "pay now" button's code is returned to the GUI and auto-submitted, so it's 100% transparent to the user.
Looking for a demo? Try the AkeebaBackup.com registration procedure.
Installation and configuration
You can download the VAT-enabled plugin for AMBRA.subs from the downloads section of this site.
Installing the plug-in is as simple as installing any Joomla! plug-in. Once installed, you have to do two configuration steps.
The first is made by going to Extensions, Plugin Manager menu item and filtering for the "ambrasubs" type. Click on the "AmbraSubscriptions - PayPal with VAT" plugin. First, make sure that it's enabled. Then, you have the following options:
- Use Paypal Sandbox. If enabled, the Sandbox server will be used (testing mode). The parameters to the sandbox server are defined in the code. More on that later.
- PayPal Email Address. This is the email address used as your PayPal account name or your merchant account ID (if you have one).
- Currency is the three letter code of the currency used for your site's prices, e.g. EUR for Euro, USD for USA Dollars and GBP for UK pounds.
- Use SSL to post back to Paypal defines if SSL should be used when contacting PayPal to validate the transaction confirmation data it sends you. It does not affect if SSL will be enabled when users perform their transaction (it's always enabled for user interaction)
- . If set, it will send a copy of successful payments' data to this email address.
- is the numeric ID of a com_content article which will be displayed to the users after a successful transaction.
The second part of configuration is somewhat low-level and can only be performed by editing two PHP files. The first one is plugins/ambrasubs/payment_paypal_vat.php and contains the variables for the PayPal sandbox, for use while you are testing the integration with your site. You will see the following block:
1 2 3 4 |
var $_sandbox = array( 'receiver_email' => ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it ', 'customer_email' => ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it ', ); |
Replace the two email addresses with those you have set up in PayPal's sandbox system.
The next file you must edit is plugins/ambrasubs/payment_paypal_vat/payment_paypal/helper.php. In there you'll find the VAT configuration array:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
static $vat_config = array( 'AT' => array('tax_rate' => 21, 'exempt_possible' => true), 'BE' => array('tax_rate' => 21, 'exempt_possible' => true), 'BG' => array('tax_rate' => 21, 'exempt_possible' => true), 'CY' => array('tax_rate' => 21, 'exempt_possible' => true), 'CZ' => array('tax_rate' => 21, 'exempt_possible' => true), 'DE' => array('tax_rate' => 21, 'exempt_possible' => true), 'DK' => array('tax_rate' => 21, 'exempt_possible' => true), 'EE' => array('tax_rate' => 21, 'exempt_possible' => true), 'ES' => array('tax_rate' => 21, 'exempt_possible' => true), 'FI' => array('tax_rate' => 21, 'exempt_possible' => true), 'FR' => array('tax_rate' => 21, 'exempt_possible' => true), 'GB' => array('tax_rate' => 21, 'exempt_possible' => true), 'GR' => array('tax_rate' => 21, 'exempt_possible' => false), 'HU' => array('tax_rate' => 21, 'exempt_possible' => true), 'IE' => array('tax_rate' => 21, 'exempt_possible' => true), 'IT' => array('tax_rate' => 21, 'exempt_possible' => true), 'LT' => array('tax_rate' => 21, 'exempt_possible' => true), 'LU' => array('tax_rate' => 21, 'exempt_possible' => true), 'LV' => array('tax_rate' => 21, 'exempt_possible' => true), 'MT' => array('tax_rate' => 21, 'exempt_possible' => true), 'NL' => array('tax_rate' => 21, 'exempt_possible' => true), 'PL' => array('tax_rate' => 21, 'exempt_possible' => true), 'PT' => array('tax_rate' => 21, 'exempt_possible' => true), 'RO' => array('tax_rate' => 21, 'exempt_possible' => true), 'SE' => array('tax_rate' => 21, 'exempt_possible' => true), 'SI' => array('tax_rate' => 21, 'exempt_possible' => true), 'SK' => array('tax_rate' => 21, 'exempt_possible' => true) ); |
Each line configures the VAT options for a specific country. The first key on the line is the two letter ISO-code of the country. Each key is assigned an array with two elements. The value next to the tax_rate label defines the vat percentage to be applied to this country.
Practical tip: Until 2013, all values here should be replaced with the VAT rate applicable in your country.
The next value, next to exempt_possible defines if it is possible for a resident of this country to be exempt from paying VAT ifhis VAT number is VIES-registered.
Practical tip: set to true for all countries, except your own.That's all folks! Enjoy creating subscription-based sites in the EU with great ease, thanks to the wonderful work of Dioscouri's crew on AMBRA.subscriptions. 


