# Paymenter

> Accept cryptocurrency payments on Paymenter invoices through Cryptonly hosted checkout.

**Cryptonly for Paymenter** lets your Paymenter site accept Bitcoin, stablecoins, and other cryptocurrencies through Cryptonly's hosted checkout.

Customers open an invoice, click **Pay**, choose Cryptonly, and pay on the Cryptonly payment page. Invoices stay in your Paymenter currency. Paymenter records the payment only after a signed `invoice.statusChanged` webhook, and marks the invoice paid once nothing is left to pay.

## How the payment flow works

```mermaid
sequenceDiagram
    participant Customer
    participant Paymenter
    participant Cryptonly
    Customer->>Paymenter: Pay invoice with Cryptonly
    Paymenter->>Cryptonly: Create invoice for the amount due
    Cryptonly-->>Paymenter: paymentPageUrl
    Paymenter-->>Customer: Redirect to hosted checkout
    Customer->>Cryptonly: Pay with crypto
    Cryptonly->>Paymenter: invoice.statusChanged webhook
    Paymenter-->>Customer: Invoice marked paid
```

At a high level:

1. The customer clicks **Pay** on a Paymenter invoice and chooses the Cryptonly gateway.
2. The extension creates a Cryptonly invoice server-side for the amount still due. Your API key never reaches the browser.
3. The customer is redirected to the Cryptonly hosted payment page.
4. After payment, Cryptonly sends a signed webhook to Paymenter.
5. The extension verifies the webhook and records the payment on the invoice.

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

## Requirements

