# Test and troubleshoot LemonSqueezy (https://talivia.com/docs/revenue-guides/lemonsqueezy/testing-and-troubleshooting)



Use the [shared payment testing setup](https://talivia.com/docs/revenue-guides/testing-payment-providers) to keep sandbox revenue separate from production, then apply the LemonSqueezy checks below.

## Connect test mode [#connect-test-mode]

1. Create or select a LemonSqueezy store in test mode.
2. Create an API key while LemonSqueezy is in test mode.
3. Connect that Store ID and API key to your sandbox Talivia website.

Talivia detects the API key mode and creates the webhook with the matching `test_mode` value. There is no environment selector in Talivia.

## Minimum test matrix [#minimum-test-matrix]

| Scenario                    | Expected Talivia result                                 |
| --------------------------- | ------------------------------------------------------- |
| One-time order              | One payment with the order amount and currency          |
| Subscription signup         | Initial payment and an active subscription              |
| Subscription renewal        | One new payment connected to the same customer          |
| Failed or recovered renewal | Subscription state changes without duplicate revenue    |
| Full or partial refund      | The original payment remains and net revenue is reduced |
| Repeated webhook            | No duplicate payment or subscription                    |

## The connection fails [#the-connection-fails]

* Confirm the API key can read the Store ID you entered.
* Confirm both values were copied from the same LemonSqueezy environment.
* Create a new API key if LemonSqueezy returns `401` or `403`.
* Reconnect after rotating the key; Talivia creates a new signed webhook and removes the previous managed endpoint.

## No payment appears [#no-payment-appears]

Open **Settings → Webhooks** in LemonSqueezy and find the Talivia endpoint for the connected store. Confirm the delivery succeeded and that the event is one Talivia processes, such as `order_created`, `subscription_payment_success`, `order_refunded`, or `subscription_payment_refunded`.

If the endpoint is missing or has the wrong `test_mode`, reconnect the provider from Talivia with the API key for the intended environment.

## The payment is unattributed [#the-payment-is-unattributed]

* **Standard link or overlay:** follow [Checkout Links](https://talivia.com/docs/revenue-guides/lemonsqueezy/checkout-links) and confirm checkout started from a tracked page.
* **Server-created checkout:** follow [Checkout API](https://talivia.com/docs/revenue-guides/lemonsqueezy/checkout-api) and confirm `checkout_data.custom.talivia_session_id` was included.
* **Metadata is unavailable:** configure the [Return URL fallback](https://talivia.com/docs/revenue-guides/lemonsqueezy/return-url).

For the first two flows, inspect the delivered webhook and confirm the session appears in `meta.custom_data.talivia_session_id`.
