3 min read Updated

CPay PHP SDK

Accept USDT and USDC on any PHP website — a custom store, a SaaS billing page or a framework app. The SDK creates signed invoices on your server, sends the customer to the secure payment page and verifies the payment proof when the money arrives. Funds go straight to your wallet; nobody holds them in between.

Package
dappcrypto/cpay (Composer)
Requirements
PHP 8.0 or newer
Wallets
MetaMask, Trust Wallet
Currencies
USDT, USDC, ETH, BNB
Networks
Ethereum, BNB Smart Chain and more
License
MIT, open source

Why merchants choose it

  • No KYC / no KYB. Your wallet address is your shop — no documents, no approval, no account freezes.
  • Self-custody. Payments land in your own wallet the moment they are confirmed on-chain.
  • Invoices signed locally. The signing key stays on your server and is never sent anywhere.
  • Cryptographic confirmation. A webhook brings a proof you verify with one call — no trust in plain request parameters.
  • AML check. The payer's wallet is screened before the payment.
  • Small and open. One Composer package, MIT license, readable source code.

How it works

  1. Your server creates an invoice

    The SDK builds the invoice — order number, amount in USDT/USDC, start and deadline — and signs it with your shop account key.

  2. The customer pays

    You redirect the customer to the payment link. They pay from MetaMask or Trust Wallet on the network they choose.

  3. The payment is confirmed

    The payment service calls your webhook with a proof and sends the customer back to your success page.

  4. You fulfil the order

    getWebhook() or getOrderData() verifies the proof. Mark the order as paid and ship.

Quick start

  1. Create a shop

    Make a new MetaMask account just for the shop. With it, create a shop at dappcrypto.github.io on every network you want to accept, and set the webhook and success page URLs.

  2. Install the package

    Run composer require dappcrypto/cpay in your project.

  3. Create invoices at checkout

    Call CPay::instance()->createInvoice() with the shop address, your payout wallet, the order number and the amount. Redirect the customer to LinkInvoice from the result.

  4. Handle the webhook

    On the webhook URL call CPay::instance()->getWebhook($aRecipient). When error is 0, the order in orderData.nOrder is paid.

  5. Double-check on the success page

    If the customer returns before the webhook arrives, call getOrderData($aRecipient, $nOrder) to confirm the payment.

The README on GitHub has complete, copy-ready examples for each step: invoice creation, the webhook page and the success page.

Invoice fields

FieldWhat it means
aRecipientAddress of the shop account that registered the shop and signs invoices.
aRecipientExtYour payout wallet that receives USDT/USDC. Must be a different wallet.
nOrderYour order ID. Must be unique for the shop.
nRTokenAmount in USDT/USDC, for example 1.50.
nRTypeReceive token type: 1 — USDT/USDC.
start, deadlineValidity of the invoice as UTC Unix timestamps.
nTax2, aTax2Optional partner commission: 100 = 1% to the aTax2 wallet.

Two wallets, always

Use a separate shop account only to register and manage the shop and to sign invoices. Receive money on a different wallet whose private key you never put on a server. Mixing them can lead to loss of funds.

Keep the key out of your code

Store the shop account key in an environment variable or server config, never in a public repository or front-end code.

Supported networks

  • Ethereum gas in ETH
  • BNB Smart Chain gas in BNB
  • Arbitrum gas in ETH
  • Base gas in ETH
  • Polygon gas in POL

Smart contract

Payment gateway (CPays)

Registers shops, accepts signed invoices, swaps the payment token and issues on-chain receipts.

FAQ

Do I need a merchant account or an API key?

No. A CPay shop is created from your wallet in one transaction. The SDK needs only the shop account key to sign invoices.

What does it cost?

The SDK is free and open source. 99% of every payment goes to you and 1% is the DAppCrypto service fee; connecting a shop costs a one-time network fee.

Which PHP frameworks are supported?

Any. The SDK is a plain Composer package that works with Laravel, Symfony, WordPress, custom code and anything else on PHP 8.0+.

My store runs on a CMS. Do I need to code?

Not for OpenCart and WooCommerce — use the ready-made OpenCart extension or WooCommerce plugin. Both already bundle the SDK.

Start with a shopThe SDK signs invoices for a CPay shop. Create one with a dedicated MetaMask account, then use its key in the SDK.

Create your shop