-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from dynamicweb/ssm/19122-quick_pay_fixes
Quickpay fixes
- Loading branch information
Showing
15 changed files
with
1,141 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow; | ||
|
||
internal sealed class CheckedData | ||
{ | ||
public CheckDataResult Result { get; set; } | ||
|
||
public string Message { get; set; } | ||
|
||
public CheckedData(CheckDataResult result) | ||
{ | ||
Result = result; | ||
} | ||
|
||
public CheckedData(CheckDataResult result, string message) : this(result) | ||
{ | ||
Message = message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow; | ||
|
||
internal sealed class CommandConfiguration | ||
{ | ||
/// <summary> | ||
/// Quick pay command. See operation urls in <see cref="QuickPayRequest"/> and <see cref="ApiService"/> | ||
/// </summary> | ||
public ApiService CommandType { get; set; } | ||
|
||
/// <summary> | ||
/// Command operator id, like /cards/{OperatorId} | ||
/// </summary> | ||
public string OperatorId { get; set; } | ||
|
||
/// <summary> | ||
/// Command operator second id, like /cards/{OperatorId}/operations/{OperatorSecondId} | ||
/// </summary> | ||
public string OperatorSecondId { get; set; } | ||
|
||
/// <summary> | ||
/// Command query parameters, like /payments/{OperatorId}/refund?{QueryParameters} | ||
/// </summary> | ||
public Dictionary<string, string> QueryParameters { get; set; } | ||
|
||
/// <summary> | ||
/// Parameters for request | ||
/// </summary> | ||
public Dictionary<string, object> Parameters { get; set; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow; | ||
|
||
internal static class Hash | ||
{ | ||
public static string ComputeHash(string key, IDictionary<string, string> formValues) | ||
{ | ||
string message = GetMacString(formValues); | ||
|
||
return ComputeHash(key, message); | ||
} | ||
|
||
|
||
public static string ComputeHash(string key, string message) | ||
{ | ||
var encoding = new UTF8Encoding(); | ||
byte[] byteKey = encoding.GetBytes(key); | ||
|
||
using (HMACSHA256 hmac = new HMACSHA256(byteKey)) | ||
{ | ||
var messageBytes = encoding.GetBytes(message); | ||
var hashedBytes = hmac.ComputeHash(messageBytes); | ||
|
||
return ByteArrayToHexString(hashedBytes); | ||
} | ||
} | ||
|
||
private static string ByteArrayToHexString(byte[] bytes) | ||
{ | ||
var result = new StringBuilder(); | ||
foreach (byte b in bytes) | ||
{ | ||
result.Append(b.ToString("x2")); | ||
} | ||
|
||
return result.ToString(); | ||
} | ||
|
||
private static string GetMacString(IDictionary<string, string> formValues) | ||
{ | ||
var excludeList = new List<string> { "MAC" }; | ||
var keysSorted = formValues.Keys.ToArray(); | ||
Array.Sort(keysSorted, StringComparer.Ordinal); | ||
|
||
var message = new StringBuilder(); | ||
foreach (string key in keysSorted) | ||
{ | ||
if (excludeList.Contains(key)) | ||
continue; | ||
|
||
if (message.Length > 0) | ||
message.Append(" "); | ||
|
||
var value = formValues[key]; | ||
message.Append(value); | ||
} | ||
|
||
return message.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Dynamicweb.Ecommerce.CheckoutHandlers.QuickPayPaymentWindow.Models; | ||
|
||
[DataContract] | ||
internal sealed class ServiceError | ||
{ | ||
[DataMember(Name = "message")] | ||
public string Message { get; set; } | ||
|
||
[DataMember(Name = "error_code")] | ||
public int ErrorCode { get; set; } | ||
} |
Oops, something went wrong.