Skip to main content
This tutorial shows how to use Stripe’s Crypto On-ramp API to let users buy USDC on Polygon directly inside your application. You will create an On-ramp session on the backend and render Stripe’s hosted widget on the frontend.
All examples below are demonstrations only. In production, never expose STRIPE_SECRET_KEY or private wallet keys in client code. Store them in a secure vault or secrets manager.

Prerequisites

  • A US-based business entity (excluding Hawaii)
  • Stripe account with the On-ramp feature enabled (appears automatically after compliance verification)
  • Stripe API key (sk_test_... or sk_live_...)

Reference docs

Schema

Create Session cURL

Run this on your backend server only (never in a browser):
If successful, Stripe returns a JSON response containing a client_secret:

Bun / NodeJS backend

Serve to Frontend

Pass only the client_secret to your client app. Never pass your Stripe secret key.
Users can now buy USDC on Polygon directly from your site. The funds are sent to the wallet specified in your onramp_session.

Reference

Configuration parameters, error codes, and guardrails.

Do / Don’t Do Guardrails

Errors

Quick Checklist

  • Backend has STRIPE_SECRET_KEY set
  • Frontend only receives client_secret
  • Wallet address is valid on Polygon
  • Tested in Sandbox before production