Skip to content

Commit 8297e65

Browse files
update gift card example (#437)
* update bookings example * update order ahead example * update invoice sample * update sample
1 parent 330fcd9 commit 8297e65

File tree

8 files changed

+185
-78
lines changed

8 files changed

+185
-78
lines changed

connect-examples/v2/node_gift-cards/.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
ENVIRONMENT=<sandbox OR production>
33

44
# Must match the values found in the corresponding production or sandbox environment
5-
SQUARE_APPLICATION_ID=your-application-id
6-
SQUARE_ACCESS_TOKEN=your-access-token
7-
SQUARE_LOCATION_ID=your-location-id
5+
SQ_APPLICATION_ID=your-application-id
6+
SQ_ACCESS_TOKEN=your-access-token
7+
SQ_LOCATION_ID=your-location-id

connect-examples/v2/node_gift-cards/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ The sample application does not implement a login authentication mechanism that
4747
1. Create a `.env` file at the top of this directory by copying the contents of the `.env.example` file
4848
2. In the file, replace the placeholder texts with actual values for:
4949
- `ENVIRONMENT` should be set to `sandbox` or `production`
50-
- `SQUARE_APPLICATION_ID` and `SQUARE_ACCESS_TOKEN` can be found under the _Credentials_ tab in your Square application
51-
- `SQUARE_LOCATION_ID` can be found under the _Locations_ tabs in your Square application
50+
- `SQ_APPLICATION_ID` and `SQ_ACCESS_TOKEN` can be found under the _Credentials_ tab in your Square application
51+
- `SQ_LOCATION_ID` can be found under the _Locations_ tabs in your Square application
5252

5353
Navigate to the [Developer Dashboard](https://developer.squareup.com/apps) to manage and retrieve credentials for Square applications. For more information on creating a Square application, see [Getting Started](https://developer.squareup.com/docs/get-started#step-2-create-an-application).
5454

@@ -86,7 +86,7 @@ This Express.js project is organized as follows:
8686
- **gift-card.js** contains routes for managing gift cards. This includes gift card creation and managing gift card activities
8787
- **seed.js** contains routes for managing test data when using the `sandbox` environment
8888
- **./util/** includes the following:
89-
- **square_client.js** a utility module for initializing the Square SDK client
89+
- **SQ_client.js** a utility module for initializing the Square SDK client
9090
- **middleware.js** contains middleware functions for verifying permissions
9191
- **./views/** contains template (.ejs) files.
9292

connect-examples/v2/node_gift-cards/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
const { v4: uuidv4 } = require("uuid");
17+
const crypto = require("crypto")
1818

1919
const express = require("express");
2020
const logger = require("morgan");
@@ -28,7 +28,7 @@ const app = express();
2828
const { locationsApi } = require("./util/square-client");
2929
app.locals.currency = "USD";
3030
app.locals.maxLimit = 200000;
31-
locationsApi.retrieveLocation(process.env[`SQUARE_LOCATION_ID`]).then(function(response) {
31+
locationsApi.retrieveLocation(process.env[`SQ_LOCATION_ID`]).then(function(response) {
3232
app.locals.currency = response.result.location.currency;
3333

3434
// If the currency is one of the following currencies, we have to change our maximum allowed balance.
@@ -63,7 +63,7 @@ app.use(express.urlencoded({
6363

6464
app.use(session({
6565
genid: function(req) {
66-
return uuidv4() // use UUIDs for session IDs
66+
return crypto.randomUUID() // use UUIDs for session IDs
6767
},
6868
secret: 'secret', // in production, use a unique and random generated string and store it in an environment variable
6969
resave: true,

connect-examples/v2/node_gift-cards/package-lock.json

Lines changed: 157 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

connect-examples/v2/node_gift-cards/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
"author": "barakj, emmac",
1717
"license": "Apache-2.0",
1818
"dependencies": {
19+
"@faker-js/faker": "^8.3.1",
1920
"body-parser": "^1.19.0",
2021
"cookie-parser": "^1.4.5",
21-
"dotenv": "^10.0.0",
22+
"dotenv": "^16.3.1",
2223
"ejs": "^3.1.6",
23-
"express": "^4.17.1",
24-
"express-session": "^1.17.2",
25-
"faker": "^5.5.3",
24+
"express": "^4.18.2",
25+
"express-session": "^1.17.3",
2626
"morgan": "^1.10.0",
2727
"nodemon": "^2.0.7",
28-
"square": "^22.0.0",
29-
"uuid": "^8.3.2"
28+
"square": "^33.0.0"
3029
},
3130
"devDependencies": {
3231
"eslint": "^7.28.0"

0 commit comments

Comments
 (0)