XPay4u

Merchant guide

Add XPay4u to your website

Pick the path that fits how your site is built. Every path follows one rule: send the customer to pay, and mark the order paid only after a signed webhook says so.

1 Create payment2 Customer pays3 Signed webhook4 Mark order paid
Easiest

1-file PHP kit

One file to upload and four settings to fill in. No installs, no database changes to start.

HostingercPanelPlain PHP

PHP 7.4+ · 1 file · 3 KB

What is inside
  • xpay4u.php
  • example-checkout.php
  • README.txt
Setup in 5 steps
  1. Upload xpay4u.php to your site.
  2. Fill in the four settings at the top.
  3. Set the webhook address below in your dashboard.
  4. Call xpay4u_pay() from your checkout.
  5. Edit xpay4u_on_paid() to mark the order paid.
Webhook address
https://yourstore.com/xpay4u.php?action=webhook
Download 1-file kitxpay4u-one-file-php-kit.zip · 3 KB
Developer

Full PHP SDK

A small client class with separate checkout, thank-you and webhook files, plus a working demo store.

Custom PHP sitesTeamsLearning the flow

PHP 8.0+ · 10 files · 6 KB

What is inside
  • src/Xpay4u.php
  • checkout.php
  • webhook.php
  • thanks.php
  • index.php (demo store)
  • config.php
Setup in 5 steps
  1. Upload the xpay4u_merchant_sdk folder.
  2. Edit config.php.
  3. Set the webhook address below in your dashboard.
  4. Buy something in the demo store and pay.
  5. Swap the demo storage for your database.
Webhook address
https://yourstore.com/xpay4u_merchant_sdk/webhook.php
Download full SDKxpay4u-merchant-sdk.zip · 6 KB
WordPress

WooCommerce plugin

Adds XPay4u as a payment method at checkout. Orders go to Processing by themselves once the money arrives.

WooCommerce storesWordPress 5.8+

PHP 7.4+ · Store currency PHP · 3 KB

What is inside
  • xpay4u-woocommerce.php
  • readme.txt
Setup in 5 steps
  1. Plugins, Add New, Upload Plugin, choose the zip.
  2. Activate, then open WooCommerce, Settings, Payments.
  3. Enter your address, secret key and webhook secret.
  4. Set the webhook address below in your dashboard.
  5. Run a real test checkout.
Webhook address
https://yourstore.com/wp-json/xpay4u/v1/webhook
Download WooCommerce pluginxpay4u-woocommerce.zip · 3 KB
Advanced

Direct API

Two calls and one webhook route. Works with anything that can send an HTTPS request and check an HMAC.

LaravelNodePythonBilling systems

Any language · No download

What you call
  • POST /api/v1/sessions
  • GET /api/v1/sessions/:id
  • Signed webhook
Setup in 5 steps
  1. Create a payment from your server.
  2. Redirect the customer to pay_url.
  3. Receive the signed webhook.
  4. Verify the HMAC with your webhook secret.
  5. Mark your order paid by its reference.
Webhook address
https://yourstore.com/api/xpay4u/webhook
Jump to the codeNode, PHP and Python samples

What you need first

Every path asks for the same three things.

Setup checklist

Do these once, in this order.

  1. Create your account and confirm your email
  2. Pair your Android phone with the XPay4u app
  3. Upload your GCash or Maya QR and switch the wallet on
  4. Create a secret API key and keep it on your server
  5. Set a webhook address that is public, not localhost
  6. Copy the webhook signing secret into your server settings
  7. Add one of the paths A to D
  8. Take a small test payment from another wallet

Path D in code

1. Create a payment

Run this on your server when the customer checks out. Use a new reference for every order.

const res = await fetch("https://xpay4u.onrender.com/api/v1/sessions", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.XPAY4U_SECRET_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    amount: 500,
    reference: "ORDER-1042",
    return_url: "https://yourstore.com/thanks",
  }),
});
const { pay_url } = await res.json();
// send the customer to pay_url

2. Verify the webhook

Read the raw body before any JSON parsing. The signature covers the timestamp, a dot and the raw body.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyWebhook(rawBody, headers, secret) {
  const ts = headers["x-timestamp"];
  const sig = headers["x-signature"] ?? "";
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const want = createHmac("sha256", secret).update(ts + "." + rawBody).digest("hex");
  return sig.length === want.length && timingSafeEqual(Buffer.from(sig), Buffer.from(want));
}

The most important rule

The thank-you page is a web address anyone can open. Never mark an order paid because someone reached it. Only a verified webhook, or a server-side check of the payment with your secret key, can confirm the money arrived.

Customer checks out
  -> your server creates the payment
  -> customer is sent to the XPay4u pay page
  -> customer pays the exact amount
  -> XPay4u sends a signed webhook to your server
  -> your server verifies it and marks the order paid
  -> the thank-you page only shows the result

Webhook quick test

The webhook address must be reachable from the internet. localhost will not work, since XPay4u cannot reach your computer. While building, a tunnel tool such as ngrok or Cloudflare Tunnel can give your local server a public address.

Final testing checklist

  • A new order is saved as unpaid before the customer is sent to pay.
  • The customer lands on the XPay4u page and sees the exact amount, centavos included.
  • The page turns green a few seconds after the wallet sends the money.
  • Your webhook endpoint answers 200 to a signed request.
  • A request with a wrong signature is refused.
  • The same webhook delivered twice does not mark the order paid twice.
  • Opening the thank-you page without paying does not mark the order paid.
  • Nothing in the browser holds your secret key.
Stuck on a step?The setup guide covers the phone and wallet side. The API docs list every field and error.
Add XPay4u to your website | XPay4u