public string GivenSHA1AndSomeInputVariables_WhenICallCreate_ThenItGeneratesCorrectly(
            string merchantId, int amount, int currencyCode, string orderId, string password, string preSharedKey
            )
        {
            Dictionary <string, object> formValues = new Dictionary <string, object>
            {
                { "MerchantID", merchantId },
                { "Amount", amount },
                { "CurrencyCode", currencyCode },
                { "OrderID", orderId }
            };

            string hashDigest = _hashDigestFactory.Create(formValues, preSharedKey, password);

            return(hashDigest);
        }
Beispiel #2
0
        private Dictionary <string, object> GetFormDetails(OrderModel order,
                                                           CustomerDataModel customerData,
                                                           string callbackUrl)
        {
            Dictionary <string, object> formValues = new Dictionary <string, object>
            {
                { "MerchantID", "Test-2994724" },
                { "Amount", order.Price.ToInt() },
                { "CurrencyCode", 826 },
                { "EchoAVSCheckResult", false },
                { "EchoCV2CheckResult", false },
                { "EchoThreeDSecureAuthenticationCheckResult", false },
                { "EchoCardType", false },
                { "AVSOverridePolicy", "EFFF" },
                { "CV2OverridePolicy", "FF" },
                { "ThreeDSecureOverridePolicy", false },
                { "OrderID", order.Id.ToString() },
                { "TransactionType", "SALE" },
                { "TransactionDateTime", DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss zzz") },
                { "CallbackURL", callbackUrl },
                { "OrderDescription", "Sale of Chilled Meat Products" },
                { "CustomerName", customerData.Name },
                { "Address1", "" },
                { "Address2", "" },
                { "Address3", "" },
                { "Address4", "" },
                { "City", "" },
                { "State", "" },
                { "PostCode", "" },
                { "CountryCode", "" },
                { "EmailAddress", customerData.EmailAddress },
                { "PhoneNumber", customerData.PhoneNumber },
                { "EmailAddressEditable", false },
                { "PhoneNumberEditable", false },
                { "CV2Mandatory", true },
                { "Address1Mandatory", true },
                { "CityMandatory", true },
                { "PostCodeMandatory", true },
                { "StateMandatory", true },
                { "CountryMandatory", true },
                { "ResultDeliveryMethod", "SERVER" },
                { "ServerResultURL", $"{_serverUrl}/api/v1/confirm-payment" },
                { "PaymentFormDisplaysResult", false }
            };
            string stringToHash = _hashDigestFactory.Create(formValues,
                                                            "WwUbLs5oGMQqZVVHvw4XgxMefcWE2TXfW5zEUP/tzIqf+iBm5iUn85+sBkTeK3NFfrjVmzRHqTkR91oOesJR",
                                                            "1q2aW3zSe4");
            Dictionary <string,
                        object> formData = formValues.ToDictionary(x => x.Key, x => x.Value);

            formData.Add("HashDigest",
                         stringToHash);
            return(formData);
        }