Jump to content

Revolut Merchant API Gateway for WHMCS


Group44

Recommended Posts

Revolut Merchant API Gateway for WHMCS

The Revolut Merchant API Gateway lets WHMCS customers pay invoices through a Revolut Business merchant account. They can pay by card, saved card, Revolut Pay, Apple Pay or Google Pay, and the invoice is marked Paid automatically.

Overview

Pay Invoices Through Revolut Business

It is a standard WHMCS third-party payment gateway module, written in plain PHP with no external libraries.

Module name

Revolut (revolut)

Version

1.2.0

Author

Group44 Pty Ltd – www.group44.com.au

Module type

WHMCS payment gateway (third-party / invoice link)

Revolut API

Merchant API, Revolut-Api-Version 2024-09-01 by default (configurable)

Environments

Production (merchant.revolut.com) and Sandbox (sandbox-merchant.revolut.com)

Delivered as

whmcs-revolut-gateway-v1.2.0.zip

Who it is for

Hosting companies and other WHMCS businesses with a Revolut Business merchant account. They want customers to pay inside the WHMCS invoice page, with optional saved cards and automatic billing.

 

Features at a Glance

Checkout

"Split checkout" payment panel: Amount due, one "Pay with" list, one Pay button.

Embedded Revolut card field inside the WHMCS invoice (card data never touches your server).

Revolut Hosted Checkout for Revolut Pay, Apple Pay, Google Pay and Pay by Bank.

Two styles: embedded card form, or redirect to Revolut.

Mobile layout with the Pay button pinned to the bottom.

Accent colour setting to match your brand.

Saved cards

Customers save a card when paying, pay later invoices in one click, remove cards themselves.

Cards stored by Revolut; WHMCS keeps only brand, last 4 digits and expiry.

Auto-billing

Daily cron charges the default saved card for due invoices, with days-before and retry limits.

Payment sync

Invoice marked Paid when the customer returns, with signed webhooks as a backup.

Idempotent: a payment can never be added twice.

Multi-currency, zero-decimal currencies and Convert To For Processing.

Admin

One-click webhook registration, secret rotation and deletion (works with a renamed admin folder such as /staff).

Full and partial refunds from the WHMCS invoice.

Transaction Information popup: state, fees, refunds, payment method, environment.

Live compatibility check (WHMCS, PHP, extensions) in the gateway settings.

Separate production and sandbox keys and webhooks.

Logging

Gateway Log entries for every payment event; full API calls in the Module Log.

The “Split Checkout” Payment Panel

What the customer sees

Amount due in large type with the due date, e.g. "A$75.85 · Due 1 Dec 2026" (uses the WHMCS currency prefix).

Pay with list, one option per row.

Each saved card (brand badge, •••• last 4, expiry). The default card is marked Default and pre-selected.

New card: opens the cardholder name, Revolut's secure card field and the "Save this card…" tick box.

Revolut Pay, Apple Pay, Google Pay: sends the customer to Revolut's hosted page. In Redirect mode this option reads "Card or Revolut Pay".

One Pay A$75.85 button. It reads "Continue to Revolut" when the wallets option is selected.

"Secured by Revolut. Card details never touch our servers." and Manage saved cards.

On phones the panel fills the width and the Pay button stays pinned to the bottom of the screen.

What happens on each choice

Saved card

POSTs to the callback; creates an order for the balance and charges the card; returns Paid, Processing or Failed.

New card

Submits the card in Revolut’s iframe (3-D Secure handled by Revolut); on success goes to the return page.

Wallets

Opens the order’s Revolut checkout link; Revolut redirects back to the return page.

Inside the WHMCS Invoice

These show v1.2.0, rendered from the module’s own output with sample data. The invoice details on the left are stand-ins: on a live site your WHMCS theme appears there.

Requirements and Compatibility

The module needs WHMCS 9.1.0 or later and PHP 8.3 or 8.4. It checks this itself: on an older WHMCS or PHP it shows a red warning in the gateway settings, and customers see a notice instead of the payment panel.

WHMCS

9.1.0 and above

PHP

