Validating PayPal Webhook calls with PayPal .NET SDK in Sandbox

paypal refund webhook
paypal developer
paypal ipn vs webhook
paypal api
paypal webhook for recurring payment
payment gateway webhook
venmo webhook
webhooks rest api

I've been trying to set up PayPal Webhooks (in Sandbox mode) to receive notifications about declined and successful payments. My problem is that I can't get validation working. Some details about my attempts:

  1. The app is an OWIN self-hosted Web API 2.
  2. Hosted as an Azure Web App, tested on Azure as well.
  3. I set the Paypal Webhook receiver URL in the Paypal dashboard to the URL of my endpoint on Azure.
  4. I used the Paypal Webhooks simulator from the Paypal dashboard to send a message to the Azure endpoint.

I tried listening for Webhook calls two ways:

  1. ASP.NET Webhook Receivers (http://blogs.msdn.com/b/webdev/archive/2015/09/04/introducing-microsoft-asp-net-webhooks-preview.aspx), which didn't work. I get the error message "WebHook validation failed: "
  2. Tried creating a Web API endpoint to receive and validate the request, didn't work either. Code here:

    [HttpPost]
    public async Task<IHttpActionResult> PaymentCaptureCompleted()
    {
        // Get the received request's headers
        NameValueCollection nvc = new NameValueCollection();
        foreach (var item in Request.Headers)
        {
            nvc.Add(item.Key, string.Join(",", item.Value));
        }
    
        // Get the received request's body
        var requestBody = await Request.Content.ReadAsStringAsync();
    
        var isValid = WebhookEvent.ValidateReceivedEvent(Api, nvc, requestBody, ConfigurationManager.AppSettings["paypal.webhook.id"]);
    
        if (isValid)
        {
            return Ok();
        }
        else
        {
            return BadRequest("Could not validate request");
        }
    }
    

There are a lot more details to this of course, but I'm not sure how much information is required to answer my question. Just let me know what you need and I'll edit this question.

Please refer PayPal Dot Net SDK for code samples. https://github.com/paypal/PayPal-NET-SDK

Also if your simulator is not working, to rule out if there is something wrong with the configuration of webhook or the azure, you may want to use Runscope. Ypu can configure a Runscope bucket as a webhook endpoint and If you are getting a webhook notification there, you may need to make changes in the Azure config.

Webhooks, The PayPal REST APIs use webhooks for event notification. When you simulate an event, the simulator validates that your listener can access protected REST API resources, you create sandbox accounts to test your web and mobile apps. The REST SDK Quickstart shows you how to use the SDKs to create payment  The Webhooks API. The Webhooks Events dashboard. To use the PayPal REST SDKs to verify event notifications. These PayPal REST SDKs provide reference implementations that enable you to verify event notifications: PayPal Java SDK; PayPal .NET SDK; PayPal Node SDK; PayPal PHP SDK; PayPal Python SDK; PayPal Ruby SDK

Really don`t go to the documentation. It is old but objects is still good. You can use WebhookEvent class for it. Just use this action in your controller.

public JsonResult Index(WebhookEvent event)
{
    // event has all the data 
    return Json(new { success = true });
}

Create Payment Notification Webhooks, See our current SDK offerings, which include the /v2/checkout and Payouts use cases. To receive webhook notifications for payment transactions, you must configure NET. var webhook_json = { url: 'https://f615ef32.ngrok.io', event_types: [{ name: After you create the webhook definition object, call the webhook create  Validation. Sometimes it is necessary to run validation when the PayPal buttons are clicked. For example, your page might contain a web form that must be valid before the transaction initiates.

Validation does not work for either IPN sandbox nor Webhook events from the mock. It's stated in the PayPal documentation. Validation only works on the production environment of PayPal.

Webhooks Management API, curl -v -X POST https://api.sandbox.paypal.com/v1/notifications/webhooks \ -H The events that this call generates only serve to validate the connection to the  Web SDK Overview. The PPH Web SDK is a single page script and is designed to be integrated on your final Payment or Checkout page. The following restrictions apply to this SDK: Available only to the US region. Available only on Windows desktop/laptop browsers. Phone/Tablet mobile browsers are not supported. USB is the only supported connection

Validating PayPal Webhook calls with PayPal .NET SDK in Sandbox, I've been trying to set up PayPal Webhooks (in Sandbox mode) to receive notifications about declined and successful payments. My problem is that I can't get  Now that the Webhook is set up, you can see in the left menu under 'Webhooks Simulator', here you can send 'test' webhook events to your URL to test that your code is working. Also, under 'Webhooks Events' you can see all the events that PayPal sent for this application.

PayPal Integration Part 3: PayPal Webhooks, NET MVCWeb Development. This post is part of a series called PayPal Integration. PayPal Integration "href" : "https://api.sandbox.paypal.com/v1/​notifications/webhooks-events/WH-9U51749144910293K-8LX80763BC1567402​" , We have all the information the SDK needs, so perform the validation. Webhooks are HTTP callbacks that receive notification messages for events. To create a webhook at PayPal, users configure a webhook listener and subscribe it to events. A webhook listener is a server that listens at a specific URL for incoming HTTP POST notification messages that are triggered when events occur.

Configuration · paypal/PayPal-NET-SDK Wiki · GitHub, Contribute to paypal/PayPal-NET-SDK development by creating an account on GitHub. PayPal SDK settings --> <paypal> <settings> <add name="mode" value="sandbox" /> <add name="clientId" webhook.id, Specifies the webhook ID to use when validating received webhook events. none Next. Make Your First Call. If you are a non-US developer, see International Developer Questions. You must be in the PayPal Partner Program to make calls on behalf of a third party. Get credentials. To generate REST API credentials for the sandbox and live environments: Log into the Developer Dashboard with your PayPal account credentials.

Comments
  • can you tell me your solution? I always get 500 server errors when receiving paypal webhooks.
  • Haven't gone back to this question yet. I'll leave another comment once I do and verify whether or not it works now.
  • I think this answer is incomplete. Receiving the WebhookEvent as a parameter, how would one go by validating the event than? How would we retrieve the txnId to ensure it's not already processed, how would we ensure the receiver_email is the primary PayPal e-mail, etc.