using System.Security.Cryptography;
public static void Main()
var initialPayment = false;
const string PublicKey = "0oa70WuefiddqLjqlTlp";
const string PrivateKey = "m2vQxqNixqrEDcQ2heVr";
var customerAccountNumber = "Customer-1";
var msisdn = "201286438693";
var operatorCode = "60201";
var subscriptionPlanId = 3;
var initialPaymentproductId = "100Points";
var initialPaymentDate = DateTime.Now.AddDays(freeStartPeriod).ToString("yyyy-MM-dd HH:mm:ssZ");
var executeInitialPaymentNow = initialPayment;
var recurringPaymentproductId = "100Points";
var productCatalogName = "HETest";
var executeRecurringPaymentNow = false;
var contractStartDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ");
var contractEndDate = DateTime.Now.AddYears(10).ToString("yyyy-MM-dd HH:mm:ssZ");
var autoRenewContract = true;
var sendVerificationSMS = true;
var allowMultipleFreeStartPeriods = false;
var headerEnrichmentReferenceCode = "";
var message = customerAccountNumber + msisdn + operatorCode + subscriptionPlanId.ToString() + initialPaymentproductId + initialPaymentDate + executeInitialPaymentNow.ToString().ToLower() + recurringPaymentproductId + productCatalogName + executeRecurringPaymentNow.ToString().ToLower() + contractStartDate + contractEndDate + autoRenewContract.ToString().ToLower() + language.ToString() + sendVerificationSMS.ToString().ToLower() + allowMultipleFreeStartPeriods.ToString().ToLower() + headerEnrichmentReferenceCode + smsId;
var digest = CalculateDigest(PublicKey, PrivateKey, message);
var theDigest = CalculateDigest(PublicKey, PrivateKey, message);
Console.WriteLine("{\n\"signature\": \"" +theDigest+"\",\n"+
"\"customerAccountNumber\": \"" +customerAccountNumber+"\",\n"+
"\"msisdn\": \"" +msisdn+"\",\n"+
"\"operatorCode\": \"" +operatorCode+"\",\n"+
"\"subscriptionPlanId\": \"" +subscriptionPlanId+"\",\n"+
"\"initialPaymentproductId\": \"" +initialPaymentproductId+"\",\n"+
"\"initialPaymentDate\": \"" +initialPaymentDate+"\",\n"+
"\"executeInitialPaymentNow\": \"" +executeInitialPaymentNow.ToString().ToLower()+"\",\n"+
"\"executeRecurringPaymentNow\": \"" +executeRecurringPaymentNow.ToString().ToLower()+"\",\n"+
"\"recurringPaymentproductId\": \"" +recurringPaymentproductId+"\",\n"+
"\"productCatalogName\": \"" +productCatalogName+"\",\n"+
"\"autoRenewContract\": \"" +autoRenewContract.ToString().ToLower()+"\",\n"+
"\"sendVerificationSMS\": \"" +sendVerificationSMS.ToString().ToLower()+"\",\n"+
"\"allowMultipleFreeStartPeriods\": \"" +allowMultipleFreeStartPeriods.ToString().ToLower()+"\",\n"+
"\"contractStartDate\": \"" +contractStartDate+"\",\n"+
"\"contractEndDate\": \"" +contractEndDate+"\",\n"+
"\"language\": \"" +language+"\",\n"+
"\"headerEnrichmentReferenceCode\": \"" +headerEnrichmentReferenceCode+"\",\n"+
"\"smsId\": \"" +smsId+"\"\n}");
public static string CalculateDigest(string publicKey, string privateKey, string message)
var hash = new System.Security.Cryptography.HMACSHA256(System.Text.Encoding.UTF8.GetBytes(privateKey));
var correctHash = string.Join(string.Empty, hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(message)).Select(b => b.ToString("x2")));
digest = publicKey + ":" + correctHash;