8.3 and 8.4

MySQL

8.0 (MariaDB 10.6+ also works)

ionCube Loader

15.0.0 – needed by WHMCS itself; the module is plain PHP and is not encoded

PHP extensions

cURL, JSON, hash, OpenSSL (random_bytes)

Web server

HTTPS System URL (Revolut only sends webhooks to HTTPS)

Revolut

A verified Revolut Business account with a Merchant account and API access

Where a business can use it

Revolut offers merchant accounts to businesses registered in Australia, Austria, Belgium, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Iceland, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Netherlands, Norway, Poland, Portugal, Romania, Slovakia, Slovenia, Singapore, Spain, Sweden and the United Kingdom. US, Swiss and Liechtenstein businesses can open Revolut Business but not a merchant account. Customers can pay from any country.

Currencies

Card, Apple Pay and Google Pay payments accept AUD, CAD, CHF, CZK, DKK, EUR, GBP, HKD, HUF, ILS, JPY, MXN, NOK, NZD, PLN, RON, SEK, SGD, TRY, USD and ZAR. Revolut Pay accepts more, including AED, INR, KRW, SAR and THB. For any other invoice currency, set WHMCS Convert To For Processing to a supported currency; the module converts amounts both ways.

Setup Takes About 10 Minutes

Upload, paste one key, click Register, then test in sandbox before going live.

1

Upload the zip contents to the WHMCS root folder, keeping the structure (modules/gateways/… and includes/hooks/revolut_autobill.php)

2

Optional: add modules/gateways/revolut/assets/group44-logo.png for the settings box

3

Activate Revolut: in WHMCS admin go to System Settings → Payment Gateways → All Payment Gateways and activate Revolut

4

Paste the Production Secret Key (Revolut Business → Merchant → APIs → Merchant API) and save

5

Register the webhook: click Register / manage Revolut webhooks, then Register. The signing secret is saved for you

6

Choose your options: Checkout Style, Mark Paid When, saved cards, auto-billing and Accent Colour, then save

7

Check the cron: make sure the WHMCS cron runs daily if you use auto-billing

Testing

Sandbox Testing and Upgrading

1

Sandbox Mode: tick Sandbox Mode, paste the sandbox secret key, save

2

Sandbox webhook: open the webhook page again and register the sandbox webhook (each environment has its own)

3

Test cards: pay a test invoice with Revolut’s sandbox test cards: one success, one declined, one 3-D Secure

4

Saved card: test New card with “Save” ticked, then pay a second invoice with the saved card

5

Wallets: test Revolut Pay / Apple Pay / Google Pay through the hosted page

6

Refunds: refund one payment in full and one in part

7

Auto-billing: set an invoice due today and run the cron to test auto-billing

8

Go live: check Billing → Gateway Log for each event, then untick Sandbox Mode

Upgrading from 1.0.0 or 1.1.0

Upload the new files over the old ones. No settings or data are lost and the tables are unchanged. In 1.2.0, the old “Pay Button Text” setting is replaced by “Accent Colour”.

Settings Reference

Gateway Settings

All settings are in System Settings → Payment Gateways → Revolut (under your admin folder, e.g. /staff). Above the fields, an info box shows the version, the webhook URL, the “Register / manage Revolut webhooks” button, the compatibility check and the Group44 copyright.

Production Secret Key

Password. Default: –. Revolut production secret key (sk_…) from Merchant → APIs → Merchant API.

Production Webhook Signing Secret

Text. Default: –. wsk_… secret used to verify webhooks. Filled in automatically by the webhook page.

Sandbox Mode

Yes/No. Default: Off. Switches every call to sandbox-merchant.revolut.com and the sandbox keys.

Sandbox Secret Key

Password. Default: –. Sandbox secret key.

Sandbox Webhook Signing Secret

Text. Default: –. Sandbox webhook secret, filled in automatically.

Checkout Style

Dropdown. Default: Embedded card form on invoice. Embedded: card entry inside the invoice plus a wallets option. Redirect: one “Card or Revolut Pay” option that opens Revolut’s hosted page.

