public TransactionRequest CreateTransactionRequest(Address billingAddress, Address shippingAddress, string transactionId, decimal total, DateTime transactionTime) { var amount = (total * 100).ToString("##"); var timestamp = transactionTime.ToString("yyyyMMddHHmmss"); var hashInput = string.Format("{0}.{1}.{2}.{3}.{4}", timestamp, _configuration.MerchantId, transactionId, amount, _configuration.Currency); var hash = GetHash(string.Format("{0}.{1}", GetHash(hashInput), _configuration.SharedSecret)); var billingCode = GetAddressCode(billingAddress); var shippingCode = GetAddressCode(shippingAddress); return new TransactionRequest { Amount = amount, BillingCode = billingCode, BillingCountry = billingAddress.CountryIso3166Alpha2Code, Currency = _configuration.Currency, MerchantId = _configuration.MerchantId, Sha1Hash = hash, ShippingCode = shippingCode, ShippingCountry = shippingAddress.CountryIso3166Alpha2Code, SubAccount = _configuration.SubAccount, Timestamp = timestamp, TransactionId = transactionId, UrlEndPoint = _configuration.UrlEndPoint }; }
private string GetAddressCode(Address address) { return string.Format("{0}|{1}", Regex.Replace(address.Postcode, "[^\\d]", string.Empty), Regex.Replace(address.Line1 + address.Line2, "[^\\d]", "")); }