> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mycryptoserver.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WooCommerce

> Accept ETH payments on your WordPress / WooCommerce store with the MyCryptoServer gateway plugin

The **MyCryptoServer for WooCommerce** plugin adds a crypto payment gateway to your WordPress store. At checkout, the customer is redirected to a hosted payment page, pays in ETH from any wallet, and the order is automatically marked paid when the on-chain payment confirms — via a signed webhook back to your store.

The plugin talks only to the public `/api/v1/*` API, so it works against both the hosted service and a self-hosted instance.

<Note>
  Not running WooCommerce? The [WordPress guide](/integrations/wordpress) covers no-code payment links and custom PHP integrations for any WordPress site.
</Note>

## How it works

1. Customer selects **Pay with crypto** and places the order.
2. The plugin calls `POST /api/v1/checkout_sessions`, stores the returned session id on the order, sets the order to **On hold**, and redirects the customer to the hosted checkout.
3. The customer pays. MyCryptoServer detects the transfer and sends webhook events to your store.
4. On `session.paid` the plugin calls WooCommerce's `payment_complete()` and the order moves to **Processing / Completed**.

## Requirements

* WordPress 6.0+ and WooCommerce 7.0+ (HPOS and the block-based Checkout are both supported).
* PHP 7.4+.
* A MyCryptoServer account (hosted or self-hosted).

## Quick setup (recommended)

The dashboard can generate the plugin **pre-configured for your store** — it provisions the API key and webhook endpoint for you and bakes them into the download, so there is nothing to copy-paste.

