# FluentCart

> Accept cryptocurrency payments in FluentCart through Cryptonly hosted checkout.

The **Cryptonly plugin for FluentCart** adds **Crypto** as a payment method to your FluentCart store, using Cryptonly's hosted checkout.

Customers choose Crypto at checkout, pay on the Cryptonly payment page and return to the FluentCart receipt. The order is marked paid once Cryptonly confirms the payment through a signed webhook. There is no manual reconciliation.

Setup takes three steps:

1. [Install the plugin](https://docs.cryptonly.net/integration/plugins/fluentcart.md#installation)
2. [Paste your keys](https://docs.cryptonly.net/integration/plugins/fluentcart.md#configuration) in FluentCart's payment settings
3. Switch the method on and place a test order

## How the payment flow works

```mermaid
sequenceDiagram
    participant Customer
    participant FluentCart
    participant Cryptonly
    Customer->>FluentCart: Place order with Crypto
    FluentCart->>Cryptonly: Create invoice
    FluentCart-->>Customer: Redirect to hosted checkout
    Customer->>Cryptonly: Pay with crypto
    Cryptonly->>FluentCart: invoice.statusChanged webhook
    FluentCart->>Cryptonly: Confirm invoice status
    FluentCart-->>Customer: Receipt: Purchase Successful
```

In detail:

1. When the customer places the order, the plugin creates a Cryptonly invoice server-side for the order total, in the store currency. Your API key never reaches the browser.
2. The customer is redirected to the hosted payment page and chooses a coin and network there.
3. Cryptonly sends signed webhooks to your store. The plugin verifies each one, reads the invoice from the Cryptonly API and only then updates the FluentCart transaction and order.
4. The **Back to store** button on the payment page opens the FluentCart receipt. If the order is still pending there, the plugin checks the invoice with the API once more, so a late webhook does not keep the customer waiting.

For details on invoices and statuses, see [Invoices](https://docs.cryptonly.net/guides/invoices.md).

## Requirements

| Requirement         | Details                                                                       |
| ------------------- | ----------------------------------------------------------------------------- |
| WordPress           | 6.7+                                                                          |
| PHP                 | 7.4+                                                                          |
| FluentCart          | 1.2.5+ (the free plugin is enough)                                            |
| Cryptonly account   | [merchant.cryptonly.net](https://merchant.cryptonly.net/)                     |
| Public HTTPS site   | Cryptonly must reach `https://your-store.com/?fluent-cart=fct_payment_listener_ipn&method=cryptonly` |

## Installation

The plugin is published in the [WordPress.org plugin directory](https://wordpress.org/plugins/cryptonly-crypto-payments-for-fluentcart/).

<Tabs>
  <TabItem label="WordPress admin">

1. In WordPress, go to **Plugins → Add New**.
2. Search for **Cryptonly FluentCart**.
3. Click **Install Now** on **Cryptonly – Crypto Payments for FluentCart**, then **Activate**.

  </TabItem>
  <TabItem label="Manual">

1. Download the plugin zip from the [WordPress.org plugin page](https://wordpress.org/plugins/cryptonly-crypto-payments-for-fluentcart/).
2. In WordPress, go to **Plugins → Add New → Upload Plugin** and upload the zip. Or, move the `cryptonly-crypto-payments-for-fluentcart` folder to `/wp-content/plugins/` on your server and activate it from the **Plugins** menu.

  </TabItem>
</Tabs>

After activation, open **FluentCart → Settings → Payment Settings → Cryptonly**.

## Configuration

| Setting                         | Description                                                                                     |
| ------------------------------- | ----------------------------------------------------------------------------------------------- |
| Live credentials                | API key and webhook signing key from [merchant.cryptonly.net](https://merchant.cryptonly.net/). |
| Test credentials (sandbox)      | The same pair from [sandbox-merchant.cryptonly.net](https://sandbox-merchant.cryptonly.net/).   |
| Underpayments                   | What happens when a customer sends less than the invoice amount. See [Underpayments](https://docs.cryptonly.net/integration/plugins/fluentcart.md#underpayments). |
| Order ID prefix                 | `FC-` by default, so order 12 appears as `FC-12` in Cryptonly. Use a different prefix for each store that shares a Cryptonly account. |

FluentCart's store-wide order mode (**Settings → Store Settings → Order Mode**) decides which pair is used: **Test** uses the sandbox keys and the sandbox API, **Live** uses the live ones.

Saving the settings checks the keys with the Cryptonly API, and a wrong key is refused. **Test Connection** checks the saved key again and warns if Cryptonly does not invoice in your store currency. In that case the method stays hidden at checkout.

### API key scopes

| Scope             | Used for                                                    |
| ----------------- | ----------------------------------------------------------- |
| `invoices.create` | Create the invoice when the customer places the order        |
| `invoices.list`   | Confirm the invoice status for webhooks and returning customers |
| `invoices.cancel` | Cancel an open invoice when the cart changes or the order is cancelled |
| `currencies.list` | Check the key and the store currency                         |

The plugin sends its webhook URL with every invoice, so you do **not** need to configure a webhook in the Merchant Dashboard.

## Checkout

The method name (**Crypto**), its logo and the text under it can be changed. Click the pencil icon at the top right of the Cryptonly settings to open FluentCart's **Checkout Customization**:

| Field | Default |
| --- | --- |
| Checkout Label | Crypto |
| Checkout Logo | The Cryptonly logo |
| Checkout Instructions | *After you place the order, you will pay on a secure Cryptonly page with the cryptocurrency of your choice.* Your text replaces it. Leave it empty to show the default again. |
| Thank you page instruction | Empty. Shown on the receipt after checkout. |

* A customer who goes back to the checkout and places the order again is sent to the same open invoice.
* If the cart total changed, the old invoice is cancelled and a new one is issued as `FC-12-2`.
* After an invoice expires or is cancelled, the customer can pay again from the checkout or from the **Payment Pending** receipt.

## Status mapping

| Cryptonly status                 | FluentCart                                                                                       |
| -------------------------------- | ------------------------------------------------------------------------------------------------ |
| `created`, `processing`          | No change. `processing` (transfer seen, waiting for confirmations) is noted in the order activity. |
| `paid`                           | Transaction **Succeeded**, payment **Paid**, order **Processing**. Digital orders complete automatically. |
| `overpaid`                       | As `paid`, with an overpayment note. Refund the extra from the Merchant Dashboard.               |
| `partially_paid`                 | Depends on the [Underpayments](https://docs.cryptonly.net/integration/plugins/fluentcart.md#underpayments) setting.                              |
| `expired`, `failed`, `cancelled` | Transaction **Failed**, payment **Failed**. The customer can pay again. A paid transaction is never downgraded. |

The Cryptonly invoice ID is the transaction's **Gateway ID**, and each step is written to the order's **Activity**.

### Underpayments

| Setting                                   | When a customer sends less than the invoice amount                                                     |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| **Hold the order for review** (default)   | Nothing is marked paid. The order stays **On Hold** with a note of what arrived.                         |
| **Record the amount received**            | The received value becomes a succeeded payment and the order is **Partially Paid**.                     |

The received value is the share of crypto received times the invoice amount, rounded down to the cent. Either way, decide whether to ship, collect the rest or refund the customer. A second payment for the same order is refused until you resolve it.

Keep in mind:

* Cancelling an order in FluentCart cancels its open Cryptonly invoice.
* Refunds made in FluentCart are not sent to Cryptonly. Refund the customer from the Merchant Dashboard.
* Automatic subscription renewals are not supported. FluentCart can offer Crypto for store-billed subscription invoices, which are paid as one-time charges.

## Testing

Set the order mode to **Test**, paste sandbox keys in **Test credentials** and place an order. You can pay with testnet coins, or click **Simulate payment** in the [sandbox dashboard](https://sandbox-merchant.cryptonly.net/) to trigger `paid`, `partially_paid` and other statuses without sending funds. See [Sandbox environment](https://docs.cryptonly.net/guides/sandbox-environment.md) and [Testing your integration](https://docs.cryptonly.net/guides/testing-your-integration.md).

## Webhook responses

| Code  | Meaning                                                                                       |
| ----- | --------------------------------------------------------------------------------------------- |
| `200` | Handled, or a repeat delivery that changed nothing                                             |
| `401` | The signature matches neither the live nor the test signing key                               |
| `404` | No FluentCart transaction belongs to the invoice                                               |
| `503` | The invoice could not be confirmed with the Cryptonly API, or another delivery for the same order is in progress. Cryptonly retries. |

For webhook signing details, see [Webhooks](https://docs.cryptonly.net/api-reference/webhooks.md).

## Related pages

  <ExternalLinkCard title="WordPress.org plugin page" href="https://wordpress.org/plugins/cryptonly-crypto-payments-for-fluentcart/" />
  <ExternalLinkCard title="Plugin on GitHub" href="https://github.com/cryptonly-net/cryptonly-fluentcart" icon="github" />
- [Invoices](https://docs.cryptonly.net/guides/invoices.md): How checkout payments work

## Support

For help with your Cryptonly merchant account, credentials, or payment questions, write to **support@cryptonly.net**.
