Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/ClientApp/Models/Orders/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,8 @@ public Order()

[JsonPropertyName("zipCode")] public string ShippingZipCode { get; set; }

public int CardTypeId { get; set; }

public string CardNumber { get; set; }

public string CardHolderName { get; set; }

public DateTime CardExpiration { get; set; }

public string CardSecurityNumber { get; set; }
[JsonPropertyName("paymentMethodId")]
public string PaymentMethodId { get; set; }

[JsonPropertyName("items")]
public List<OrderItem> OrderItems { get; set; }
Expand Down
12 changes: 1 addition & 11 deletions src/ClientApp/Models/Orders/OrderCheckout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ public class OrderCheckout

public string ZipCode { get; set; }
[Required]
public string CardNumber { get; set; }
[Required]
public string CardHolderName { get; set; }

[Required]
public DateTime CardExpiration { get; set; }

[Required]
public string CardSecurityNumber { get; set; }

public int CardTypeId { get; set; }
public string PaymentMethodId { get; set; }

public string Buyer { get; set; }

Expand Down
15 changes: 0 additions & 15 deletions src/ClientApp/Models/User/PaymentInfo.cs

This file was deleted.

7 changes: 0 additions & 7 deletions src/ClientApp/Models/User/UserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ public class UserInfo

[JsonPropertyName("last_name")] public string LastName { get; set; }

[JsonPropertyName("card_number")] public string CardNumber { get; set; }

[JsonPropertyName("card_holder")] public string CardHolder { get; set; }

[JsonPropertyName("card_security_number")]
public string CardSecurityNumber { get; set; }

[JsonPropertyName("address_city")] public string Address { get; set; }

[JsonPropertyName("address_country")] public string Country { get; set; }
Expand Down
3 changes: 0 additions & 3 deletions src/ClientApp/Services/Identity/IdentityMockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public Task<UserInfo> GetUserInfoAsync()
PreferredUsername = "sampleUser",
Name = "Sample",
LastName = "User",
CardNumber = "XXXXXXXXXXXX3456",
CardHolder = "Sample User",
CardSecurityNumber = "123",
Address = "123 Sample Street",
Country = "USA",
State = "Washington",
Expand Down
4 changes: 0 additions & 4 deletions src/ClientApp/Services/Identity/IdentityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public async Task<UserInfo> GetUserInfoAsync()
userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value,
Name = userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "name")?.Value,
LastName = userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "last_name")?.Value,
CardNumber = userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "card_number")?.Value,
CardHolder = userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "card_holder")?.Value,
CardSecurityNumber =
userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "card_security_number")?.Value,
PhoneNumberVerified =
bool.Parse(userInfoWithClaims.Claims.FirstOrDefault(c => c.Type == "phone_number_verified")
?.Value ?? "false"),
Expand Down
49 changes: 6 additions & 43 deletions src/ClientApp/Services/Order/OrderMockService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using eShop.ClientApp.Models.Basket;
using eShop.ClientApp.Models.Orders;
using eShop.ClientApp.Models.User;

namespace eShop.ClientApp.Services.Order;