<Steps>
  <Step title="Generate the plugin">
    In the dashboard, go to **Integrations → WordPress**, enter your **WordPress store URL** (e.g. `https://store.example.com`), pick the mode (**Live** or **Test**), and click **Generate & download plugin**.

    Behind the scenes this creates an API key (scoped to sessions + webhooks) and registers a webhook endpoint at `https://your-store.com/wp-json/mycryptoserver/v1/webhook` subscribed to all `session.*` events, then embeds those credentials — plus the API base URL — in the zip.

    <Warning>
      The raw API key and webhook secret exist **only inside the zip** — they are not stored server-side, so keep the file safe. Regenerating provisions fresh credentials and revokes the previous ones: an older download stops working the moment you regenerate.
    </Warning>
  </Step>

  <Step title="Upload and activate">
    In WordPress, go to **Plugins → Add New → Upload Plugin**, choose `mycryptoserver-woocommerce.zip`, **Install Now**, and **Activate**. The gateway settings (API base URL, key, webhook secret, endpoint ID, test mode) are seeded automatically on activation.

    Then enable the gateway under **WooCommerce → Settings → Payments → MyCryptoServer** and adjust the customer-facing **Title**/**Description** if you like.
  </Step>

  <Step title="Test the round-trip">
    Open any order in the WooCommerce admin and click **Test send webhook** in the MyCryptoServer metabox — a `✓ sent` result means signing and connectivity are correct end to end. Then place a test order and confirm it transitions **On hold → Processing** after payment.
  </Step>
</Steps>

## Manual setup

If you prefer to provision credentials yourself (or you're installing the same zip on a second site), configure the plugin by hand:

<Steps>
  <Step title="Install the plugin">
    Download the plugin zip, then in WordPress go to **Plugins → Add New → Upload Plugin**, choose the zip, **Install Now**, and **Activate**.

    Activation creates the webhook log table and registers the REST webhook route at:

    ```
    https://your-store.com/wp-json/mycryptoserver/v1/webhook
    ```

    <Note>
      WooCommerce must be installed and active first. Without it the plugin shows an admin notice and stays inactive.
    </Note>
  </Step>

  <Step title="Create an API key">
    In the MyCryptoServer dashboard, go to **API Keys** and create a key with these scopes:

    | Scope            | Why                                                           |
    | ---------------- | ------------------------------------------------------------- |
    | `sessions:write` | Create checkout sessions at checkout (required)               |
    | `webhooks:write` | Enable the **Test send** button in the order admin (optional) |

    Use a `ck_test_...` key while testing and a `ck_live_...` key in production. Copy the key — it is shown only once.
  </Step>

  <Step title="Create a webhook endpoint">
    In the dashboard, go to **Webhooks → Add endpoint** and set:

    * **URL**: `https://your-store.com/wp-json/mycryptoserver/v1/webhook`
    * **Events**: subscribe to all `session.*` events (or at least `session.detected`, `session.paid`, `session.paid_late`, `session.underpaid`, `session.overpaid`, `session.expired`, `session.failed`).

    Copy the **signing secret** (`whsec_...`) — shown only once — and note the endpoint **ID** (a UUID).
  </Step>

  <Step title="Configure the gateway">
    In WordPress, go to **WooCommerce → Settings → Payments → MyCryptoServer → Manage** and fill in:

    | Setting                      | Value                                                               |
    | ---------------------------- | ------------------------------------------------------------------- |
    | **Enable**                   | Turn the gateway on                                                 |
    | **Title**                    | What customers see at checkout (e.g. "Pay with crypto (ETH)")       |
    | **Description**              | Optional checkout blurb                                             |
    | **API base URL**             | Your MyCryptoServer URL, e.g. `https://mycryptoserver.com`          |
    | **API key**                  | The `ck_live_` / `ck_test_` key from step 2                         |
    | **Webhook signing secret**   | The `whsec_` value from step 3                                      |
    | **Webhook endpoint ID**      | The endpoint UUID from step 3 (enables Test send)                   |
    | **Test mode**                | Treat transactions as test                                          |
    | **Show confirmations**       | Show live payment status + confirmation count on the thank-you page |
    | **Delete data on uninstall** | Drop the log table and settings when the plugin is deleted          |

    Save changes.
  </Step>

  <Step title="Test the round-trip">
    With **Webhook endpoint ID** set and a key that has `webhooks:write`, open any order in the WooCommerce admin and click **Test send webhook** in the MyCryptoServer metabox. A `✓ sent` result means signing and connectivity are correct end to end.

    Then place a real order (with **Test mode** on, or a `ck_test_` key) and confirm the order transitions **On hold → Processing** after payment.
  </Step>
</Steps>

## Order status mapping

| Webhook event                                             | WooCommerce result                                                  |
| --------------------------------------------------------- | ------------------------------------------------------------------- |
| `session.detected`                                        | Order note: payment detected, awaiting confirmations                |
| `session.paid` / `session.paid_late` / `session.overpaid` | `payment_complete()` → **Processing / Completed**, tx hash recorded |
| `session.underpaid`                                       | Order note added; order kept **On hold** for manual review          |
| `session.expired`                                         | **Failed** (unless already paid)                                    |
| `session.failed`                                          | **Failed** (unless already paid)                                    |

Webhook processing is idempotent — duplicate deliveries won't double-complete an order or duplicate notes.

## Going live

If you used **Quick setup** with the mode set to **Test**, the simplest path is to regenerate: go back to **Integrations → WordPress**, switch the mode to **Live**, download again, and upload the new zip (the test credentials are rotated out automatically).

If you configured manually:

1. Swap the **API key** to a `ck_live_...` key (with `sessions:write`).
2. Turn **Test mode** off.
3. Make sure the production webhook endpoint points at your live store URL and is **active**.

## Troubleshooting

| Symptom                                                   | Likely cause                                                                                                                                                                                   |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Gateway not visible at checkout                           | Gateway not enabled, or the store uses the block Checkout — the plugin supports it, but confirm the gateway is enabled and saved                                                               |
| "Could not create the crypto payment session" at checkout | Wrong **API base URL** / **API key**, key missing `sessions:write`, or the order total has more than 2 decimal places (the plugin normalizes to 2 — re-check currency settings if it persists) |
| Orders stay **On hold** after payment                     | Webhook not reaching the store. Check the endpoint URL, that `session.*` events are subscribed, and the **signing secret** matches. Inspect deliveries under **Webhooks → Deliveries**         |
| Webhook returns `401 bad signature`                       | The **Webhook signing secret** in the gateway settings doesn't match the endpoint's `whsec_`                                                                                                   |
| **Test send** button missing                              | No **Webhook endpoint ID** configured                                                                                                                                                          |
| **Test send** fails with a 4xx                            | API key lacks the `webhooks:write` scope                                                                                                                                                       |

Every inbound webhook is recorded in the `wp_mcs_webhook_log` table (signature result, response status, body), trimmed to the most recent 500 rows — useful for debugging delivery issues.

## Uninstalling

Deactivating leaves all data in place. **Deleting** the plugin removes its data only if **Delete data on uninstall** was enabled — otherwise order meta and the log table are preserved.