| Requirement | Details |
| --- | --- |
| Paymenter | 1.5 or newer (tested with 1.5.9) |
| PHP | 8.3 or newer |
| Cryptonly account | [Cryptonly merchant account](https://merchant.cryptonly.net/) |
| Public HTTPS App URL | Paymenter’s **Settings → General → App URL** must be a public HTTPS address so Cryptonly can deliver webhooks. Cryptonly does not follow redirects |
| Supported invoice currency | The invoice currency must be one Cryptonly prices. Other currencies do not show the gateway |

## Before you install — Cryptonly account

1. Sign up at [cryptonly.net](https://cryptonly.net), or at [sandbox-merchant.cryptonly.net](https://sandbox-merchant.cryptonly.net) for testing.
2. Open **Accounts**, select the account, then **Settings → Security**. Create an **API key**. The key selects the account.
3. On the same page, under **Webhook signing key**, click **Rotate key** and copy the secret when it is shown. It appears only once, and the previous key stops working immediately.

## Install the extension

Download `cryptonly-paymenter-1.0.0.zip` from the [Paymenter marketplace](https://paymenter.org/marketplace), then install it one of two ways:

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

1. In Paymenter admin, open **Extensions → Available Extensions → Ready to Install / Upload**.
2. Click **Upload Extension**, choose the zip, and click **Submit**.

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

1. Extract the zip into your Paymenter `extensions/Gateways/` folder (FTP, SFTP, or your hosting file manager). After extraction, this file should exist:

    ```text
    extensions/Gateways/Cryptonly/Cryptonly.php
    ```

2. Make sure the web server user can read the new folder.

  </TabItem>
</Tabs>

To update, upload the newer zip the same way. Paymenter replaces the folder and keeps the gateway settings.

## Configure the gateway

Open **Extensions → Gateways**, click **New**, and choose **Cryptonly** under **Gateway**. Enter a **Name**, which is what customers see at checkout, then fill in the gateway settings.

| Setting | Purpose |
| --- | --- |
| **Name** | The payment method name customers see, for example `Crypto` |
| **API Key** | Cryptonly API key. The key selects the account. See [required scopes](#api-key-scopes) |
| **Webhook Signing Key** | Signing key from the same account’s Security page. Paymenter rejects webhooks it cannot verify |
| **Sandbox mode** | Tick for a sandbox API key from [sandbox-merchant.cryptonly.net](https://sandbox-merchant.cryptonly.net) |
| **Order ID Prefix** | Optional. Default `PAYMENTER` produces `PAYMENTER-12`, then `PAYMENTER-12-2` on a later attempt. Use a different prefix for each site that shares an account |
| **Debug log** | Writes Cryptonly API responses to the Paymenter log (`storage/logs`). The API key is never logged |
| **Webhook URL** | Read-only. The address Cryptonly calls, built from App URL |

Saving checks the API key with Cryptonly `GET /currencies`. A sandbox key is refused unless **Sandbox mode** is ticked, and a production key is refused while it is ticked.

The extension sends the webhook URL with each invoice, so you do not paste it into the Cryptonly Merchant Dashboard:

```text
{App URL}/extensions/gateways/cryptonly/webhook
```

:::caution
Paymenter builds this URL from **Settings → General → App URL**, which overrides `APP_URL` in `.env`. If App URL is not public HTTPS, checkout stops with a message instead of creating an invoice Cryptonly cannot confirm.
:::

### API key scopes

Create the key on the account’s **Accounts → Settings → Security** page and enable only these scopes:

| Scope | Used for |
| --- | --- |
| `currencies.list` | Confirm the API key when saving the gateway (`GET /currencies`) and list the invoice currencies Cryptonly prices (`GET /currencies/fiat`) |
| `invoices.list` | Reuse a payable invoice or choose the next `orderId`, and load the invoice when create returns a duplicate (`GET /invoice`) |
| `invoices.create` | Create the invoice at checkout (`POST /invoice`) |

## Test in sandbox before going live

1. Tick **Sandbox mode** and enter credentials from [sandbox-merchant.cryptonly.net](https://sandbox-merchant.cryptonly.net).
2. Confirm **Settings → General → App URL** is public HTTPS. For a local Paymenter, use a tunnel such as ngrok and set App URL to the tunnel address.
3. Sign in as a customer, open an unpaid invoice, click **Pay**, choose the Cryptonly gateway, and click **Pay Now**.
4. Complete payment on the Cryptonly [sandbox payment page](https://docs.cryptonly.net/guides/sandbox-environment.md) using testnet assets only, or use **Simulate payment** on the invoice in Cryptonly **Accounts → History** to settle it without sending testnet funds.
5. Confirm the Paymenter invoice shows **Paid** with a **Succeeded** transaction.

See [Testing your integration](https://docs.cryptonly.net/guides/testing-your-integration.md) for more on the History and simulator tools.

:::caution
Sandbox uses testnets only. Do not send mainnet funds to sandbox payment addresses.
:::

## Customer payment experience

1. The customer opens an unpaid invoice and clicks **Pay**.
2. They choose the Cryptonly gateway (named **Crypto** here) and click **Pay Now**.

3. The extension creates a Cryptonly invoice for the amount still due and redirects the customer to the Cryptonly payment page, where they pick a coin and network and pay.
4. The customer returns to the invoice. It shows **Payment Processing** and checks every few seconds until the webhook arrives.
5. Paymenter records the payment and marks the invoice **Paid**. The transaction id is the Cryptonly invoice id, so you can find the payment in Cryptonly **Accounts → History**.

**If the customer leaves before paying**

The Paymenter invoice stays unpaid. Clicking **Pay** again returns the customer to the same Cryptonly payment page while it is still payable, and creates a new one after it expires or is cancelled.

## How Paymenter invoices are updated

The extension listens for `invoice.statusChanged` webhooks. Returning from the hosted page does not mark the invoice paid.

| Cryptonly invoice status | Paymenter behavior |
| --- | --- |
| `created`, `processing` | Nothing recorded |
| `suspended` | A **Processing** transaction is added. A later `paid` completes it; `failed`, `cancelled` or `expired` marks it **Failed** |
| `paid`, `overpaid` | The amount still due is recorded and Paymenter marks the invoice paid. An overpay is not stored as credit |
| `partially_paid` | `settlement.amountPaid` is recorded. The invoice stays open for the rest |
| `expired`, `failed`, `cancelled` | Nothing recorded. A later `paid` can still be applied |

A repeated webhook updates the same transaction instead of adding money twice. The next **Pay** after a partial payment charges only what is still due, with order id `PAYMENTER-12-2`, then `PAYMENTER-12-3`.

Overdue invoices can still be paid. Saved payment methods (billing agreements) and refunds are not supported, so a renewal invoice is paid with a new checkout.

## Go live checklist

* [ ] Untick **Sandbox mode**
* [ ] Enter production **API Key** and **Webhook Signing Key**
* [ ] Confirm **App URL** is public HTTPS and reachable from the internet
* [ ] Confirm each invoice currency you use is offered by Cryptonly
* [ ] Place a small real payment and confirm the invoice is marked **Paid**

## Troubleshooting

**Cryptonly is not offered on an invoice**

* Confirm **API Key** and **Webhook Signing Key** are saved on the gateway.
* Check the invoice currency. The gateway is hidden for currencies Cryptonly does not price.
* The invoice must have something left to pay.

**“Cryptonly needs this site on a public HTTPS address”**

**Settings → General → App URL** is `http://`, `localhost`, or an IP address. Set it to your public HTTPS domain. The read-only **Webhook URL** on the gateway form shows the result.

**“Invalid Cryptonly API key” when saving**

* **Sandbox mode** must match the key: ticked for a sandbox key, unticked for a production key.
* The key needs the [required scopes](#api-key-scopes).

**The invoice stays on Payment Processing**

* Confirm Paymenter is reachable from the internet at App URL, and that a firewall, WAF, or bot protection does not block `POST /extensions/gateways/cryptonly/webhook`.
* Confirm the **Webhook Signing Key** matches the account’s **Accounts → Settings → Security** page. A wrong key makes Paymenter answer `401`, and the payment is not recorded.
* Look in the Paymenter log (`storage/logs`) for `Cryptonly webhook` lines, which show the status and what was recorded.

**“This invoice already has a finished Cryptonly payment”**

The Cryptonly invoice for this order id was already paid. Check the payment in Cryptonly **Accounts → History** and the invoice transactions in Paymenter before taking a new payment.

## Frequently asked questions

**Which cryptocurrencies are supported?**

Cryptonly supports Bitcoin, Ethereum, USDT, USDC, and many other cryptocurrencies. Available assets depend on your Cryptonly account and enabled networks.

**Do I need to configure webhooks in the Cryptonly Merchant Dashboard?**

No. The extension sends the webhook URL with each invoice. You only enter the **Webhook Signing Key** so incoming webhooks can be verified.

**Can customers pay part of an invoice?**

Yes. A partial crypto payment is recorded on the invoice, and the customer pays the rest with a new checkout or another payment method.

**Does it work with Paymenter account credit?**

Yes. If credit covers part of the invoice, Cryptonly charges only the amount still due.

## Related pages

- [Webhooks](https://docs.cryptonly.net/api-reference/webhooks.md): Verification and payload details
- [Invoices](https://docs.cryptonly.net/guides/invoices.md): How checkout payments work
- [Testing your integration](https://docs.cryptonly.net/guides/testing-your-integration.md): History and test webhooks

## Support

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