Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to new MP Payments API + new authentication #301

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ public class MobilePaySettingsV2 : IValidatable
public string ApiKey { get; set; }

[Required]
public Guid PaymentPointId { get; set; }
public string ClientId { get; set; }

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

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

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

[Required]
public string WebhookUrl { get; set; }
Expand Down
45 changes: 45 additions & 0 deletions coffeecard/CoffeeCard.Common/Configuration/MobilePaySettingsV3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.ComponentModel.DataAnnotations;
using NetEscapades.Configuration.Validation;

namespace CoffeeCard.Common.Configuration
{
public class MobilePaySettingsV3 : IValidatable
{
[Required]
public Uri ApiUrl { get; set; }

[Required]
public Guid ClientId { get; set; }

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

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

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

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

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

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

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

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


public void Validate()
{
Validator.ValidateObject(this, new ValidationContext(this), true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CoffeeCard.MobilePay.Generated.Api.PaymentsApi;
using CoffeeCard.Models.DataTransferObjects.v2.MobilePay;
using CoffeeCard.Models.DataTransferObjects.v2.Purchase;
using CoffeeCard.Models.Entities;
Expand Down
3 changes: 1 addition & 2 deletions coffeecard/CoffeeCard.Library/Services/v2/PurchaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks;
using CoffeeCard.Common.Errors;
using CoffeeCard.Library.Persistence;
using CoffeeCard.MobilePay.Generated.Api.PaymentsApi;
using CoffeeCard.MobilePay.Service.v2;
using CoffeeCard.Models.DataTransferObjects.v2.MobilePay;
using CoffeeCard.Models.DataTransferObjects.v2.Products;
Expand Down Expand Up @@ -133,7 +132,7 @@ private static void CheckUserIsAllowedToPurchaseProduct(User user, InitiatePurch
Price = product.Price,
NumberOfTickets = product.NumberOfTickets,
DateCreated = DateTime.UtcNow,
OrderId = paymentDetails.OrderId,
OrderId = orderId.ToString(),
ExternalTransactionId = transactionId,
PurchasedBy = user,
Status = purchaseStatus,
Expand Down
4 changes: 2 additions & 2 deletions coffeecard/CoffeeCard.Library/Services/v2/WebhookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public class WebhookService : IWebhookService

private readonly CoffeeCardContext _context;
private readonly IMobilePayWebhooksService _mobilePayWebhooksService;
private readonly MobilePaySettingsV2 _mobilePaySettings;
private readonly MobilePaySettingsV3 _mobilePaySettings;
private readonly IMemoryCache _memoryCache;

public WebhookService(CoffeeCardContext context, IMobilePayWebhooksService mobilePayWebhooksService,
MobilePaySettingsV2 mobilePaySettings, IMemoryCache memoryCache)
MobilePaySettingsV3 mobilePaySettings, IMemoryCache memoryCache)
{
_context = context;
_mobilePayWebhooksService = mobilePayWebhooksService;
Expand Down
Loading
Loading