=== NoorFile – Digital File Delivery with Google Drive for WooCommerce ===
Contributors: noorwork
Donate link: https://buymeacoffee.com/noorwork
Tags: google drive, woocommerce, digital downloads, drive access, file delivery
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Deliver Google Drive files and folders to WooCommerce customers: share them from the order screen and revoke access again at any time.

== Description ==

**NoorFile** connects your WooCommerce store to Google Drive. Attach a Google Drive file or folder to a product, then share it with the buyer's Google address straight from the WooCommerce order screen — and take that access away again just as easily.

Because the files stay on Google Drive, large videos, course material and design bundles never touch your hosting bandwidth or upload limits, and customers open them in Drive with their own Google account instead of downloading an unprotected file.

= How delivery works =

NoorFile does not act on an order by itself. You decide when a customer gets their files:

1. Open the order in WooCommerce.
2. Choose **NoorFile: grant Google Drive access** from the Order actions box, or grant one item at a time from the NoorFile panel on the same screen.
3. Google shares the file or folder with the customer's billing email address, and NoorFile records the result.

Removing access works the same way, with **NoorFile: revoke Google Drive access**.

= Features =

* **Attach as many files or folders to a product as you need** — a whole course folder, a single file, or several of each, every one with the permission level you choose.
* **Paste a link, not an ID** — paste any Google Drive address and NoorFile reads the file or folder ID out of it.
* **Grant and revoke from the order screen** — for a whole order at once, or one resource at a time.
* **Google service account integration** — connect with a Google Cloud service account JSON key. Your customers never sign in to anything but Google Drive itself.
* **Encrypted credentials** — the service account JSON is encrypted with AES-256-GCM before it is written to the database and is never printed back into the screen once saved.
* **Customer delivery email** — a WooCommerce-styled email tells the buyer their Drive access is ready, with a link to open it.
* **Drive Access tab in My Account** — customers see everything they hold from a completed order, with a link to open each item in Drive.
* **Activity log** — every grant, revoke and failure is recorded, together with the message Google returned.

== Installation ==

= Minimum requirements =

* WordPress 6.5 or newer
* WooCommerce 8.2 or newer
* PHP 7.4 or newer
* A Google Cloud service account (JSON key)

= Automatic installation =

1. In your WordPress admin, go to **Plugins > Add New Plugin**.
2. Search for "NoorFile".
3. Click **Install Now**, then **Activate**.

= Manual installation =

1. Upload the `noorfile` folder to `/wp-content/plugins/`, or upload the zip via **Plugins > Add New Plugin > Upload Plugin**.
2. Activate the plugin through the **Plugins** screen.

= Setup =

1. Go to **NoorFile > Google accounts** in your WordPress admin menu.
2. Create a Google Cloud service account, enable the Google Drive API for its project, download the JSON key and paste it in.
3. Share the Drive files and folders you want to sell with that service account's email address, as an **Editor**.
4. Edit a WooCommerce product, open the **NoorFile** tab in Product data, and paste the Drive link for the file or folder it delivers.
5. When an order comes in, open it and choose **NoorFile: grant Google Drive access**.

== Frequently Asked Questions ==

= Does the access NoorFile grants expire? =

No. A customer keeps the Drive permission until you revoke it from the order screen.

= Does NoorFile share files automatically when an order completes? =

No. This plugin delivers on your instruction: you grant and revoke access from the WooCommerce order screen. That is deliberate — it keeps you in control of who receives a file and when.

= Why does Google refuse to share my file? =

The service account must be able to pass the item on. Open the file or folder in Google Drive, share it with the service account's email address, and give it the **Editor** role. A Viewer cannot share it with anyone else.

= Do I need a Google Workspace account? =

No. A free Google Cloud project and an ordinary Google account are enough. Files kept in a Workspace shared drive work as well.

= Is High-Performance Order Storage (HPOS) supported? =

Yes. NoorFile declares compatibility with HPOS and with the Cart & Checkout Blocks.

= Can customers see their files without contacting me? =

Yes. NoorFile adds a **Drive Access** tab to the customer's WooCommerce My Account page listing the files and folders they hold from a completed order, with a link to open each one.

= Does NoorFile store my Google credentials safely? =

Your service account JSON is encrypted before it is saved to the database, and it is never printed back into the admin screen once saved.

= What happens to my data if I uninstall NoorFile? =

By default your delivery history and settings are kept in case you reinstall. You can opt in to full removal on uninstall from **NoorFile > Settings**.

== Screenshots ==

1. Dashboard — recent grants, revokes and delivery activity.
2. Product configuration — attach a Google Drive file or folder to a WooCommerce product.
3. Order screen — grant or revoke a customer's Drive access.
4. Customer portal — the My Account tab where customers see their active Drive access.

== External services ==

NoorFile's purpose is granting Google Drive access, so it connects to Google's own APIs using the service account credentials you provide. Nothing else is contacted, and nothing is sent anywhere during checkout or on a front-end page load.

* **Google OAuth2** (`oauth2.googleapis.com`) — used to authenticate your Google service account. NoorFile sends a signed JWT built from the service account key you provide, and receives a short-lived access token which it caches. No customer data is sent. This happens as a prerequisite for any of the Drive requests below.

* **Google Drive API** (`www.googleapis.com`) — used to create and remove permissions on the Drive files and folders you configure. NoorFile contacts it in five situations, all of them the direct result of somebody acting:
    * you press **Test connection** on the NoorFile → Google accounts screen (nothing is sent but the access token);
    * you grant or revoke access on a WooCommerce order, from the Order actions box or the NoorFile panel;
    * a queued delivery job runs in the background, or you press **Run queue now**;
    * a customer presses **Restore access** in their My Account → Drive Access tab;
    * a customer corrects the Google address a failed delivery was sent to, in the same place.

    What is sent when a permission is created: the access token, the Drive file or folder ID you configured, and the customer's email address. When a permission is removed, the token, the file ID and Google's own permission ID — no email address. The contents of your files never pass through NoorFile, and nothing is sent during checkout or on a front-end page load.

    See Google's [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms).

== Third-party libraries ==

* [Chart.js](https://github.com/chartjs/Chart.js) 4.5.1, MIT licence — bundled unmodified at `assets/admin/vendor/chart.umd.min.js` and used for the dashboard activity chart. Source: https://github.com/chartjs/Chart.js/releases/tag/v4.5.1

== Changelog ==

= 1.0.0 =
* Initial release on WordPress.org.

== Upgrade Notice ==

= 1.0.0 =
Initial release on WordPress.org.
