GitXplorerGitXplorer
t

nextjs-typescript-react-stripe-js

public
4 stars
2 forks
1 issues

Commits

List of commits on branch master.
Unverified
fe5e19a3031c242d26e82a647569fe15a60d37cb

Remove box shadow on mobile.

tthorsten-stripe committed 5 years ago
Unverified
021d8c9ad0f31525d6450692e5d8f11bbcacb9d0

Add twitter card.

tthorsten-stripe committed 5 years ago
Unverified
ece89bfcdace434a14a67ee9d564410a3c613baa

Add global CSS styles # Type-safe payments with Next.js, TypeScript, and react-stripe-js šŸ”’šŸ’ø

tthorsten-stripe committed 5 years ago
Unverified
2495bc7c1faa3bffde609c1df91b21321992661e

Moved to Next.js repo

tthorsten-stripe committed 5 years ago
Unverified
d1b1629680630590c070c2e45d3d7151e2d17f80

Update README links.

tthorsten-stripe committed 5 years ago
Unverified
095f4d4d29437e4d9a4b5a9c86178cf21b16c035

Update stripe-js.

tthorsten-stripe committed 5 years ago

README

The README file for this repository.

Type-safe payments with Next.js, TypeScript, and react-stripe-js šŸ”’šŸ’ø


This is a full-stack TypeScript example using:

Included functionality

How to use

Using create-next-app

Execute create-next-app with npm or Yarn to bootstrap the example:

npm init next-app --example with-stripe-typescript with-stripe-typescript-app
# or
yarn create next-app --example with-stripe-typescript with-stripe-typescript-app

Download manually

Download the example:

curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-stripe-typescript
cd with-stripe-typescript

Required configuration

Copy the .env.example file into a file named .env in the root directory of this project:

cp .env.example .env

You will need a Stripe account (register) to run this sample. Go to the Stripe developer dashboard to find your API keys and replace them in the .env file.

STRIPE_PUBLISHABLE_KEY=<replace-with-your-publishable-key>
STRIPE_SECRET_KEY=<replace-with-your-secret-key>

Now install the dependencies and start the development server.

npm install
npm run dev
# or
yarn
yarn dev

Forward webhooks to your local dev server

First install the CLI and link your Stripe account.

Next, start the webhook forwarding:

stripe listen --forward-to localhost:3000/api/webhooks

The CLI will print a webhook secret key to the console. Set STRIPE_WEBHOOK_SECRET to this value in your .env file.

Deploy

Deploy it to the cloud with ZEIT Now (Documentation).

Note: You must add your Stripe secrets using the ZEIT Now CLI (Download here):

now secrets add stripe_publishable_key pk_***
now secrets add stripe_secret_key sk_***
now secrets add stripe_webhook_secret whsec_***

After deploying, copy the deployment URL with the webhook path (https://your-url.now.sh/api/webhooks) and create a live webhook endpoint in your Stripe dashboard.

Note: Your live webhook will have a different secret. To update it in your deployed application you will need to first remove the existing secret and then add the new secret:

now secrets rm stripe_webhook_secret
now secrets add stripe_webhook_secret whsec_***

As the secrets are set as env vars in the project at deploy time, we will need to redeploy our app after we made changes to the secrets.