From 4f04d7f3077edc056eb32bf583acfafa84752248 Mon Sep 17 00:00:00 2001 From: Fellyph Cintra Date: Mon, 12 Feb 2024 17:57:25 +0000 Subject: [PATCH 1/4] changin text on payment gateway --- src/scenarios/payment-gateway/checkout.ejs | 2 +- src/scenarios/payment-gateway/routes.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/scenarios/payment-gateway/checkout.ejs b/src/scenarios/payment-gateway/checkout.ejs index 33efff4..5715a74 100644 --- a/src/scenarios/payment-gateway/checkout.ejs +++ b/src/scenarios/payment-gateway/checkout.ejs @@ -1,7 +1,7 @@ <%- include(commonPath + '/header.ejs') %> <%- include(commonPath + '/internal-page/header.ejs') %> -

Item: <%= item %> - $<%= price %>

+

Shopping cart: <%= item %> - $<%= price %>

diff --git a/src/scenarios/payment-gateway/routes.js b/src/scenarios/payment-gateway/routes.js index ceed45b..b454de5 100644 --- a/src/scenarios/payment-gateway/routes.js +++ b/src/scenarios/payment-gateway/routes.js @@ -2,11 +2,13 @@ const express = require( 'express' ); const path = require( 'path' ); const router = express.Router(); +const DEMO_CARD_NUMBER = '4242424242424242'; +const DEMO_CARD_NUMBER_2 = '4242-4242-4242-4242'; router.get( '/', ( req, res ) => { res.render( path.join( __dirname, 'checkout' ), { - title: 'Checkout', - item: "Virtual Badge for testing the site", + title: 'Checkout - Payment', + item: '🍍 Pineapple', price: 10, } ); } ); @@ -18,7 +20,7 @@ router.get( '/payment-form', ( req, res ) => { maxAge: 900000, httpOnly: true, domain: res.locals.domainC, - sameSite: "none", + sameSite: 'none', secure: true } ); } @@ -33,13 +35,13 @@ router.post( '/payment-form', ( req, res ) => { let message = ''; let status = 0; - if (sessionId && ( cardNumber === '4242424242424242' || cardNumber === '4242-4242-4242-4242' )) { + if (sessionId && ( cardNumber === DEMO_CARD_NUMBER || cardNumber === DEMO_CARD_NUMBER_2 )) { status = 1; message = 'Payment successful!'; } else if (!sessionId) { message = 'Payment failed! Session not valid.'; } else { - message = 'Invalid card number.
Please use 4242424242424242 for demo purchases.'; + message = `Invalid card number.
Please use ${DEMO_CARD_NUMBER} for demo purchases.`; } res.render( path.join( __dirname, 'payment-form' ), { From 875bb536dad42d8d37674900f45da9e4c332bf66 Mon Sep 17 00:00:00 2001 From: Fellyph Cintra Date: Mon, 12 Feb 2024 17:58:30 +0000 Subject: [PATCH 2/4] changing social media demo to facebook --- src/common/index.ejs | 2 +- src/scenarios/social-media/routes.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/index.ejs b/src/common/index.ejs index 15a744a..2a86b8b 100644 --- a/src/common/index.ejs +++ b/src/common/index.ejs @@ -19,7 +19,7 @@ <%= renderCard('Payment Gateway', '💳', '/payment-gateway') %> <%= renderCard('CHIPS', '🍪', '/chips') %> <%= renderCard('Legacy GSI', '🔐', '/gsi') %> - <%= renderCard('Social Media', '👍', '/social-media') %> + <%= renderCard('Facebook', '👍', '/social-media') %> diff --git a/src/scenarios/social-media/routes.js b/src/scenarios/social-media/routes.js index d0810d2..bdab96c 100644 --- a/src/scenarios/social-media/routes.js +++ b/src/scenarios/social-media/routes.js @@ -6,7 +6,7 @@ router.get('/', (req, res) => { // Send the default page const currentDomain = req.get('host'); res.render(path.join(__dirname,'index'), { - title: 'Social Media' + title: 'Facebook' }); }); From e8b565aa505bff9f2f032b693c8e0171d9e7649a Mon Sep 17 00:00:00 2001 From: Fellyph Cintra Date: Mon, 12 Feb 2024 18:35:54 +0000 Subject: [PATCH 3/4] adding product names --- src/scenarios/ecommerce/cart.ejs | 23 ++++++++++++++++------- src/scenarios/ecommerce/index.ejs | 12 ++++++------ src/scenarios/ecommerce/products.ejs | 24 +++++++++++++++++++----- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/scenarios/ecommerce/cart.ejs b/src/scenarios/ecommerce/cart.ejs index bd434ce..d8a0bd9 100644 --- a/src/scenarios/ecommerce/cart.ejs +++ b/src/scenarios/ecommerce/cart.ejs @@ -1,8 +1,8 @@ <%- include(commonPath + '/header.ejs') %> -
-

Your Cart

-
+
+

Your Cart

+
    @@ -14,6 +14,16 @@ const data = await res.json(); const cartElement = document.getElementById('cart'); + const productList = { + 1: { name: '🍍 Pineapple'}, + 2: { name: '🍊 Orange' }, + 3: { name: '🍓 Strawberry' } + }; + + const getProductName = ( productId ) => { + return productList[productId].name + } + // Group products by ID and count them const productCounts = data.reduce((acc, productId) => { acc[productId] = (acc[productId] || 0) + 1; @@ -30,10 +40,9 @@ // Display the product details in the cart element cartElement.innerHTML = productDetails.map(detail => ` -
    - 📦 - Product #${detail.productId} (Count: ${detail.count}) -
    +
  • + ${getProductName(detail.productId)} (Count: ${detail.count}) +
  • `).join(''); } catch (error) { console.error('Error:', error); diff --git a/src/scenarios/ecommerce/index.ejs b/src/scenarios/ecommerce/index.ejs index a88fb61..dee3b24 100644 --- a/src/scenarios/ecommerce/index.ejs +++ b/src/scenarios/ecommerce/index.ejs @@ -1,10 +1,10 @@ <%- include(commonPath + '/header.ejs') %> - <%- include(commonPath + '/internal-page/header.ejs') %> -

    Here is an embedded Third-Party e-commerce site, check if you can add products to cart.

    -
    - -
    - <%- include(commonPath + '/internal-page/footer.ejs') %> +
    +

    E-commerce

    +
    +
    + +
    <%- include(commonPath + '/footer.ejs') %> diff --git a/src/scenarios/ecommerce/products.ejs b/src/scenarios/ecommerce/products.ejs index 6098733..ef94db7 100644 --- a/src/scenarios/ecommerce/products.ejs +++ b/src/scenarios/ecommerce/products.ejs @@ -1,13 +1,27 @@ <%- include(commonPath + '/header.ejs') %> -
    - 🛒 Cart (0) -

    Products

    +<% + const productList = { + 1: { name: '🍍 Pineapple'}, + 2: { name: '🍊 Orange' }, + 3: { name: '🍓 Strawberry' } + }; + + const getProductName = ( productId ) => { + return productList[productId].name + } +%> + +
    +
    +

    Products

    + 🛒 Cart (0) +
      <% [1,2,3].forEach(productNumber => { %> -
    • - Product <%= productNumber %> +
    • + <%= getProductName(productNumber) %>
    • <% }) %> From ee7402c9c9e1716bed7bb717f7f15db12e64a5d5 Mon Sep 17 00:00:00 2001 From: Fellyph Cintra Date: Mon, 12 Feb 2024 18:58:57 +0000 Subject: [PATCH 4/4] removing typo --- src/common/index.ejs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/index.ejs b/src/common/index.ejs index 2a86b8b..d7b5399 100644 --- a/src/common/index.ejs +++ b/src/common/index.ejs @@ -23,5 +23,4 @@
    -<%- include(commonPath + '/footer.ejs') %> -👍 \ No newline at end of file +<%- include(commonPath + '/footer.ejs') %> \ No newline at end of file