Need Webhook help and clarrifications

PaqHelp
New Community Member

Hello,

 

I am trying to implement a paypal subscription service on my site.

I use Angular as front end, ASP.net as backend.

I have added a webhook to my site.

 

 

    [HttpPost]
    public IActionResult Post()
    {
      bool isValid;

      try
      {
        // The APIContext object can contain an optional override for the trusted certificate.
        var apiContext = new APIContext();

        // Get the received request's headers
        var requestheaders = HttpContext.Request.Headers;

        // Get the received request's body
        var requestBody = string.Empty;
        using (var reader = new StreamReader(HttpContext.Request.Body))
        {
          requestBody = reader.ReadToEnd();
        }

        NameValueCollection nvc = new NameValueCollection();
        foreach (var item in requestheaders)
        {
          nvc.Add(item.Key, string.Join(",", item.Value));
        }

        // We have all the information the SDK needs, so perform the validation.
        isValid = WebhookEvent.ValidateReceivedEvent(apiContext, nvc, requestBody, ConfigurationManager.AppSettings["paypal.webhook.id"]);
      }
      catch (Exception ex)
      {
        isValid = false;
      }

      if (isValid)
      {
        return Ok();
      }
      else
      {
        return BadRequest("Could not validate request");
      }
    }

 

 

So far I can get the sandbox user to login, subscribe and I see the event in the Sandbox webhooks events.

 

But, the events are all listed as 'Pending'.

 

What am I missing?

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.