public class OrderMockService : IOrderService
{
private static readonly DateTime MockExpirationDate = DateTime.Now.AddYears(5);
private const string MockPaymentMethodId = "pm_mock_mobile";

private static readonly Address MockAdress = new()
{
Expand All @@ -22,22 +21,6 @@ public class OrderMockService : IOrderService
ZipCode = "98101"
};

private static readonly PaymentInfo MockPaymentInfo = new()
{
Id = Guid.NewGuid(),
CardHolderName = "American Express",
CardNumber = "XXXXXXXXXXXX0005",
CardType = new CardType
{
Id = 3,
Name = "MasterCard"
},
Expiration = MockExpirationDate.ToString(),
ExpirationMonth = MockExpirationDate.Month,
ExpirationYear = MockExpirationDate.Year,
SecurityNumber = "123"
};

private static readonly List<OrderItem> MockOrderItems = new()
{
new OrderItem
Expand All @@ -64,11 +47,7 @@ public class OrderMockService : IOrderService

private static readonly OrderCheckout MockOrderCheckout = new()
{
CardExpiration = DateTime.UtcNow,
CardHolderName = "FakeCardHolderName",
CardNumber = "XXXXXXXXXXXX3224",
CardSecurityNumber = "1234",
CardTypeId = 1,
PaymentMethodId = MockPaymentMethodId,
City = "FakeCity",
Country = "FakeCountry",
ZipCode = "FakeZipCode",
Expand All @@ -84,11 +63,7 @@ public class OrderMockService : IOrderService
OrderDate = DateTime.Now,
OrderStatus = "Submitted",
OrderItems = MockOrderItems,
CardTypeId = MockPaymentInfo.CardType.Id,
CardHolderName = MockPaymentInfo.CardHolderName,
CardNumber = MockPaymentInfo.CardNumber,
CardSecurityNumber = MockPaymentInfo.SecurityNumber,
CardExpiration = new DateTime(MockPaymentInfo.ExpirationYear, MockPaymentInfo.ExpirationMonth, 1),
PaymentMethodId = MockPaymentMethodId,
ShippingCity = MockAdress.City,
ShippingState = MockAdress.State,
ShippingCountry = MockAdress.Country,
Expand All @@ -102,11 +77,7 @@ public class OrderMockService : IOrderService
OrderDate = DateTime.Now,
OrderStatus = "Paid",
OrderItems = MockOrderItems,
CardTypeId = MockPaymentInfo.CardType.Id,
CardHolderName = MockPaymentInfo.CardHolderName,
CardNumber = MockPaymentInfo.CardNumber,
CardSecurityNumber = MockPaymentInfo.SecurityNumber,
CardExpiration = new DateTime(MockPaymentInfo.ExpirationYear, MockPaymentInfo.ExpirationMonth, 1),
PaymentMethodId = MockPaymentMethodId,
ShippingCity = MockAdress.City,
ShippingState = MockAdress.State,
ShippingCountry = MockAdress.Country,
Expand All @@ -120,11 +91,7 @@ public class OrderMockService : IOrderService
OrderDate = DateTime.Now,
OrderStatus = "Cancelled",
OrderItems = MockOrderItems,
CardTypeId = MockPaymentInfo.CardType.Id,
CardHolderName = MockPaymentInfo.CardHolderName,
CardNumber = MockPaymentInfo.CardNumber,
CardSecurityNumber = MockPaymentInfo.SecurityNumber,
CardExpiration = new DateTime(MockPaymentInfo.ExpirationYear, MockPaymentInfo.ExpirationMonth, 1),
PaymentMethodId = MockPaymentMethodId,
ShippingCity = MockAdress.City,
ShippingState = MockAdress.State,
ShippingCountry = MockAdress.Country,
Expand All @@ -138,11 +105,7 @@ public class OrderMockService : IOrderService
OrderDate = DateTime.Now,
OrderStatus = "Shipped",
OrderItems = MockOrderItems,
CardTypeId = MockPaymentInfo.CardType.Id,
CardHolderName = MockPaymentInfo.CardHolderName,
CardNumber = MockPaymentInfo.CardNumber,
CardSecurityNumber = MockPaymentInfo.SecurityNumber,
CardExpiration = new DateTime(MockPaymentInfo.ExpirationYear, MockPaymentInfo.ExpirationMonth, 1),
PaymentMethodId = MockPaymentMethodId,
ShippingCity = MockAdress.City,
ShippingState = MockAdress.State,
ShippingCountry = MockAdress.Country,
Expand Down
6 changes: 1 addition & 5 deletions src/ClientApp/Services/Order/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ public OrderCheckout MapOrderToBasket(Models.Orders.Order order)
{
return new OrderCheckout
{
CardExpiration = order.CardExpiration,
CardHolderName = order.CardHolderName,
CardNumber = order.CardNumber,
CardSecurityNumber = order.CardSecurityNumber,
CardTypeId = order.CardTypeId,
PaymentMethodId = order.PaymentMethodId,
City = order.ShippingCity,
State = order.ShippingState,
Country = order.ShippingCountry,
Expand Down
15 changes: 1 addition & 14 deletions src/ClientApp/ViewModels/CheckoutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ await IsBusyFor(
City = userInfo?.Address
};

// Create Payment Info
var paymentInfo = new PaymentInfo
{
CardNumber = userInfo?.CardNumber,
CardHolderName = userInfo?.CardHolder,
CardType = new CardType {Id = 3, Name = "MasterCard"},
SecurityNumber = userInfo?.CardSecurityNumber
};

var orderItems = CreateOrderItems(basketItems);

// Create new Order
Expand All @@ -76,11 +67,7 @@ await IsBusyFor(
OrderItems = orderItems,
OrderStatus = "Submitted",
OrderDate = DateTime.Now,
CardHolderName = paymentInfo.CardHolderName,
CardNumber = paymentInfo.CardNumber,
CardSecurityNumber = paymentInfo.SecurityNumber,
CardExpiration = DateTime.UtcNow.AddYears(5),
CardTypeId = paymentInfo.CardType.Id,
PaymentMethodId = "pm_sample_mobile",
ShippingState = ShippingAddress.State,
ShippingCountry = ShippingAddress.Country,
ShippingStreet = ShippingAddress.Street,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace eShop.Identity.API.Data.Migrations
{
public partial class RemoveSensitiveCardProfileData : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CardHolderName",
table: "AspNetUsers");

migrationBuilder.DropColumn(
name: "CardNumber",
table: "AspNetUsers");

migrationBuilder.DropColumn(
name: "CardType",
table: "AspNetUsers");

migrationBuilder.DropColumn(
name: "Expiration",
table: "AspNetUsers");

migrationBuilder.DropColumn(
name: "SecurityNumber",
table: "AspNetUsers");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "CardHolderName",
table: "AspNetUsers",
type: "text",
nullable: false,
defaultValue: "");

migrationBuilder.AddColumn<string>(
name: "CardNumber",
table: "AspNetUsers",
type: "text",
nullable: false,
defaultValue: "");

migrationBuilder.AddColumn<int>(
name: "CardType",
table: "AspNetUsers",
type: "integer",
nullable: false,
defaultValue: 0);

migrationBuilder.AddColumn<string>(
name: "Expiration",
table: "AspNetUsers",
type: "text",
nullable: false,
defaultValue: "");

migrationBuilder.AddColumn<string>(
name: "SecurityNumber",
table: "AspNetUsers",
type: "text",
nullable: false,
defaultValue: "");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");

b.Property<string>("CardHolderName")
.IsRequired()
.HasColumnType("text");

b.Property<string>("CardNumber")
.IsRequired()
.HasColumnType("text");

b.Property<int>("CardType")
.HasColumnType("integer");

b.Property<string>("City")
.IsRequired()
.HasColumnType("text");
Expand All @@ -192,10 +181,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");

b.Property<string>("Expiration")
.IsRequired()
.HasColumnType("text");

b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
Expand Down Expand Up @@ -227,10 +212,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");

b.Property<string>("SecurityNumber")
.IsRequired()
.HasColumnType("text");

b.Property<string>("SecurityStamp")
.HasColumnType("text");

Expand Down
10 changes: 0 additions & 10 deletions src/Identity.API/Models/ApplicationUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
{
[Required]
public string CardNumber { get; set; }
[Required]
public string SecurityNumber { get; set; }
[Required]
[RegularExpression(@"(0[1-9]|1[0-2])\/[0-9]{2}", ErrorMessage = "Expiration should match a valid MM/YY value")]
public string Expiration { get; set; }
[Required]
public string CardHolderName { get; set; }
public int CardType { get; set; }
[Required]
public string Street { get; set; }
[Required]
Expand Down
12 changes: 0 additions & 12 deletions src/Identity.API/Services/ProfileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ private IEnumerable<Claim> GetClaimsFromUser(ApplicationUser user)
if (!string.IsNullOrWhiteSpace(user.LastName))
claims.Add(new Claim("last_name", user.LastName));

if (!string.IsNullOrWhiteSpace(user.CardNumber))
claims.Add(new Claim("card_number", user.CardNumber));

if (!string.IsNullOrWhiteSpace(user.CardHolderName))
claims.Add(new Claim("card_holder", user.CardHolderName));

if (!string.IsNullOrWhiteSpace(user.SecurityNumber))
claims.Add(new Claim("card_security_number", user.SecurityNumber));

if (!string.IsNullOrWhiteSpace(user.Expiration))
claims.Add(new Claim("card_expiration", user.Expiration));

if (!string.IsNullOrWhiteSpace(user.City))
claims.Add(new Claim("address_city", user.City));

Expand Down
Loading