Skip to content

Latest commit

 

History

History
 
 

node-typescript

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Accepting a payment with TypeScript

As of 8.0.1, stripe-node provides types for the latest API version. These types offer a beneficial developer experience when working with TypeScript, including enhanced code completion.

To find out more about usage with TypeScript, see the stripe-node README.

Requirements

You’ll need the following:

Setup

Copy the environment variables file from the root of the repository:

cp ../../../.env.example .env

Update .env with your own Stripe API keys.

Install and run

Install dependencies using npm:

npm install

Next, follow these installation steps to install the Stripe CLI which we'll use for webhook forwarding.

After the installation has finished, authenticate the CLI with your Stripe account:

stripe login

To start the webhook forwarding run:

stripe listen --forward-to localhost:4242/webhook

The Stripe CLI will let you know that webhook forwarding is ready and output your webhook signing secret:

> Ready! Your webhook signing secret is whsec_xxx

Copy the webhook signing secret (whsec_xxx) to your .env file.

In a separate terminal window, start the local server:

npm run start # Compiles and runs the TypeScript example.