Building an app that needs to accept payments? Choosing the right payment API is crucial for your business. This guide compares the 10 best payment APIs for developers in 2026, with code examples, pricing, and integration tips.
Quick Comparison Table
| Provider | Transaction Fee | Free Tier | Best For |
|---|---|---|---|
| Stripe | 2.9% + $0.30 | Yes | Developers |
| PayPal | 2.9% + $0.30 | Yes | Consumer trust |
| Square | 2.6% + $0.10 | Yes | In-person + online |
| Braintree | 2.59% + $0.49 | Yes | PayPal integration |
| Adyen | 0.6% + $0.12 | No | Enterprise |
| Razorpay | 2% | Yes | India |
| Mollie | 1.8% + €0.25 | Yes | Europe |
| Paddle | 5% + $0.50 | No | SaaS/digital |
| LemonSqueezy | 5% + $0.50 | No | Indie devs |
| Coinbase Commerce | 1% | Yes | Crypto |
1. Stripe API
Stripe is the most popular payment API for developers, known for its excellent documentation and developer experience.
Pricing:
- 2.9% + $0.30 per transaction
- No monthly fees
- No setup fees
- Custom pricing for large volume
Key Features:
- Accept cards, wallets, bank transfers
- Subscriptions and invoicing
- Connect (marketplace payments)
- Radar (fraud detection)
- Terminal (in-person payments)
- 135+ currencies
JavaScript Example (Checkout Session):
const stripe = require('stripe')('sk_test_xxx');
async function createCheckoutSession(priceId, customerId) {
const session = await stripe.checkout.sessions.create({
customer: customerId,
payment_method_types: ['card'],
line_items: [
{
price: priceId,
quantity: 1
}
],
mode: 'payment', // or 'subscription'
success_url: 'https://yoursite.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://yoursite.com/cancel'
});
return session.url;
}
// Usage
const checkoutUrl = await createCheckoutSession('price_xxx', 'cus_xxx');
console.log('Redirect to:', checkoutUrl);
Payment Intent (Custom UI):
// Server-side: Create Payment Intent
async function createPaymentIntent(amount, currency = 'usd') {
const paymentIntent = await stripe.paymentIntents.create({
amount: amount * 100, // Amount in cents
currency,
automatic_payment_methods: { enabled: true }
});
return {
clientSecret: paymentIntent.client_secret
};
}
// Client-side: Confirm payment
import { loadStripe } from '@stripe/stripe-js';
const stripe = await loadStripe('pk_test_xxx');
async function handlePayment(clientSecret) {
const { error, paymentIntent } = await stripe.confirmCardPayment(
clientSecret,
{
payment_method: {
card: cardElement,
billing_details: {
name: 'John Doe',
email: 'john@example.com'
}
}
}
);
if (error) {
console.error('Payment failed:', error.message);
} else if (paymentIntent.status === 'succeeded') {
console.log('Payment successful!');
}
}
Subscriptions:
async function createSubscription(customerId, priceId) {
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{ price: priceId }],
payment_behavior: 'default_incomplete',
payment_settings: {
save_default_payment_method: 'on_subscription'
},
expand: ['latest_invoice.payment_intent']
});
return {
subscriptionId: subscription.id,
clientSecret: subscription.latest_invoice.payment_intent.client_secret
};
}
Best For: Developers wanting full control and excellent documentation.
2. PayPal API
PayPal is trusted by millions of consumers worldwide, making it essential for many businesses.
Pricing:
- 2.9% + $0.30 per transaction
- Lower rates for nonprofits
- No monthly fees
Key Features:
- PayPal button and checkout
- Venmo integration
- Pay Later options
- Seller protection
- Global reach (200+ markets)
- Invoicing
JavaScript Example (PayPal Buttons):
<!-- Include PayPal SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID"></script>
<div id="paypal-button-container"></div>
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '99.99',
currency_code: 'USD'
},
description: 'Premium Subscription'
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
console.log('Payment completed by', details.payer.name.given_name);
// Call your server to save the transaction
fetch('/api/paypal/capture', {
method: 'POST',
body: JSON.stringify({ orderId: data.orderID })
});
});
},
onError: function(err) {
console.error('PayPal error:', err);
}
}).render('#paypal-button-container');
</script>
Server-Side Order Creation:
const paypal = require('@paypal/checkout-server-sdk');
// Configure PayPal environment
const environment = new paypal.core.SandboxEnvironment(
'CLIENT_ID',
'CLIENT_SECRET'
);
const client = new paypal.core.PayPalHttpClient(environment);
async function createOrder(amount) {
const request = new paypal.orders.OrdersCreateRequest();
request.prefer('return=representation');
request.requestBody({
intent: 'CAPTURE',
purchase_units: [{
amount: {
currency_code: 'USD',
value: amount.toString()
}
}]
});
const response = await client.execute(request);
return response.result.id;
}
async function captureOrder(orderId) {
const request = new paypal.orders.OrdersCaptureRequest(orderId);
const response = await client.execute(request);
return response.result;
}
Best For: Consumer-facing apps needing trusted checkout.
3. Square API
Square excels at both online and in-person payments with excellent hardware integration.
Pricing:
- Online: 2.9% + $0.30
- In-person: 2.6% + $0.10
- No monthly fees
Key Features:
- Online and in-person payments
- POS hardware
- Invoicing
- Subscriptions
- Inventory management
- Loyalty programs
JavaScript Example:
const { Client, Environment } = require('square');
const client = new Client({
accessToken: 'YOUR_ACCESS_TOKEN',
environment: Environment.Sandbox
});
async function createPayment(sourceId, amount, currency = 'USD') {
const paymentsApi = client.paymentsApi;
try {
const response = await paymentsApi.createPayment({
sourceId: sourceId, // Card nonce from frontend
idempotencyKey: crypto.randomUUID(),
amountMoney: {
amount: BigInt(amount * 100), // Amount in cents
currency
},
autocomplete: true
});
return response.result.payment;
} catch (error) {
console.error('Payment failed:', error);
throw error;
}
}
Web Payment Form:
<script src="https://sandbox.web.squarecdn.com/v1/square.js"></script>
<form id="payment-form">
<div id="card-container"></div>
<button type="submit">Pay $99.99</button>
</form>
<script>
async function initializeCard(payments) {
const card = await payments.card();
await card.attach('#card-container');
return card;
}
async function handlePayment(card) {
const result = await card.tokenize();
if (result.status === 'OK') {
// Send result.token to your server
const response = await fetch('/api/square/pay', {
method: 'POST',
body: JSON.stringify({ sourceId: result.token, amount: 99.99 })
});
return response.json();
}
}
// Initialize
const payments = Square.payments('APPLICATION_ID', 'LOCATION_ID');
const card = await initializeCard(payments);
document.getElementById('payment-form').addEventListener('submit', async (e) => {
e.preventDefault();
await handlePayment(card);
});
</script>
Best For: Businesses with both online and physical presence.
4. Braintree API
Braintree (owned by PayPal) offers a unified platform for cards, PayPal, and Venmo.
Pricing:
- 2.59% + $0.49 per transaction
- No monthly fees
- Custom pricing available
Key Features:
- Drop-in UI
- PayPal, Venmo, cards
- 3D Secure
- Vault for storing cards
- Recurring billing
- Marketplace payments
JavaScript Example:
const braintree = require('braintree');
const gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.Sandbox,
merchantId: 'YOUR_MERCHANT_ID',
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY'
});
// Generate client token for frontend
async function generateClientToken(customerId = null) {
const options = customerId ? { customerId } : {};
const response = await gateway.clientToken.generate(options);
return response.clientToken;
}
// Process payment
async function createTransaction(nonce, amount) {
const result = await gateway.transaction.sale({
amount: amount,
paymentMethodNonce: nonce,
options: {
submitForSettlement: true
}
});
if (result.success) {
return result.transaction;
} else {
throw new Error(result.message);
}
}
Drop-in UI:
<script src="https://js.braintreegateway.com/web/dropin/1.33.7/js/dropin.min.js"></script>
<div id="dropin-container"></div>
<button id="submit-button">Pay</button>
<script>
braintree.dropin.create({
authorization: 'CLIENT_TOKEN_FROM_SERVER',
container: '#dropin-container',
paypal: {
flow: 'checkout',
amount: '99.99',
currency: 'USD'
},
venmo: {}
}, function (err, instance) {
document.getElementById('submit-button').addEventListener('click', function () {
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.error(err);
return;
}
// Send payload.nonce to your server
fetch('/api/braintree/checkout', {
method: 'POST',
body: JSON.stringify({ nonce: payload.nonce, amount: 99.99 })
});
});
});
});
</script>
Best For: Apps wanting PayPal + cards in one integration.
5. Adyen API
Adyen is an enterprise-grade payment platform used by Netflix, Uber, and Spotify.
Pricing:
- Processing: ~0.6% + $0.12
- Interchange++: Pass-through pricing
- Monthly minimum applies
Key Features:
- 250+ payment methods
- Global acquiring
- Risk management
- Terminal integration
- Unified commerce
- Real-time data
JavaScript Example:
const { Client, Config, CheckoutAPI } = require('@adyen/api-library');
const config = new Config();
config.apiKey = 'YOUR_API_KEY';
config.merchantAccount = 'YOUR_MERCHANT_ACCOUNT';
const client = new Client({ config });
client.setEnvironment('TEST');
const checkout = new CheckoutAPI(client);
async function createPaymentSession(amount, currency, returnUrl) {
const response = await checkout.PaymentsApi.sessions({
amount: {
value: amount * 100,
currency
},
returnUrl,
reference: `order-${Date.now()}`,
merchantAccount: config.merchantAccount
});
return response;
}
Best For: Enterprise businesses with complex payment needs.
6. Razorpay API
Razorpay is India's leading payment gateway with comprehensive features.
Pricing:
- 2% per transaction
- No setup fees
- No monthly fees
Key Features:
- UPI, cards, wallets, netbanking
- Subscriptions
- Payment links
- Route (split payments)
- Invoicing
- India-focused
JavaScript Example:
const Razorpay = require('razorpay');
const razorpay = new Razorpay({
key_id: 'YOUR_KEY_ID',
key_secret: 'YOUR_KEY_SECRET'
});
async function createOrder(amount, currency = 'INR') {
const order = await razorpay.orders.create({
amount: amount * 100, // Amount in paise
currency,
receipt: `receipt_${Date.now()}`
});
return order;
}
<!-- Frontend -->
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
const options = {
key: 'YOUR_KEY_ID',
amount: 50000, // 500 INR in paise
currency: 'INR',
name: 'Your Company',
description: 'Product Purchase',
order_id: 'ORDER_ID_FROM_SERVER',
handler: function (response) {
// Verify payment on server
fetch('/api/razorpay/verify', {
method: 'POST',
body: JSON.stringify({
razorpay_order_id: response.razorpay_order_id,
razorpay_payment_id: response.razorpay_payment_id,
razorpay_signature: response.razorpay_signature
})
});
},
prefill: {
name: 'John Doe',
email: 'john@example.com',
contact: '9999999999'
}
};
const rzp = new Razorpay(options);
rzp.open();
</script>
Best For: Businesses targeting Indian customers.
7. Mollie API
Mollie is a European payment processor with excellent UX and competitive pricing.
Pricing:
- Cards: 1.8% + €0.25
- iDEAL: €0.29
- No monthly fees
Key Features:
- European payment methods
- iDEAL, Bancontact, SOFORT
- Subscriptions
- Refunds API
- Multi-currency
- GDPR compliant
JavaScript Example:
const { createMollieClient } = require('@mollie/api-client');
const mollie = createMollieClient({ apiKey: 'test_xxx' });
async function createPayment(amount, description, redirectUrl) {
const payment = await mollie.payments.create({
amount: {
currency: 'EUR',
value: amount.toFixed(2)
},
description,
redirectUrl,
webhookUrl: 'https://yoursite.com/webhooks/mollie'
});
return payment.getCheckoutUrl();
}
// Usage
const checkoutUrl = await createPayment(29.99, 'Order #12345', 'https://yoursite.com/success');
Best For: European businesses, especially Netherlands/Belgium.
8. Paddle
Paddle is a merchant of record handling taxes, invoicing, and compliance for SaaS businesses.
Pricing:
- 5% + $0.50 per transaction
- Handles all taxes and compliance
Key Features:
- Merchant of record
- Global tax handling
- Subscription management
- License key generation
- Checkout overlay
- PayPal included
JavaScript Example:
<script src="https://cdn.paddle.com/paddle/v2/paddle.js"></script>
<script>
Paddle.Initialize({
token: 'YOUR_CLIENT_TOKEN'
});
async function openCheckout(priceId) {
Paddle.Checkout.open({
items: [{ priceId, quantity: 1 }],
customer: {
email: 'customer@example.com'
},
customData: {
userId: '12345'
}
});
}
</script>
<button onclick="openCheckout('pri_xxx')">Subscribe - $29/mo</button>
Best For: SaaS businesses wanting to avoid tax headaches.
9. LemonSqueezy
LemonSqueezy is a Paddle alternative focused on indie developers and creators.
Pricing:
- 5% + $0.50 per transaction
- Handles taxes globally
Key Features:
- Merchant of record
- License keys
- Discount codes
- Affiliate system
- Digital downloads
- Simple dashboard
JavaScript Example:
<script src="https://app.lemonsqueezy.com/js/lemon.js" defer></script>
<a href="https://yourstore.lemonsqueezy.com/checkout/buy/xxx" class="lemonsqueezy-button">
Buy Now - $49
</a>
API Example:
async function createCheckout(variantId, email) {
const response = await fetch('https://api.lemonsqueezy.com/v1/checkouts', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: {
type: 'checkouts',
attributes: {
checkout_data: {
email,
custom: { user_id: '12345' }
}
},
relationships: {
store: { data: { type: 'stores', id: 'STORE_ID' } },
variant: { data: { type: 'variants', id: variantId } }
}
}
})
});
const data = await response.json();
return data.data.attributes.url;
}
Best For: Indie hackers and digital product creators.
10. Coinbase Commerce
Coinbase Commerce enables cryptocurrency payments for your business.
Pricing:
- 1% per transaction
- No chargebacks
- Instant settlement option
Key Features:
- Bitcoin, Ethereum, USDC, etc.
- No volatility (convert instantly)
- Hosted checkout
- Embedded checkout
- Webhook notifications
- No chargebacks
JavaScript Example:
const { Client, resources, Webhook } = require('coinbase-commerce-node');
Client.init('YOUR_API_KEY');
async function createCharge(amount, name, description) {
const charge = await resources.Charge.create({
name,
description,
pricing_type: 'fixed_price',
local_price: {
amount: amount.toString(),
currency: 'USD'
},
metadata: {
customer_id: '12345',
order_id: 'order_xxx'
}
});
return charge.hosted_url;
}
// Webhook handler
app.post('/webhooks/coinbase', (req, res) => {
const signature = req.headers['x-cc-webhook-signature'];
const event = Webhook.verifyEventBody(
req.rawBody,
signature,
'WEBHOOK_SECRET'
);
if (event.type === 'charge:confirmed') {
// Payment confirmed
const { metadata } = event.data;
fulfillOrder(metadata.order_id);
}
res.sendStatus(200);
});
Best For: Accepting crypto payments with instant USD conversion.
Payment Webhook Best Practices
Always verify webhooks to prevent fraud:
// Stripe webhook verification
const endpointSecret = 'whsec_xxx';
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
} catch (err) {
console.log('Webhook signature verification failed');
return res.status(400).send(`Webhook Error: ${err.message}`);
}
switch (event.type) {
case 'payment_intent.succeeded':
const payment = event.data.object;
fulfillOrder(payment.metadata.order_id);
break;
case 'payment_intent.payment_failed':
notifyCustomer(event.data.object);
break;
}
res.json({ received: true });
});
Choosing the Right Payment API
| Need | Recommended |
|---|---|
| Best developer experience | Stripe |
| Consumer trust | PayPal |
| Online + In-person | Square |
| Europe | Mollie |
| India | Razorpay |
| SaaS with tax handling | Paddle / LemonSqueezy |
| Enterprise | Adyen |
| Crypto | Coinbase Commerce |
Conclusion
For most developers, Stripe offers the best combination of features, documentation, and developer experience. If you need PayPal acceptance, consider Braintree for a unified solution. For SaaS businesses wanting to avoid tax compliance, Paddle or LemonSqueezy handle everything for you.
Related Resources: