Adding a crypto payment option to XenForo user upgrades
Selling user upgrades on a XenForo forum usually means PayPal or Stripe. If your members would rather pay in USDT or Bitcoin, XenForo's payment profiles make it fairly painless to add a crypto option. This walks through
Selling user upgrades on a XenForo forum usually means PayPal or Stripe. If your members would rather pay in USDT or Bitcoin, XenForo's payment profiles make it fairly painless to add a crypto option. This walks through our free add-on. Disclosure: we build Plaxswap, so the add-on is ours.
Requirements
- XenForo 2.3
- PHP 7.2 or newer with OpenSSL
- HTTPS and a public callback URL for a live forum
- A Plaxswap merchant account (sign in with Google or Telegram, then set up an authenticator app)
It works with one-time purchases that go through payment profiles, such as user upgrades. Recurring upgrades aren't supported, and guests can't pay.
Cost: your member pays a 1.5% platform fee at checkout, so about $100 reaches your balance on a $100 upgrade. You pay 0.3% plus the network fee when you withdraw. Details are on the fees page.
Install
Download the add-on from xenforo.com and back up your forum first. In the Admin CP go to Add-ons > Install/upgrade from archive and upload the ZIP. Later versions upgrade the same way.
Keys, secret and callback
In the merchant dashboard:
-
Developers > API keys > New key, choose Test, then Create test key. It starts with
pxs_test_and you only see it once. -
Developers > Webhooks > Make a new secret. It starts with
whsec_, also shown once.
In the Admin CP, open Setup > Payment profiles, add Plaxswap Crypto Payment Gateway, paste the key and the secret, and save.
Reopen the profile and copy its callback URL. It looks like this:
https://forum.example/payment_callback.php?_xfProvider=plaxswap_gateway&profile_id=1
Paste it under Webhooks > Add URL in the dashboard. Switch the dashboard to Test, press Send test, and check that Delivery history says Delivered.
Test a purchase
Attach the profile to a one-time user upgrade and buy it as a forum administrator. With a test key saved, only administrators can pay, so a simulated payment can never hand out real access. Act out a payment on the test checkout, then look at Payments & tracking in the Admin CP.
Once that works, make a live key (pxs_live_) in the same account, paste it into the profile and do one small real payment.
How a purchase gets activated
The add-on doesn't trust a member returning from checkout, and it doesn't trust the webhook body by itself either. A signed webhook makes it ask the API about the payment, and it checks the invoice, amount, currency and mode before doing anything.
| Payment | Purchase |
|---|---|
| Waiting for the member | Not active |
| Seen on the network, confirming | Not active |
| Short by no more than your allowance | Active (default allowance 0.5%, can go up to 10%) |
| Short by more than your allowance | Not active, waits |
| Paid and verified | Active, once |
| Expired, cancelled or failed | Not active |
| Paid up to 24 hours late | Active after verification |
If a webhook goes missing, the add-on's cron picks it up: every run in the first hour, every 10 minutes for about a day, then hourly for up to 30 days. So make sure XenForo's scheduled jobs actually run.
Gotchas
- Credentials are encrypted with your
globalSalt, so back upsrc/config.phpand the database together. - A merchant account has one webhook URL. If you run two forums, plan for that.
- Refunds are manual. Send the coins back yourself and remove the upgrade in XenForo.
- Uninstalling deletes the add-on's invoice table, so back up first. Disabling it keeps the history.
- A swap partner key (
pxk_) won't work here; it has to be apxs_test_orpxs_live_key.
The full guide is at plaxswap.com/integrations/xenforo. If you also bill hosting clients, there's a WHMCS module, and the crypto payment gateway page covers the API and payment links.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.