GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Stripe customer creation API endpoint · aidrivencoder/master-git-github@49249a5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/app/api/stripe/customers
    • route.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/app/api/stripe/customers/route.ts‎

Copy file name to clipboard
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { NextResponse } from 'next/server'
2+
import Stripe from 'stripe'
3+
4+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
5+
apiVersion: '2023-08-16'
6+
})
7+
8+
export async function POST(request: Request) {
9+
try {
10+
const { email } = await request.json()
11+
12+
if (!email) {
13+
return NextResponse.json(
14+
{ error: 'Email is required' },
15+
{ status: 400 }
16+
)
17+
}
18+
19+
// Create a new customer in Stripe
20+
const customer = await stripe.customers.create({
21+
email,
22+
metadata: {
23+
source: 'master-git-github'
24+
}
25+
})
26+
27+
return NextResponse.json({ customerId: customer.id })
28+
} catch (error) {
29+
console.error('Error creating Stripe customer:', error)
30+
return NextResponse.json(
31+
{ error: 'Failed to create Stripe customer' },
32+
{ status: 500 }
33+
)
34+
}
35+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.