This is a Next.js project bootstrapped with create-next-app
.
- Install the dependencies:
npm install
-
Go to your Square Developer Dashboard, create an app and get the credentials.
-
Create a file named
.env.local
in your project's root folder, copy this code and replace the data with your credentials:
SQUARE_ACCESS_TOKEN='YOUR_ACCESS_TOKEN'
NEXT_PUBLIC_SQUARE_APP_ID='YOUR_APP_ID'
NEXT_PUBLIC_SQUARE_LOCATION_ID='YOUR_LOCATION_ID'
- Run the development server:
npm run dev
-
Open http://localhost:3000 with your browser to see the result.
-
Use any of the Sandbox credit card numbers to test the payment flow.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
To learn more about Square on Next.js, take a look at: https://developer.squareup.com/blog/accept-payments-with-square-using-next-js-app-router/