# Configuration

#### Step 1: Choose Your Environment

| Environment    | API URL                            | Dashboard                                               |
| -------------- | ---------------------------------- | ------------------------------------------------------- |
| **Production** | `https://api.fungies.io/v0`        | [app.fungies.io](https://app.fungies.io/)               |
| **Sandbox**    | `https://api.stage.fungies.net/v0` | [app.stage.fungies.net](https://app.stage.fungies.net/) |

> **Important:** Production and staging are **completely separate**. API keys, products, and webhooks are all independent. Staging keys will NOT work against the production API, and vice versa.

<figure><img src="/files/sayHrF9q0GzUGvoNCMYi" alt=""><figcaption><p>Configure Webhook URL + Post-Purchase Redirect URL in your Fungies Dashboard</p></figcaption></figure>

#### Step 2: Get Your API Keys

1. Log in to your Fungies Dashboard (production or staging)
2. Go to **Developers → API Keys**
3. Click **Generate API Key**
4. Copy your **Public Key** (`pub_...`) and **Secret Key** (`sec_...`)
5. Copy your **Webhook Secret** from **Developers → Webhooks**

#### Step 3: Plugin Settings

Navigate to **WooCommerce → Settings → Fungies** and fill in:

| Setting               | Value                         |
| --------------------- | ----------------------------- |
| Sandbox Mode          | Check if using staging        |
| Public Key            | Your `pub_...` key            |
| Secret Key            | Your `sec_...` key            |
| Webhook Secret        | From Fungies webhook settings |
| **Fungies Store URL** | Your store URL (see Step 4)   |

#### Step 4: Match Store Currencies

> **Your WooCommerce store currency must match the currency set in your Fungies workspace.**

1. Check your Fungies currency in **Fungies Dashboard → Settings → General** (under "Currency")
2. Check your WooCommerce currency in **WooCommerce → Settings → General** (under "Currency options")
3. Make sure both are set to the same currency (e.g. both USD, both EUR)

If the currencies don't match, product prices will display incorrectly and checkout totals may be wrong.

#### Step 5: Publish Your Fungies Store & Get the Store URL

> **Your Fungies store must be published for the hosted checkout to work.**

1. In the Fungies Dashboard, click **"Go to Store"** in the top menu
2. Make sure the store is **published** (not draft)
3. Copy the store URL — it looks like:
   * **Production:** `https://yourname.app.fungies.io`
   * **Staging:** `https://yourname.stage.fungies.net`
4. Paste it into the **Fungies Store URL** field in WooCommerce → Settings → Fungies
5. Click **Save Changes**

#### Step 6: Configure Webhook in Fungies

1. Go to **Fungies Dashboard → Developers → Webhooks**
2. Add a new endpoint with the **Webhook URL** shown on the plugin settings page (e.g. `https://yoursite.com/wp-json/fungies/v1/webhook`)
3. Select the events: `payment_success`, `payment_failed`, `payment_refunded`, `subscription_created`, `subscription_interval`, `subscription_cancelled`

#### Step 7: Configure Post-Purchase Redirect URL in Fungies

After a customer completes payment on Fungies, they need to be redirected back to your WooCommerce store. This is configured **store-wide** in the Fungies Dashboard.

1. Go to **Fungies Dashboard → Settings → Store → Checkout tab**
2. Scroll down to **"Success redirection settings"**
3. In the **Instant Redirect URL** field, paste the **Post-Purchase Redirect URL** shown on the plugin settings page:

   ```
   https://yoursite.com/?wc-api=fungies_return
   ```
4. In **URL Parameters**, add these system parameters from the dropdown:

   * **Order id** (appears as `fngs-order-id` in the URL)

   * **User email** (appears as `fngs-user-email` in the URL)

   > **Note:** The dropdown list shows human-readable names (e.g. "Order id", "User email"). Once selected, they are automatically converted to the correct URL parameters (`fngs-order-id`, `fngs-user-email`). The names in the dropdown may differ from the final parameter names -- this is expected.
5. The final redirect URL will look like:

```
https://yoursite.com/?wc-api=fungies_return&fngs-order-id={fngs-order-id}&fngs-user-email={fngs-user-email}
```

6. Click **Save**

> **How it works:** After payment, Fungies redirects the customer to this URL with the Fungies order ID. The plugin looks up the matching WooCommerce order and sends the customer to the WooCommerce "Order Received" thank-you page.

See the [Fungies redirect documentation](https://help.fungies.io/for-saas-developers/redirecting-after-purchase) for more details on available system parameters.

#### Step 8: Test the Full Flow

1. Enable **Sandbox Mode** and use staging keys
2. Click **Sync Now** to pull products
3. Add a product to cart and proceed to checkout
4. Select **Fungies Checkout** and place order
5. You should be redirected to the Fungies hosted checkout page
6. Pay using [Stripe test cards](https://docs.stripe.com/testing?testing-method=card-numbers)
7. After payment, you should be redirected back to the WooCommerce thank-you page
8. Check **WooCommerce → Orders** — the order should be marked as completed
9. Check logs at **WooCommerce → Status → Logs → `fungies-*`**

> When ready to go live, uncheck Sandbox Mode, switch to production keys and store URL, and Save Changes.

<figure><img src="/files/uRB4VOOzeVGmtQyfUBKj" alt=""><figcaption><p>Test Connection and Sync your One-Time Payment Offers from Fungies to WooCommerce using the buttons</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.fungies.io/integrations/woocommerce/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
