belherdigital / open-eshop

PHP Script to sell your digital goods. Deliver bought files to your customers, give support for the purchases, create licenses and more!
open-eshop.com
GNU General Public License v3.0
52 stars 36 forks source link

EU VAT Compliance #362

Closed neo22s closed 9 years ago

neo22s commented 9 years ago

Add a config to force the EU VAT compliance.

Purchase flow 1- Sees a product 2- Clicks buy now (if not registered see register user) 3- Order is created with data (if we dont have the country we get it from API) 4- Redirect to checkout page. (theres a button next to VAT number (got VAT?) and Spain -- Edit goes to edit profile) 5- Checkout page will load the price with correct VAT, recalculates every time loading data from user and storing at model order VAT %, Country, City, address and VAT_Number 6- Checkout page appears pay buttons.

Register user (modal) 1- Receives a product ID by get/post

Edit profile (Billing details):

My Purchases

Pay via bank transfer:

Country codes: https://gist.github.com/vxnick/380904

To validate the VAT number: https://github.com/herdani/vat-validation

To get a list of updated VAT by country: 'https://wceuvatcompliance.s3.amazonaws.com/rates.json', 'https://euvatrates.com/rates.json',

To detect the country:

// If CloudFlare has already done the hard work, return their result (which is probably more accurate)
        if (!empty($_SERVER["HTTP_CF_IPCOUNTRY"])) {
            $country_info = $_SERVER["HTTP_CF_IPCOUNTRY"]);
        } 
else:

function ip_details($ip) {
    $json = file_get_contents("http://ipinfo.io/{$ip}/json");
//http://freegeoip.net/json/IP
//http://ip-api.com/json/IP
//http://www.telize.com/geoip/IP

    $details = json_decode($json);
    return $details;
}

$details = ip_details("8.8.8.8");

echo $details->city;     // => Mountain View
echo $details->country;  // => US
echo $details->org;      // => AS15169 Google Inc.
echo $details->hostname; // => google-public-dns-a.google.com

OR

https://github.com/maxmind/GeoIP2-php
``