When each order payment is after getting a notification from the merchant we are using the notifications received through the webhook service I prefer the link: https://docs.clover.com/docs/webhooks
Currently, I'm using the clover sandbox account
APP NAME: CrownTrophyClover
APP ID : 4CX3H0TBZCY8Y
MID : FBTRW3S6J8RZ1
Now come to the point, In the Webhook URL field, I set the callback URL : https://temp.crownworkflow.com/CloverWebhook.aspx
The following code I had implemented in CloverWebhook.aspx.cs :
public partial class CloverWebhook : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (Request.HttpMethod == "POST")
{
string verificationToken = Request.Headers.GetValues("X-Clover-Auth")?[0];
//Request.Headers["X-Clover-Auth"];
if (!string.IsNullOrEmpty(verificationToken))
{
// Generate a verification code
string verificationCode = GenerateVerificationCode();
lblpaymentMsg.InnerText = verificationCode;
Response.ContentType = "text/plain";
Response.Write(verificationCode);
Response.End();
return;
}
// Handle other webhook events here...
}
}
}
private string GenerateVerificationCode()
{
string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
char[] verificationCodeChars = new char[6];
for (int i = 0; i < verificationCodeChars.Length; i++)
{
verificationCodeChars[i] = characters[random.Next(characters.Length)];
}
string verificationCode = new string(verificationCodeChars);
return verificationCode;
}
}
The above code in the "X-Clover-Auth" header is getting a null value.
Now Issue is when click Send Verification Code. A POST request containing a verification code is sent to the callback URL, but I did not get any Verification Code on the callback URL.
So please let me know what did I taken a mistake? Please respond as soon as possible.