public TransactionRequest(NameValueCollection requestForm, DIBSConfiguration dibsConfiguration) { _dibsConfiguration = dibsConfiguration; _keyPairs = GetRequestKeyPairs(requestForm); _hmacKey = requestForm[HmacParamName]; OrderId = GetKeyPairValue(OrderIdParamName); TransactionId = GetKeyPairValue(TransactionParamName); }
public DIBSRequestHelper( IOrderNumberGenerator orderNumberGenerator, SiteContext siteContext, DIBSConfiguration dibsConfiguration) { _orderNumberGenerator = orderNumberGenerator; _siteContext = siteContext; DIBSConfiguration = dibsConfiguration; }
public DIBSPaymentMethod(IOrderGroupFactory orderGroupFactory) { _orderGroupFactory = orderGroupFactory; _paymentMethod = DIBSConfiguration.GetDIBSPaymentMethod()?.PaymentMethod?.FirstOrDefault(); if (_paymentMethod == null) { return; } PaymentMethodId = _paymentMethod.PaymentMethodId; SystemKeyword = _paymentMethod.SystemKeyword; Name = _paymentMethod.Name; Description = _paymentMethod.Description; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, System.EventArgs e) { if (Request.Form["paymentprovider"] != null && Request.Form["paymentprovider"].Equals(DIBSConfiguration.DIBSSystemName)) { ErrorManager.GenerateError(Utilities.Translate("CancelMessage")); } if (!IsPostBack) { var dibsConfiguration = new DIBSConfiguration(); if (string.IsNullOrEmpty(dibsConfiguration.ProcessingUrl) || string.IsNullOrEmpty(dibsConfiguration.HMACKey)) { ConfigMessage.Text = Utilities.Translate("DIBSSettingsError"); } } }
private static string GetHMACCalculation(DIBSConfiguration paymentConfiguration, string messageString) { // reference: https://tech.dibspayment.com/batch/d2integratedpwapihmac //Decoding the secret Hex encoded key and getting the bytes for MAC calculation var hmacKeyBytes = new byte[paymentConfiguration.HMACKey.Length / 2]; for (var i = 0; i < hmacKeyBytes.Length; i++) { hmacKeyBytes[i] = byte.Parse(paymentConfiguration.HMACKey.Substring(i * 2, 2), NumberStyles.HexNumber); } var msgBytes = Encoding.UTF8.GetBytes(messageString); //Calculate MAC key var hash = new HMACSHA256(hmacKeyBytes); var macBytes = hash.ComputeHash(msgBytes); return(BitConverter.ToString(macBytes).Replace("-", string.Empty).ToLower()); }
private PaymentMethodDto.PaymentMethodParameterRow GetParameterByName(string name) { return(DIBSConfiguration.GetParameterByName(_paymentMethodDto, name)); }
protected virtual string GetMACRequest(DIBSConfiguration configuration, Dictionary <string, object> message) => Utilities.GetMACRequest(configuration, message);
/// <summary> /// Gets the MD5 key used to send to DIBS in authorization step. /// </summary> /// <param name="paymentConfiguration">The DIBS payment configuration.</param> /// <param name="keyPairs">The key pairs.</param> public static string GetMACRequest(DIBSConfiguration paymentConfiguration, Dictionary <string, object> keyPairs) { var messageString = string.Join("&", keyPairs.Select(kp => $"{kp.Key}={kp.Value}")); return(GetHMACCalculation(paymentConfiguration, messageString)); }