using System.Security.Cryptography;
public static void Main()
var customerAccountNumber = "8401e447-c4de-4b95-9e77-1b5fce4123ce";
var operatorCode = "42403";
var subscriptionPlanId = 48;
var initialPaymentproductId = "dv-008";
var initialPaymentDate = "2020-01-22 09:30:00Z";
var recurringPaymentproductId = "dv-008";
var productCatalogName = "DV-Catalog";
var contractStartDate = "2020-01-22 09:30:00Z";
var contractEndDate = "2021-01-22 09:30:00Z";
var autoRenewContract = true;
var sendVerificationSMS = true;
var executeInitialPaymentNow = false;
var executeRecurringPaymentNow = false;
const string PublicKey = "whpnsHMgiNioDB76MXXw";
const string PrivateKey = "F1ihKTGCrPL4UVvSnMBR";
var message = customerAccountNumber + msisdn + operatorCode + subscriptionPlanId.ToString() + initialPaymentproductId + initialPaymentDate + executeInitialPaymentNow.ToString().ToLower() + recurringPaymentproductId + productCatalogName + executeRecurringPaymentNow.ToString().ToLower() + contractStartDate + contractEndDate + autoRenewContract.ToString().ToLower() + (int)language;
var theDigest = CalculateDigest(PublicKey, PrivateKey, message);
var url = "https://live.tpay.me/op/42403/sub/new/customerAccountNumber="+customerAccountNumber+"&msisdn=&operatorCode="+operatorCode+"&subscriptionPlanId="+subscriptionPlanId.ToString()+"&initialPaymentproductId="
+"&initialPaymentDate="+initialPaymentDate +"&executeInitialPaymentNow="+executeInitialPaymentNow+"&recurringPaymentproductId="+recurringPaymentproductId+"&productCatalogName="+productCatalogName
+"&executeRecurringPaymentNow="+executeRecurringPaymentNow+"&contractStartDate="+contractStartDate+"&contractEndDate="+contractEndDate
+"&autoRenewContract="+autoRenewContract+"&language="+language+"&signature="+theDigest+"&redirectURL=http://billing.virgopass.com/tpay/du/callback.php";
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;