Skip to content

Commit

Permalink
Added template for "Save new card" case - Card.cshtml.
Browse files Browse the repository at this point in the history
Changed code to handle it.
  • Loading branch information
StanislavSmetaninSSM committed May 23, 2024
1 parent b9159e8 commit a57b17c
Show file tree
Hide file tree
Showing 14 changed files with 736 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>
<ItemGroup>
<None Remove="Updates\Card.cshtml" />
<None Remove="Updates\InlineForm.cshtml" />
<None Remove="Updates\Post.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Updates\Card.cshtml" />
<EmbeddedResource Include="Updates\InlineForm.cshtml" />
<EmbeddedResource Include="Updates\Post.cshtml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.4.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
Expand Down
45 changes: 45 additions & 0 deletions src/Hash.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow;

internal static class Hash
{
public static string ByteArrayToHexString(byte[] bytes)
{
var result = new StringBuilder();
foreach (byte b in bytes)
{
result.Append(b.ToString("x2"));
}

return result.ToString();
}

public static string ComputeHash(string key, Stream message)
{
var encoding = new UTF8Encoding();
var byteKey = encoding.GetBytes(key);

using (HMACSHA256 hmac = new HMACSHA256(byteKey))
{
var hashedBytes = hmac.ComputeHash(message);
return ByteArrayToHexString(hashedBytes);
}
}

public static string ComputeHash(string key, string message)
{
var encoding = new UTF8Encoding();
var byteKey = encoding.GetBytes(key);

using (HMACSHA256 hmac = new HMACSHA256(byteKey))
{
var messageBytes = encoding.GetBytes(message);
var hashedBytes = hmac.ComputeHash(messageBytes);

return ByteArrayToHexString(hashedBytes);
}
}
}
10 changes: 10 additions & 0 deletions src/Models/CardLinkUrl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Runtime.Serialization;

namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow.Models;

[DataContract]
internal sealed class CardLinkUrl
{
[DataMember(Name = "url")]
public string Url { get; set; }
}
11 changes: 11 additions & 0 deletions src/Models/Frontend/CallbackError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.Serialization;

namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow.Models.Frontend;

//This is a model for ajax-interactions with our templates only
[DataContract]
internal sealed class CallbackError
{
[DataMember(Name = "errorMessage")]
public string ErrorMessage { get; set; }
}
35 changes: 35 additions & 0 deletions src/Models/Frontend/CreateCardRequestData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Runtime.Serialization;

namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow.Models.Frontend;

//This is a model for ajax-interactions with our templates only
[DataContract]
internal sealed class CreateCardRequestData
{
[DataMember(Name = "agreementId")]
public string AgreementId { get; set; }

[DataMember(Name = "brandingId")]
public string BrandingId { get; set; }

[DataMember(Name = "languageCode")]
public string LanguageCode { get; set; }

[DataMember(Name = "paymentMethods")]
public string PaymentMethods { get; set; }

[DataMember(Name = "googleAnalyticsTrackingId")]
public string GoogleAnalyticsTrackingId { get; set; }

[DataMember(Name = "googleAnalyticsClientId")]
public string GoogleAnalyticsClientId { get; set; }

[DataMember(Name = "receiptUrl")]
public string ReceiptUrl { get; set; }

[DataMember(Name = "cancelUrl")]
public string CancelUrl { get; set; }

[DataMember(Name = "callbackUrl")]
public string СallbackUrl { get; set; }
}
3 changes: 2 additions & 1 deletion src/Models/Error.cs → src/Models/ServiceError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow.Models;

internal sealed class Error
[DataContract]
internal sealed class ServiceError
{
[DataMember(Name = "message")]
public string Message { get; set; }
Expand Down
Loading

0 comments on commit a57b17c

Please sign in to comment.