💸 Create a Payment Intent

How to create a Payment Intent on the Server

Create a Payment Intent

file_type_typescript payments.ts
import { stripe } from './';

/**
 * Create a Payment Intent with a specific amount
 */
export async function createPaymentIntent(amount: number) {
  const paymentIntent = await stripe.paymentIntents.create({
    amount,
    currency: 'usd',
    // receipt_email: 'hello@fireship.io',
  });

  paymentIntent.status

  return paymentIntent;
}

Payments Endpoint

file_type_typescript api.ts
import { createPaymentIntent } from './payments';

/**
 * Payment Intents
 */

app.post(
  '/payments',
  runAsync(async ({ body }: Request, res: Response) => {
    res.send(
      await createPaymentIntent(body.amount)
    );
  })
);

Questions? Let's chat

Open Discord