WordPress Verify Woocommerce webhooks in PHP Laravel 6

Also Read : first love marriage in the world

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 :  Laravel Multiple Order By Columns
Also Read : tamilblasters, 9kmovie, filmygod, hdhub4u, vegamovies, tamilrockers website link and 1377x proxy.

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 :  Angular Sum all properties value in JSON object

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.