Mark Invoice Paid When

Dropdown. Default: Authorised (recommended). Authorised: paid once the card is authorised and captured. Completed: waits for Revolut to settle.

Allow Saved Cards

Yes/No. Default: On. Lets customers save cards and pay with them. Needs the embedded card form to add new cards.

Automatic Billing

Yes/No. Default: Off. Daily cron charges the default saved card for due invoices. Needs Allow Saved Cards and the hook file.

Auto-bill Days Before Due

Number. Default: 0. Charge this many days before the due date (0 = on the due date).

Auto-bill Max Attempts

Number. Default: 3. Most automatic attempts per invoice, one per day.

Accent Colour

Text (hex). Default: #2563EB. Colour of the Pay button and the selected option; invalid values fall back to the default.

Revolut API Version

Text. Default: 2024-09-01. Sent in the Revolut-Api-Version header. Change only if Revolut advises.

Convert To For Processing

WHMCS standard. Default: N/A. Charge in another currency; the module converts payments back to the invoice currency.

Show on Order Form / Display Name

WHMCS standard. Default: Shown. Standard WHMCS options (module sets VisibleDefault on).

Webhooks

Backup Payment Confirmation

Webhooks are Revolut’s backup way of telling WHMCS that an order changed, so an invoice is marked Paid even if the customer closes the browser before returning. One click on the admin page registers them.

Registration page

Endpoint: https://<your WHMCS>/modules/gateways/callback/revolut.php (POST).

Registration page: modules/gateways/revolut/webhook-setup.php, opened from the gateway settings. It is admin-only (WHMCS admin login required) and protected by a signed form token.

Shows the environment in use (Production or Sandbox).

Shows whether this WHMCS URL is registered and whether a signing secret is saved.

A Register button creates the webhook in Revolut and saves the returned wsk_... secret into the matching gateway setting.

Lists every webhook on the Revolut account, each with Rotate secret (new secret, saved automatically) and Delete.

Events subscribed: ORDER_COMPLETED, ORDER_AUTHORISED, ORDER_CANCELLED, ORDER_PAYMENT_DECLINED, ORDER_PAYMENT_FAILED.

How each webhook is checked and handled

Reject if no signing secret is configured (HTTP 500, logged).

Verify Revolut-Signature: HMAC-SHA256 of v1.{Revolut-Request-Timestamp}.{raw body} with the signing secret, compared in constant time. Several comma-separated signatures are accepted during secret rotation.

Reject if the timestamp is more than 5 minutes from now (stops replayed requests), or if the signature does not match (HTTP 401, logged).

Ignore events that are not ORDER_* or have no order ID (HTTP 204).

Fetch the order from the Revolut API. Amounts are never taken from the webhook body.

Apply it to the invoice through the same idempotent routine the return page uses.

Reply HTTP 204. On an error, reply HTTP 500 so Revolut retries.

Saved Cards

Saved Cards and Automatic Billing

Revolut stores saved cards. WHMCS only keeps a reference to each one (brand, last 4 digits, expiry and Revolut’s ID), so no card numbers are held on your server.

How a card gets saved

The customer picks New card and leaves "Save this card…" ticked.

The module sends the card to Revolut with savePaymentMethodFor: merchant, so the business can charge it later.

Each order includes the customer as a Revolut customer: an existing customer ID if WHMCS already has one, otherwise their email, name and phone.

After a successful payment, the module reads the customer's saved payment methods from Revolut and syncs them into mod_revolut_paymethods. Cards removed in Revolut are removed locally too.

The first saved card becomes the Default. Every saved card is enabled for auto-billing.

Paying with and removing a saved card

Paying: the customer selects it and presses Pay. The module creates an order for the invoice balance and charges the card as a merchant-initiated payment.

It then checks the result for up to about 12 seconds (6 checks, 2 seconds apart). The customer returns to the invoice with Paid, Processing or Failed.

Removing: "Manage saved cards" shows a Remove link on each card. After the customer confirms, the module deletes the card in Revolut and in WHMCS.

Remove and Pay are POST actions: they work only for the logged-in owner of the invoice and card, and need a signed token.

