# WooCommerce integration
This document explains how to integrate BTCPay Server into your WooCommerce store. If you do not have a store yet, follow this step by step article (opens new window) to create one from scratch.
You can check out the following video, or head over to the WooCommerce plugin repository (opens new window).
To integrate BTCPay Server into an existing WooCommerce store, follow the steps below.
# 1. Install BTCPay Plugin
There are two ways to download BTCPay plugin:
# Install plugin from WordPress
- WordPress > Plugins > Add New.
- In Search, type "BTCPay for WooCommerce"
- Install and activate.
# Download and install plugin from GitHub
Download the latest BTCPay plugin (opens new window), upload it in .zip format into your WordPress and activate it.
# 2. Deploy BTCPay Server
To launch your BTCPay server, you can self-host it, or use a third party host.
# 2.1 Self-hosted BTCPay
For the self-hosted solutions, you'll have to wait for your node to sync fully before proceeding to step 3.
# 2.2 Third-party host
For those who want to test BTCPay out, or are okay with the limitations of a third-party hosting (dependency and privacy, as well as lack of some features) can use a one of many third-party hosts.
The video below shows you how to connect your store to such a host.
# 3. Pairing the store
BTCPay WooCommerce plugin is a bridge between your server (payment processor) and your e-commerce store. No matter if you're using a self-hosted or third-party solution from step 2, the pairing process is identical.
Go to your store dashboard. WooCommerce > Settings > Payments. Click BTCPay.
- In the field, enter the full URL of your host (including the https) – https://btcpay.mydomain.com
- Click on the generated link which will redirect you back to your BTCPay Server.
- Click on request pairing
- Approve the pairing
- Copy the pairing code
- Go back to your store and paste the pairing code
- Click “Pair”
- When you see the image, it means you successfully paired your server and your store.
The process of pairing a store with BTCPay is explained in a video below, starting at 1:59
# 4. Connecting your wallet
No matter if you're using self-hosted or server hosted by a third-party, the process of configuring your wallet is the same.
# 5. Testing the checkout
Making a small test-purchase from your store will give you a piece of mind. Always make sure that everything is set up correctly before going live. The final video guides you through the steps of setting a gap limit in your Electrum wallet and testing the checkout process.
# 6. Customizing BTCPay WooCommerce Plugin
# BTCPay Order Statuses
Depending on your business model and store settings, you may want to configure your order statuses. You can set BTCPay to trigger certain order status in WooCommerce automatically.
- New Order - order placed, not paid yet.
- Paid - order paid, not confirmed on the blockchain.
- Confirmed - order paid, confirmed on the blockchain, does not have a sufficient number of confirmations set in BTCPay tore settings.
- Complete - order paid, confirmed on the blockchain with a sufficient number of confirmations.
- Invalid - order paid, did not get a sufficient number of confirmations in a pre-defined time-frame set in BTCPay store settings.
- Expired - invoice expired, order not paid
- Paid after expiration - invoice expired, paid
- Expired with partial payment - invoice expired and paid partially
Take time to think about how you wish to automate these statuses. If you do not wish certain BTCPay status to trigger WooCommerce order status, you can leave it blank.
For example, if a merchant wants to send an email notifying the customer that the payment has been received, but the order will be processed upon confirmation, the merchant would have to set "order status paid" to "on hold." Then, the merchant would have to customize and trigger email for 'on hold' status of the order in WooCommerce. It takes some time to find a perfect formula, so users should test things out before going live.
# Deploying WooCommerce from BTCPay Server
If you already have BTCPay Server, you can very easily start WooCommerce from your existing environment.
Point the external IP of the virtual machine where your BTCPay is hosted to your store domain, for example store.yourdomain.com.
Log into your BTCPay server as root.
sudo su -
- Set up WooCommerce variables. You can add optional variables (opens new window) as well.
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-woocommerce" export WOOCOMMERCE_HOST="yourstoredomain.com"
- Lastly, just run BTCPay Setup script which will add the set up variables.
. ./btcpay-setup.sh -i
- Go to your store's domain name, in our example that's store.yourdomain.com and follow the WordPress installation wizard.