# WooCommerce

The **RazCrypto Gateway for WooCommerce** plugin adds "Pay with crypto" to your store checkout. Customers pay
in USDT, USDC or native coins straight into your own wallet. Orders are marked paid automatically.

[Download plugin](https://razcryptogateway.com/downloads/razcrypto-for-woocommerce.zip) · version and
checksum in [manifest.json](https://razcryptogateway.com/downloads/manifest.json)

- Works with the **Checkout block** and the classic `[woocommerce_checkout]` shortcode.
- Compatible with **High-Performance Order Storage (HPOS)**.
- Uses your **store currency** automatically (INR, USD, EUR… whatever WooCommerce is set to). The customer pays the converted amount in the coin they pick.
- **Overview page** (WooCommerce → RazCrypto): paid orders, revenue, pending and on-hold orders.
- **Test mode** with simulated payments — no real money needed.
- Orders complete from **signed webhooks**. The plugin always re-reads the payment from the API, so a fake
  webhook cannot mark an order paid.

## Requirements

| | Minimum | Tested up to |
|---|---|---|
| WordPress | 6.4 | 7.1 |
| WooCommerce | 8.6 | 11.1 |
| PHP | 8.1 | 8.2 |

Your server must be able to make outgoing HTTPS requests (normal on every host). The webhook URL must be
reachable from the internet.

## Install

1. Download `razcrypto-for-woocommerce.zip` (link above).
2. In WordPress open **Plugins → Add New Plugin → Upload Plugin**, choose the zip, then **Install Now → Activate**.
3. A notice appears: *RazCrypto is installed* → click **Finish setup**. (Or open **WooCommerce → Settings →
   Payments → RazCrypto**.)
4. Paste your secret key and **Save**. "Pay with crypto" now shows at checkout — the method is enabled by
   default and stays hidden only while the key is missing.

You will need these from your RazCrypto dashboard. Start with a **Test** app:

- **Secret key** (`sk_test_…`) — shown once, when the app is created. Roll it if you lost it.
- **Signing secret** (`whsec_…`) — Dashboard → API apps → your app → Webhook → Reveal

## Settings

| Setting | What to enter | Default |
|---|---|---|
| **Enable** | Untick to hide "Pay with crypto" at checkout. | On |
| **Title** | Name of the method the customer sees. | Pay with crypto (USDT, USDC…) |
| **Description** | Short text under the title at checkout. | Pay from any wallet… |
| **Mode** | **Test** uses the test keys (no real money). **Live** uses the live keys. | Test |
| **Test secret key** | `sk_test_…` of your **test** API app. | empty |
| **Test signing secret** | `whsec_…` of the same test app. Used to check webhooks. | empty |
| **Live secret key** | `sk_live_…` of your **live** API app. | empty |
| **Live signing secret** | `whsec_…` of the same live app. | empty |
| **Webhook URL** | Not a field — copy the URL shown here into your RazCrypto app (see below). | — |
| **Status after payment** | **WooCommerce default**: Processing for physical goods, Completed for virtual or downloadable goods. **Completed**: always Completed. | WooCommerce default |

- The method appears at checkout when it is **enabled** and the **secret key for the current mode** is filled in.
- Keys are stored in your WordPress database like every other payment plugin, and shown as password fields.

## Currency and amount

The plugin sends the order total **in your store currency** — it reads WooCommerce → Settings → General →
Currency for every order, so there is nothing to configure. The gateway converts it at the live rate when the
customer picks a coin, and locks that rate for the payment window.

Example — a ₹200 order: USDT at ₹96.3 → about **2.09 USDT**; BNB at ₹75,906 → about **0.00265 BNB**.
Each payment gets a tiny unique extra (a few paise to a few rupees) so the gateway can tell which customer
paid; you never receive less than the order total. Very small orders below a coin's minimum (for example
0.1 USDT) cannot be paid with that coin.

## Overview

**WooCommerce → RazCrypto** (also **Overview** on the Plugins screen) shows, for the last 7 days, 30 days
or all time:

- **Paid orders** and **Revenue** (Processing + Completed, minus refunds, per currency)
- **Waiting for payment** and **On hold (check)**
- the **latest crypto orders** with their RazCrypto payment id
- whether the method is shown at checkout, the mode, and a warning if the signing secret is missing

## Connect the webhook

1. Copy the **Webhook URL** shown on the settings page. It looks like
   `https://yourstore.com/?wc-api=razcrypto` (on sites with pretty permalinks: `https://yourstore.com/wc-api/razcrypto/`).
2. In your RazCrypto dashboard open **API apps → (the same app) → Webhook**, paste it as the endpoint URL
   and save. Keep the `payment.*` events selected.
3. Press **Send test event**. It should show `200`.

Do this once for the test app and once for the live app.

## What happens at checkout

1. The customer chooses "Pay with crypto" and places the order. The order is **Pending payment**.
2. The plugin creates a RazCrypto payment for the order total, in the store currency, with the order number as
   `reference_id`. The customer is sent to the RazCrypto checkout.
3. The customer picks a network and coin, and pays from any wallet.
4. After payment the checkout shows a green **Payment received** screen and, a few seconds later, sends the
   customer back to your **thank-you page** automatically (WooCommerce's order-received page). There is
   nothing to set — the plugin passes that page as the return address.
5. The order is updated when either of these happens first:
   - the signed webhook arrives
   - the customer opens the thank-you page

   Either way the plugin re-reads the payment from the API before changing the order.

| RazCrypto status | Order becomes |
|---|---|
| `paid`, amount and currency match | **Processing** or **Completed** (your setting) |
| `paid` but amount or currency differ, or `underpaid` | **On hold** — check it in your dashboard |
| `expired` or `cancelled` while the order is pending | **Cancelled** |
| `confirming` | unchanged (order note added) |

**Downloadable or virtual products:** when the order is paid, WooCommerce grants the downloads as usual — the
links appear on the thank-you page, in *My account → Downloads* and in the order email. Virtual + downloadable
orders go straight to **Completed**.

Every change adds an order note starting with `RazCrypto:`. The payment id (`pay_…`) is saved on the order
as the transaction id.

Clicking **Place order** twice never creates two payments. The request uses an idempotency key built from
the order and its total.

## Test it

1. Set **Mode = Test** with your test keys, and enable the method.
2. Place an order on your store and choose "Pay with crypto". You land on the checkout marked
   *Test mode — no real money moves*.
3. In your RazCrypto dashboard open **Payments → (that payment) → Simulate → Paid**.
4. Within seconds the order shows **Processing** and the note `RazCrypto: …`.

Try **Simulate → Underpaid** to see the On hold path.

## Go live

1. In your RazCrypto dashboard create a **live** API app. Copy its secret key and signing secret, and add its
   webhook URL as above.
2. Paste the keys into **Live secret key** and **Live signing secret**.
3. Set **Mode = Live** and save.
4. Place one small real order to confirm.

## Troubleshooting

| Problem | Fix |
|---|---|
| "Pay with crypto" is not shown at checkout | Enable the method and fill the secret key for the current **Mode**. Also check that the store currency is supported. |
| "Crypto payment could not be started" | Open the order notes. The exact error is there, for example a wrong key (test key in Live mode, or the other way round). |
| Orders stay **Pending payment** after paying | Check the webhook URL in your RazCrypto app and press **Send test event**. Make sure a firewall or a "coming soon" plugin does not block `?wc-api=razcrypto`. The thank-you page also updates the order. |
| Webhook test shows `400 invalid signature` | The **signing secret** in the plugin is not the one of this app, or it is in the wrong mode field. |
| Order is **On hold** | The customer paid less, or paid in a different currency. Open the payment in your dashboard and decide. |

## Privacy

When a customer chooses crypto, the plugin sends the RazCrypto API these details:

- order total and currency
- order number
- customer name and email

Nothing is sent for other payment methods. Read the [privacy policy](https://razcryptogateway.com/legal/privacy) and
[terms](https://razcryptogateway.com/legal/terms).
