# Checkout Flow

```
  Customer          WooCommerce           Fungies             WooCommerce
  ────────          ───────────           ───────             ───────────
     │                   │                   │                     │
     │  1. Place Order   │                   │                     │
     │──────────────────►│                   │                     │
     │                   │                   │                     │
     │                   │ 2. Create pending  │                     │
     │                   │    order           │                     │
     │                   │                   │                     │
     │  3. Redirect to Fungies checkout      │                     │
     │◄──────────────────│                   │                     │
     │──────────────────────────────────────►│                     │
     │                   │                   │                     │
     │  4. Pay on Fungies│                   │                     │
     │──────────────────────────────────────►│                     │
     │                   │                   │                     │
     │                   │                   │ 5. Webhook           │
     │                   │                   │ payment_success      │
     │                   │                   │────────────────────►│
     │                   │                   │                     │
     │  6. Redirect back │                   │  Order completed     │
     │◄─────────────────────────────────────│                     │
     │──────────────────────────────────────────────────────────►│
     │                   │                   │                     │
     │  7. Thank-you page│                   │                     │
     │◄─────────────────────────────────────────────────────────│
```

<figure><img src="/files/mWIR4M0ODZqAz9j6vr4n" alt=""><figcaption><p>Customers will see Fungies Checkout as one of the available payment methods</p></figcaption></figure>

<figure><img src="/files/x7WgKnTY1ouQs6netY4J" alt=""><figcaption><p>Customers will then be redirected to finish the payment on Fungies Hosted Checkout</p></figcaption></figure>

<figure><img src="/files/wIWbjICnusfoLbWXWtu5" alt=""><figcaption><p>Customers then await for payment to be finalized</p></figcaption></figure>

<figure><img src="/files/6px4FZWJCjTidvM99FEL" alt=""><figcaption><p>After the payment, user is redirected to a Thank You page</p></figcaption></figure>

<figure><img src="/files/Ba1wTINJEnaZHpIgav4a" alt=""><figcaption><p>Payment is finalized and you can start processing the order for your customer</p></figcaption></figure>

<figure><img src="/files/k8KYZWmKJsBkx1sdwaQO" alt=""><figcaption><p>In the Order Details - you'll also see Fungies Order Details on the right</p></figcaption></figure>

### Webhook Events

| Fungies Event            | WooCommerce Action                         |
| ------------------------ | ------------------------------------------ |
| `payment_success`        | Complete WC order, store Fungies metadata  |
| `payment_failed`         | Update order status to `failed`            |
| `payment_refunded`       | Create WC refund, set status to `refunded` |
| `subscription_created`   | Store subscription ID in order meta        |
| `subscription_interval`  | Create renewal order                       |
| `subscription_cancelled` | Update subscription status in meta         |

#### Webhook Security

All incoming webhooks are verified using **HMAC-SHA256** signature validation. Duplicate events are filtered via idempotency key tracking.

***

### Order Metadata

When a payment succeeds, the following metadata is stored on the WC order:

| Meta Key                   | Description                              |
| -------------------------- | ---------------------------------------- |
| `_fungies_order_id`        | Fungies order UUID                       |
| `_fungies_order_number`    | Fungies order number                     |
| `_fungies_payment_id`      | Payment UUID                             |
| `_fungies_payment_type`    | `one_time`, `subscription_initial`, etc. |
| `_fungies_subscription_id` | Subscription UUID (if applicable)        |
| `_fungies_invoice_url`     | Invoice PDF link                         |
| `_fungies_fee`             | Fungies processing fee                   |
| `_fungies_tax`             | Tax amount                               |

***

### FAQ

**Q: Does the Fungies store need to be published?** A: Yes. The hosted checkout URL only works when your Fungies store is published. Go to the Fungies Dashboard and make sure your store is not in draft mode.

**Q: Why don't customers get redirected back after payment?** A: You need to configure the **Instant Redirect URL** in Fungies Dashboard → Settings → Store → Checkout tab. See [Step 7](https://github.com/dukenukemall/fungies-wp-plugin#step-7-configure-post-purchase-redirect-url-in-fungies) above.

**Q: Can I use this alongside other WC payment gateways?** A: Yes. Fungies registers as a standard WC payment gateway. Customers can choose it at checkout alongside any other enabled gateways.

**Q: Which Fungies products are synced?** A: Only **OneTimePayment** products and their offers are synced. Other product types (Digital Downloads, Subscriptions, Game Keys, etc.) are not imported. The product name and description from Fungies are used for the WooCommerce product listing.

**Q: How often do products sync automatically?** A: Every hour via WP Cron. You can also trigger a manual sync anytime from the settings page.

**Q: How do I test without processing real payments?** A: Enable **Sandbox Mode**, use staging keys from [app.stage.fungies.net](https://app.stage.fungies.net/), and pay with [Stripe test cards](https://docs.stripe.com/testing?testing-method=card-numbers).


---

# 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/checkout-flow.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.
