Introduction
With the rise of cryptocurrencies, integrating crypto payments into web applications offers businesses faster transactions, lower fees, and global reach. This guide will show you how to accept Bitcoin (BTC), Ethereum (ETH), USDT, and other cryptocurrencies using MetaMask, Stripe Crypto, and third-party APIs.
What You’ll Learn
✔ How to integrate MetaMask for Ethereum-based payments
✔ How to use Stripe Crypto for simple crypto transactions
✔ How to implement Web3.js and Ethers.js for blockchain payments
✔ How to process payments in Bitcoin, USDT, and stablecoins
- Choosing the Right Crypto Payment Method
There are several ways to accept crypto payments in a web app:
1.1 Using MetaMask for Ethereum & ERC-20 Payments
Best for decentralized apps (dApps)
Supports ETH, USDT, DAI, and ERC-20 tokens
Works directly with smart contracts
1.2 Using Stripe Crypto for Mainstream Payments
Best for e-commerce and traditional businesses
Supports USDC, BTC, ETH, and stablecoins
Fiat conversion available
1.3 Using Payment Gateways like CoinGate or NowPayments
Accepts multiple cryptocurrencies
Auto-converts crypto to fiat (USD, EUR, NGN, etc.)
API integration for easy checkout
- Accepting Crypto Payments with MetaMask (Ethereum & ERC-20 Tokens)
Step 1: Install Web3.js or Ethers.js
npm install web3 ethers
Step 2: Connect MetaMask to Your Web App
Modify App.js:
import { useState } from "react";
import { ethers } from "ethers";
function App() {
const [account, setAccount] = useState("");
async function connectWallet() {
if (window.ethereum) {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const accounts = await provider.send("eth_requestAccounts", []);
setAccount(accounts[0]);
} else {
alert("MetaMask not detected");
}
}
return (
<div>
<button onClick={connectWallet}>Connect Wallet</button>
<p>Connected Account: {account}</p>
</div>
);
}
export default App;
- Sending Crypto Payments with MetaMask
Step 1: Create a Send Payment Function
async function sendCrypto(recipient, amount) {
if (!window.ethereum) return alert("MetaMask not detected");
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const tx = await signer.sendTransaction({
to: recipient,
value: ethers.utils.parseEther(amount),
});
await tx.wait();
alert("Transaction successful!");
}
Step 2: Add a Payment Button
<button onClick={() => sendCrypto("0xRecipientAddress", "0.01")}>
Pay with Crypto
</button>
- Accepting Bitcoin & Stablecoins Using Stripe Crypto
Step 1: Sign Up for Stripe
Go to Stripe Crypto
Get your API keys
Step 2: Install Stripe SDK
npm install @stripe/stripe-js
Step 3: Create a Payment Button
Modify App.js:
import { loadStripe } from "@stripe/stripe-js";
const stripePromise = loadStripe("YOUR_STRIPE_PUBLIC_KEY");
async function handlePayment() {
const stripe = await stripePromise;
const response = await fetch("/create-checkout-session", {
method: "POST",
});
const session = await response.json();
const result = await stripe.redirectToCheckout({ sessionId: session.id });
if (result.error) {
alert(result.error.message);
}
}
return <button onClick={handlePayment}>Pay with Stripe Crypto</button>;
Step 4: Backend Route for Checkout Session
Modify server.js:
const express = require("express");
const Stripe = require("stripe");
const app = express();
const stripe = new Stripe("YOUR_STRIPE_SECRET_KEY");
app.post("/create-checkout-session", async (req, res) => {
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card", "crypto"],
line_items: [
{
price_data: {
currency: "usd",
product_data: { name: "Crypto Payment" },
unit_amount: 1000,
},
quantity: 1,
},
],
mode: "payment",
success_url: "https://your-site.com/success",
cancel_url: "https://your-site.com/cancel",
});
res.json({ id: session.id });
});
app.listen(3000, () => console.log("Server running on port 3000"));
- Accepting Multiple Cryptocurrencies with Payment APIs
If you want to accept BTC, ETH, USDT, BNB, and other cryptos, use platforms like:
CoinGate (coingate.com)
NowPayments (nowpayments.io)
Example API Request for NowPayments
curl -X POST https://api.nowpayments.io/v1/invoice \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"price_amount": 50,
"price_currency": "usd",
"pay_currency": "btc",
"order_id": "12345",
"order_description": "Crypto Payment"
}'
- Converting Crypto to Fiat
To convert received crypto into USD or NGN, use:
✔ Binance Pay – Auto-converts payments to fiat
✔ Coinbase Commerce – Crypto payments with fiat withdrawal
✔ BitPay – Accepts BTC & USDT, converts to USD/EUR
- Deploying the Web App
Step 1: Deploy to Vercel or Netlify
npm run build
vercel deploy
Step 2: Deploy Backend on Railway or Render
git push heroku main
Conclusion
We successfully implemented crypto payments using:
✔ MetaMask for Ethereum & ERC-20 tokens
✔ Stripe Crypto for mainstream businesses
✔ NowPayments & CoinGate for multiple currencies
✔ Fiat conversion solutions like Binance Pay & BitPay
Adding crypto payments can make your app global, secure, and future-proof.
💡 I'm open for collaboration! If you’re working on a crypto payment integration, dApp, or Web3 project, let’s connect and build something amazing! 🚀
Top comments (0)