WordPress Verify Woocommerce webhooks in PHP Laravel 6

Today, We want to share with you WordPress Verify Woocommerce webhooks in PHP Laravel 6.In this post we will show you wordpress plugin require another plugin, hear for Receive WooCommerce webhoops in Laravel apps we will give you demo and example for implement.In this post, we will learn about How to Connect Your PHP Based Web App to the WooCommerce Rest API with an example.

WordPress Verify Woocommerce webhooks in PHP Laravel 6

There are the Following The simple About WooCommerce Webhooks verification in PHP Full Information With Example and source code.

As I will cover this Post with live Working example to develop WooCommerce Webhooks verification in Laravel application, so the Send data from Woocommerce to Laravel via webhook is used for this example is following below.

READ :  angularbind - AngularJS Bind Function - Angular Binding Examples

E-junkie: Sell digital downloads online

E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

Also see:

  1. The Top 10+ Best Webinar Software Platforms For 2020-2021
  2. Build Your Future Godaddy Careers And Jobs
  3. Introduction To Web Hosting Services

Example 1: laravel verify Woocommerce WordPress webhook

public function handle($request, Closure $next)
{
    $signature = Request::header('x-wc-webhook-signature');
    //$payload = @file_get_contents('php://input');

    $payload = file_get_contents('php://input');

    //$payload = json_decode( $payload, true);
    $calculated_hmac = base64_encode(hash_hmac('sha256', $payload, $secret_key, true));

    if($signature != $calculated_hmac) {
        return false;
    }

    return $next($request);
}

Example 2: Get data from Woocommerce to Laravel via webhook verify

$all_header =$request->headers->all();     
dump($all_header);

$hmac_header = $request->header('x-wc-webhook-signature');
dump($hmac_header);

$payload = file_get_contents("php://input");
dump($payload);

$website_domain = $request->header('x-wc-webhook-source');
dump($website_domain);

$webs = Webs::where(['website_domain'=>$website_domain])->first(); 
dump($webs);


if($webs){
	$secret_key = $webs->secret_key;
	dump($secret_key);

    $calculated_hmac = base64_encode(hash_hmac('sha256', $payload, $secret_key, true));
    dump($hmac_header);
    dump($calculated_hmac);

    dump($hmac_header . ": ======= :" . $calculated_hmac);
    if($hmac_header == $calculated_hmac){
        dump("laravel verify Woocommerce Wordpress webhook");
    } else {
        dump("error For : laravel verify Woocommerce Wordpress webhook");
    }
    
}

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

READ :  Validating Woocommerce webhook using HMAC in PHP

I hope you get an idea about Validating Woocommerce webhook using HMAC in PHP.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.