Skip to content

Commit

Permalink
update gift card example (#437)
Browse files Browse the repository at this point in the history
* update bookings example

* update order ahead example

* update invoice sample

* update sample
  • Loading branch information
zenmasterjobo authored Dec 20, 2023
1 parent 330fcd9 commit 8297e65
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 78 deletions.
6 changes: 3 additions & 3 deletions connect-examples/v2/node_gift-cards/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
ENVIRONMENT=<sandbox OR production>

# Must match the values found in the corresponding production or sandbox environment
SQUARE_APPLICATION_ID=your-application-id
SQUARE_ACCESS_TOKEN=your-access-token
SQUARE_LOCATION_ID=your-location-id
SQ_APPLICATION_ID=your-application-id
SQ_ACCESS_TOKEN=your-access-token
SQ_LOCATION_ID=your-location-id
6 changes: 3 additions & 3 deletions connect-examples/v2/node_gift-cards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ The sample application does not implement a login authentication mechanism that
1. Create a `.env` file at the top of this directory by copying the contents of the `.env.example` file
2. In the file, replace the placeholder texts with actual values for:
- `ENVIRONMENT` should be set to `sandbox` or `production`
- `SQUARE_APPLICATION_ID` and `SQUARE_ACCESS_TOKEN` can be found under the _Credentials_ tab in your Square application
- `SQUARE_LOCATION_ID` can be found under the _Locations_ tabs in your Square application
- `SQ_APPLICATION_ID` and `SQ_ACCESS_TOKEN` can be found under the _Credentials_ tab in your Square application
- `SQ_LOCATION_ID` can be found under the _Locations_ tabs in your Square application

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).

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

Expand Down
6 changes: 3 additions & 3 deletions connect-examples/v2/node_gift-cards/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

const { v4: uuidv4 } = require("uuid");
const crypto = require("crypto")

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

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

app.use(session({
genid: function(req) {
return uuidv4() // use UUIDs for session IDs
return crypto.randomUUID() // use UUIDs for session IDs
},
secret: 'secret', // in production, use a unique and random generated string and store it in an environment variable
resave: true,
Expand Down
206 changes: 157 additions & 49 deletions connect-examples/v2/node_gift-cards/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions connect-examples/v2/node_gift-cards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
"author": "barakj, emmac",
"license": "Apache-2.0",
"dependencies": {
"@faker-js/faker": "^8.3.1",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"dotenv": "^10.0.0",
"dotenv": "^16.3.1",
"ejs": "^3.1.6",
"express": "^4.17.1",
"express-session": "^1.17.2",
"faker": "^5.5.3",
"express": "^4.18.2",
"express-session": "^1.17.3",
"morgan": "^1.10.0",
"nodemon": "^2.0.7",
"square": "^22.0.0",
"uuid": "^8.3.2"
"square": "^33.0.0"
},
"devDependencies": {
"eslint": "^7.28.0"
Expand Down
Loading

0 comments on commit 8297e65

Please sign in to comment.