DEV Community

Alex Spinov
Alex Spinov

Posted on

Stripe Has a Free API — Accept Payments, Manage Subscriptions, and Build Checkout in Minutes

Stripe's API is free to integrate — you only pay when you process real transactions (2.9% + 30 cents per charge). The test mode gives you unlimited API calls with fake credit cards, so you can build and test your entire payment system without spending a cent.

Here's how to start building with it.

Get Your Free API Keys

  1. Create a free account at dashboard.stripe.com
  2. Go to Developers → API keys
  3. Copy your test mode keys (start with sk_test_ and pk_test_)

Test mode = unlimited free API calls with test card numbers.

1. Create a Payment Intent

curl https://api.stripe.com/v1/payment_intents \
  -u sk_test_YOUR_KEY: \
  -d amount=2000 \
  -d currency=usd \
  -d "payment_method_types[]"=card
Enter fullscreen mode Exit fullscreen mode

This creates a $20.00 payment intent. The client_secret in the response is used by your frontend to complete the payment.

2. Create a Customer

curl https://api.stripe.com/v1/customers \
  -u sk_test_YOUR_KEY: \
  -d email="customer@example.com" \
  -d name="Jane Doe"
Enter fullscreen mode Exit fullscreen mode

3. Create a Subscription

# First create a product and price
curl https://api.stripe.com/v1/products \
  -u sk_test_YOUR_KEY: \
  -d name="Pro Plan"

curl https://api.stripe.com/v1/prices \
  -u sk_test_YOUR_KEY: \
  -d product=prod_XXXXX \
  -d unit_amount=1999 \
  -d currency=usd \
  -d "recurring[interval]"=month

# Then create the subscription
curl https://api.stripe.com/v1/subscriptions \
  -u sk_test_YOUR_KEY: \
  -d customer=cus_XXXXX \
  -d "items[0][price]"=price_XXXXX
Enter fullscreen mode Exit fullscreen mode

4. Python — Payment Processing

import stripe

stripe.api_key = "sk_test_YOUR_KEY"

def create_checkout_session(price_cents, product_name):
    session = stripe.checkout.Session.create(
        payment_method_types=["card"],
        line_items=[{
            "price_data": {
                "currency": "usd",
                "product_data": {"name": product_name},
                "unit_amount": price_cents,
            },
            "quantity": 1,
        }],
        mode="payment",
        success_url="https://yoursite.com/success",
        cancel_url="https://yoursite.com/cancel",
    )
    return session.url

# Create a $29.99 checkout link
url = create_checkout_session(2999, "Premium Report")
print(f"Pay here: {url}")
Enter fullscreen mode Exit fullscreen mode

5. Node.js — Webhook Handler

const stripe = require("stripe")("sk_test_YOUR_KEY");

// Express webhook endpoint
app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const event = stripe.webhooks.constructEvent(
    req.body,
    req.headers["stripe-signature"],
    "whsec_YOUR_WEBHOOK_SECRET"
  );

  switch (event.type) {
    case "payment_intent.succeeded":
      console.log(`Payment received: $${event.data.object.amount / 100}`);
      break;
    case "customer.subscription.created":
      console.log("New subscriber!");
      break;
    case "invoice.payment_failed":
      console.log("Payment failed — send reminder email");
      break;
  }
  res.json({ received: true });
});
Enter fullscreen mode Exit fullscreen mode

Test Card Numbers

Card Number Result
4242 4242 4242 4242 Success
4000 0000 0000 0002 Decline
4000 0000 0000 3220 3D Secure required

Use any future expiry date and any 3-digit CVC.

Rate Limits

Mode Limit
Test mode 100 requests/second
Live mode 100 requests/second
Read operations Higher limits

What You Can Build

  • SaaS billing — subscriptions, usage-based pricing, free trials
  • Marketplace payments — Stripe Connect for multi-party payouts
  • One-time purchases — digital products, courses, reports
  • Donation page — accept one-time or recurring donations
  • Invoice system — auto-generate and send invoices
  • Usage metering — charge customers based on API calls or data usage

More Free API Articles


Need Web Data? Try These Tools

If you're building apps that need web scraping or data extraction, check out my ready-made tools on Apify Store — scrapers for Reddit, YouTube, Google News, Trustpilot, and 80+ more. No coding needed, just run and get your data.

Need a custom scraping solution? Email me at spinov001@gmail.com


More Free APIs You Should Know About

Need custom data scraping? Email me or check my Apify actors.

Top comments (0)