Automatic billing (daily cron)

Runs on the WHMCS DailyCronJob hook in includes/hooks/revolut_autobill.php when Allow Saved Cards and Automatic Billing are both on.

Picks Unpaid invoices whose payment method is Revolut and whose due date is within "Days Before Due" (at most 200 per run).

Charges the client's default saved card, or else their oldest card enabled for auto-billing.

One attempt per invoice per day, up to "Max Attempts". Every attempt is logged in mod_revolut_autobill_log.

On a failure the client gets the standard WHMCS Credit Card Payment Failed email.

Writes one Activity Log line per run (attempted / paid).

When a WHMCS client is deleted, the ClientDelete hook removes their local card references and Revolut customer mapping.

Admin

Refunds, Transaction Info and Admin Tools

Refunds are issued from the WHMCS invoice with the standard Refund button, in full or in part. The money goes back to the customer’s original payment method.

Refunds (revolut_refund)

Uses the WHMCS transaction ID, which is the Revolut order ID.

Fetches the order first. If the invoice currency differs from the order currency, the amount is converted to the order's currency.

Caps the amount at what is still refundable (order amount minus amounts already refunded).

Sends an Idempotency-Key, so a double-click cannot refund twice.

Calls POST /api/orders/{id}/refund, falling back to /api/1.0/orders/{id}/refund on accounts that only support the older path.

Returns success with the refund order ID, or declined/error with Revolut's response in the Gateway Log.

Other admin tools

Transaction Information (revolut_TransactionInformation): clicking a Revolut transaction in WHMCS 8+/9 shows live data from Revolut: transaction ID, amount, currency, type, state, description, fee, created date, refunded amount, payment method and environment.

Webhook page: register, rotate and delete webhooks.

Compatibility line in the settings box: green "Compatible" or a red warning naming the WHMCS or PHP version found.

Billing → Gateway Log: one entry per event (Success, Payment Declined/Cancelled, Create Order Error, Webhook Rejected, Saved Card Removed, auto-billing errors).

System Logs → Module Log (when module logging is on): every Revolut API request and response, with the secret key masked.

Security

Security Design

Card data never reaches WHMCS, and nothing that arrives from the browser or a webhook is trusted until Revolut’s API confirms it.

Card data exposure

Card entry happens in Revolut’s iframe (embed.js); saved cards live in Revolut. WHMCS stores only brand, last 4, expiry, IDs. Keeps WHMCS out of PCI card-data scope.

Fake or tampered webhooks

HMAC-SHA256 signature check with constant-time compare; 5-minute timestamp window; amounts always re-read from the API.

Fake “payment success” return

The return page fetches the order from Revolut and only marks Paid on a paid state.

Double payments

Atomic “applied” flag per order plus a check of existing WHMCS transactions; refunds send an Idempotency-Key.

Charging someone else’s card

Saved-card Pay/Remove need the logged-in owner of both invoice and card, a POST, and an HMAC token tied to invoice + client + card.

Accidental auto-charge on checkout

No <form> elements in the panel, so WHMCS’s “forwarding to gateway” can never submit a saved-card charge by itself.

Admin page abuse

Webhook page requires a WHMCS admin session plus a signed form token.

Token secret leakage

Action tokens use a random 256-bit secret stored in tblconfiguration (G44RevolutActionSecret), not configuration.php values.

Secret keys in logs

Module Log masks the API secret key.

Script injection in the panel

All output HTML-escaped; JSON config uses hex-escaping for tags, quotes and ampersands; accent colour validated as hex.

Errors leaking details

Customers see a short generic message; technical details go to the Gateway Log only.

Outdated platform

Payments are disabled automatically on WHMCS < 9.1 or PHP < 8.3.

Technical Reference

Files and Database Tables

The module has seven PHP files, one hook file and four database tables. Classes live in the G44\Revolut namespace.

 

I would like to know if anyone interested in this.

 

g44-rv-hosted-checkout.png

g44-rv-mobile.png

g44-rv-manage-cards.png

g44-rv-saved-card.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated