DEV Community

Alex Spinov
Alex Spinov

Posted on

Stripe Has a Free Payment API — Accept Payments in 135+ Currencies With 5 Lines of Code

Stripe Has a Free Payment API — Accept Payments in 135+ Currencies With 5 Lines of Code

Building payment processing from scratch means PCI compliance, fraud detection, currency conversion, and regulatory nightmares. Stripe handles all of this. No monthly fees — you only pay per transaction (2.9% + 30¢).

Free to Start

  • No setup fees
  • No monthly fees
  • Pay per transaction only (2.9% + 30¢)
  • Test mode with unlimited test transactions
  • All features available from day one
  • 135+ currencies supported

Quick Start: Checkout Session

const stripe = require('stripe')('sk_test_...');

// Create a checkout session — redirect users to Stripe's hosted page
const session = await stripe.checkout.sessions.create({
  line_items: [{
    price_data: {
      currency: 'usd',
      product_data: { name: 'Premium Plan' },
      unit_amount: 4999 // $49.99 in cents
    },
    quantity: 1
  }],
  mode: 'payment',
  success_url: 'https://yoursite.com/success',
  cancel_url: 'https://yoursite.com/cancel'
});

// Redirect user to session.url
Enter fullscreen mode Exit fullscreen mode

Subscriptions

// Create a subscription
const subscription = await stripe.subscriptions.create({
  customer: 'cus_xxx',
  items: [{ price: 'price_xxx' }],
  trial_period_days: 14,
  payment_behavior: 'default_incomplete',
  expand: ['latest_invoice.payment_intent']
});
Enter fullscreen mode Exit fullscreen mode

Webhooks

app.post('/webhooks/stripe', (req, res) => {
  const event = stripe.webhooks.constructEvent(
    req.body, req.headers['stripe-signature'], webhookSecret
  );

  switch (event.type) {
    case 'checkout.session.completed':
      const session = event.data.object;
      fulfillOrder(session);
      break;
    case 'invoice.paid':
      activateSubscription(event.data.object);
      break;
    case 'invoice.payment_failed':
      notifyCustomer(event.data.object);
      break;
  }
  res.sendStatus(200);
});
Enter fullscreen mode Exit fullscreen mode

The Bottom Line

Stripe is the gold standard for payment APIs. No upfront costs, world-class documentation, and it handles everything from simple one-time payments to complex marketplace payouts.


Need to monitor competitor pricing, track e-commerce trends, or build payment analytics? I create custom data solutions.

📧 Email me: spinov001@gmail.com
🔧 My tools: Apify Store

Top comments (0)