Skip to content

Commit

Permalink
[Delivers-18758498] ft-buyer-stripe-payment (#78)
Browse files Browse the repository at this point in the history
* [Delivers-18758498] ft-buyer-stripe-payment

* [Delivers-18758498] ft-buyer-stripe-payment

* --ammend

* [Delivers-18758498] ft-buyer-stripe-payment

* fix bugs in test

* fix test

* removing bugs

* merge to develop and fix code base

* merge to develop and fix codebase

* Fixes DB double calling

* Fixes DB double calling

* Fixes DB double calling

---------

Co-authored-by: AimePazzo <[email protected]>
Co-authored-by: Ndahimana Bonheur <[email protected]>
  • Loading branch information
3 people authored Jul 2, 2024
1 parent b2e95c9 commit cb7a058
Show file tree
Hide file tree
Showing 31 changed files with 1,417 additions and 978 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
Session_secret: ${{ secrets.Session_secret }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
STRIPE_SECRET: ${{ secrets.STRIPE_SECRET }}

jobs:
build:
Expand Down
91 changes: 84 additions & 7 deletions package-lock.json

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

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@
"src/types/*.*",
"src/services/googleAuth.ts",
"src/services/chat.ts",
"src/services/cronJob.ts",
"src/helpers/passwordExpiryNotifications.ts",
"src/services/notificationSocket.ts",
"src/helpers/notifications.ts",
"src/services/stripe.ts",
"src/services/cronJob.ts",
"src/helpers/passwordExpiryNotifications.ts"

],
"reporter": [
"html",
Expand All @@ -61,7 +66,6 @@
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/mocha": "^10.0.6",
"@types/multer": "^1.4.11",
"@types/node-cron": "^3.0.11",
"@types/sinon": "^17.0.3",
"@types/sinon-chai": "^3.2.12",
"bcrypt": "^5.1.1",
Expand Down Expand Up @@ -100,6 +104,7 @@
"sinon-chai": "^3.7.0",
"socket.io": "^4.7.5",
"socket.io-client": "^4.7.5",
"stripe": "^15.12.0",
"supertest": "^7.0.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/databases/migrations/20240604150804-create-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export = {
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
products: {
type: DataTypes.JSONB

},
shopId: {
type: DataTypes.UUID,
allowNull: false,
Expand All @@ -30,7 +34,7 @@ export = {
onDelete: "CASCADE"
},
paymentMethodId: {
type: DataTypes.INTEGER,
type: DataTypes.STRING,
allowNull: false
},
orderDate: {
Expand Down
1 change: 1 addition & 0 deletions src/databases/models/carts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface CartAttributes {
}

class Carts extends Model<CartAttributes> implements CartAttributes {
[x: string]: any;
declare id: string;
declare userId: string;
declare status: string;
Expand Down
12 changes: 9 additions & 3 deletions src/databases/models/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import Carts from "./carts";
export interface OrderAttributes {
id: string;
shopId: string;
products: any;
cartId: string;
paymentMethodId: number;
paymentMethodId: string;
orderDate: Date;
status: string;
createdAt: Date;
Expand All @@ -20,8 +21,9 @@ export interface OrderAttributes {
class Orders extends Model<OrderAttributes> implements OrderAttributes {
declare id: string;
declare cartId: string;
declare products: any;
declare shopId: string;
declare paymentMethodId: number;
declare paymentMethodId: string;
declare orderDate: Date;
declare status: string;
declare createdAt: Date;
Expand All @@ -41,6 +43,10 @@ Orders.init(
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
products: {
type: new DataTypes.JSONB,
allowNull: false
},
shopId: {
type: new DataTypes.UUID,
allowNull: false
Expand All @@ -50,7 +56,7 @@ Orders.init(
allowNull: false
},
paymentMethodId: {
type: new DataTypes.INTEGER,
type: new DataTypes.STRING,
allowNull: false
},
orderDate: {
Expand Down
23 changes: 23 additions & 0 deletions src/databases/seeders/20240520202759-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
userEightId,
userNineId,
userTenId,
userElevenId
} from "../../types/uuid";

const userOne = {
Expand Down Expand Up @@ -205,6 +206,7 @@ const userTen = {
id: userTenId,
createdAt: new Date(),
updatedAt: new Date(),
passwordUpdatedAt: new Date(),
firstName: "F Buyer3",
lastName: "L Buyer3",
email: "[email protected]",
Expand All @@ -220,6 +222,26 @@ const userTen = {
isVerified: true,
is2FAEnabled: false,
};
const userEleven = {
id: userElevenId,
createdAt: new Date(),
updatedAt: new Date(),
passwordUpdatedAt: new Date(),
firstName: "F Buyer3",
lastName: "L Buyer3",
email: "[email protected]",
password: hashPassword("Password@123"),
phone: 25089767899,
profilePicture: "",
gender: "female",
birthDate: "2-2-2014",
language: "english",
currency: "USD",
role: "buyer",
status: "enabled",
isVerified: true,
is2FAEnabled: false,
};

export const up = (queryInterface: QueryInterface) =>
queryInterface.bulkInsert("users", [
Expand All @@ -233,6 +255,7 @@ export const up = (queryInterface: QueryInterface) =>
userEight,
userNine,
userTen,
userEleven
]);

export const down = async (queryInterface: QueryInterface) => {
Expand Down
9 changes: 8 additions & 1 deletion src/databases/seeders/20240602133044-carts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryInterface } from "sequelize";
import { cartOneId, cartTwoId, userTenId, userTwoId } from "../../types/uuid";
import { cartOneId, cartTwoId, userTenId, userTwoId , cartThreeId, userElevenId } from "../../types/uuid";

module.exports = {
async up(queryInterface: QueryInterface) {
Expand All @@ -17,6 +17,13 @@ module.exports = {
status: "pending",
createdAt: new Date(),
updatedAt: new Date()
},
{
id: cartThreeId,
userId: userElevenId,
status: "pending",
createdAt: new Date(),
updatedAt: new Date()
}
], {});
},
Expand Down
23 changes: 22 additions & 1 deletion src/databases/seeders/20240604133044-orders.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
/* eslint-disable comma-dangle */
import { QueryInterface } from "sequelize";
import { cartOneId, orderOneId, orderTwoId, shopOneId } from "../../types/uuid";
import { cartOneId, orderOneId, orderTwoId, shopOneId,productTwoId,productOneId } from "../../types/uuid";

module.exports = {
async up(queryInterface: QueryInterface) {
await queryInterface.bulkInsert("orders", [
{
id: orderOneId,
products:JSON.stringify( [
{
productId:productOneId,
status:"pending"
},
{
productId:productTwoId,
status:"pending"
},
]),
shopId: shopOneId,
cartId: cartOneId,
paymentMethodId: 1,
Expand All @@ -16,6 +27,16 @@ module.exports = {
},
{
id: orderTwoId,
products:JSON.stringify( [
{
productId:productOneId,
status:"pending"
},
{
productId:productTwoId,
status:"pending"
}
]),
shopId: shopOneId,
cartId: cartOneId,
paymentMethodId: 2,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/passwordExpiryNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const checkPasswordExpirations = async () => {
const salutation = getSalutation(user.lastName);
const emailMessage = `${salutation}, your password will expire in 10 minutes. Please update your password to continue using the E-commerce Ninja. You can reset your password using the following link: ${PASSWORD_RESET_URL}`;
await sendEmail(user.email, "Password Expiration Warning", emailMessage)
// .then(() => console.log(`10-minute warning sent to user: ${user.email}`))
.then(() => console.log(`10-minute warning sent to user: ${user.email}`))
.catch((err) =>
console.error(`Failed to send 10-minute warning to ${user.email}:`, err.message)
);
Expand Down
Loading

0 comments on commit cb7a058

Please sign in to comment.