Skip to content

Commit

Permalink
update invoice (#436)
Browse files Browse the repository at this point in the history
* update bookings example

* update order ahead example

* update invoice sample
  • Loading branch information
zenmasterjobo authored Dec 20, 2023
1 parent 7520234 commit 330fcd9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 37 deletions.
8 changes: 4 additions & 4 deletions connect-examples/v2/node_invoices/bin/script/seed-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.

const { Client, Environment } = require("square");
const readline = require("readline");
const { v4: uuidv4 } = require("uuid");
const crypto = require("crypto");
const { program } = require("commander");
require("dotenv").config();

Expand All @@ -44,14 +44,14 @@ async function addCustomers() {
try {
// Create first customer with card on file
const { result : { customer } } = await customersApi.createCustomer({
idempotencyKey: uuidv4(),
idempotencyKey: crypto.randomUUID(),
givenName: "Ryan",
familyName: "Nakamura",
emailAddress: "[email protected]" // it is a fake email
});

await cardsApi.createCard({
idempotencyKey: uuidv4(),
idempotencyKey: crypto.randomUUID(),
sourceId: "cnon:card-nonce-ok",
card: {
customerId: customer.id
Expand All @@ -60,7 +60,7 @@ async function addCustomers() {

// create second customer with no card on file
await customersApi.createCustomer({
idempotencyKey: uuidv4(),
idempotencyKey: crypto.randomUUID(),
givenName: "Kaitlyn",
familyName: "Spindel",
emailAddress: "[email protected]" // it is a fake email
Expand Down
30 changes: 8 additions & 22 deletions connect-examples/v2/node_invoices/package-lock.json

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

5 changes: 2 additions & 3 deletions connect-examples/v2/node_invoices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
"pug": "^3.0.0",
"request": "^2.88.0",
"serve-favicon": "^2.5.0",
"square": "^28.0.0",
"tslib": "^2.6.0",
"uuid": "^8.3.0"
"square": "^33.0.0",
"tslib": "^2.6.0"
},
"devDependencies": {
"eslint": "^6.1.0",
Expand Down
6 changes: 2 additions & 4 deletions connect-examples/v2/node_invoices/routes/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ limitations under the License.
*/

const express = require("express");
const {
v4: uuidv4
} = require("uuid");
const crypto = require("crypto");
const {
cardsApi,
ordersApi,
Expand Down Expand Up @@ -58,7 +56,7 @@ router.get("/view/:locationId/:customerId/:invoiceId", async (req, res, next) =>
locationId,
customerId,
invoice,
idempotencyKey: uuidv4(),
idempotencyKey: crypto.randomUUID(),
});
} catch (error) {
next(error);
Expand Down
6 changes: 2 additions & 4 deletions connect-examples/v2/node_invoices/routes/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ limitations under the License.
*/

const express = require("express");
const {
v4: uuidv4
} = require("uuid");
const crypto = require("crypto");
const {
customersApi,
invoicesApi,
Expand Down Expand Up @@ -86,7 +84,7 @@ router.get("/:locationId/:customerId", async (req, res, next) => {
serviceItems,
customer,
invoices: invoices || [],
idempotencyKey: uuidv4(),
idempotencyKey: crypto.randomUUID(),
});
} catch (error) {
next(error);
Expand Down

0 comments on commit 330fcd9

Please sign in to comment.