Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pt 1131 woocommerce webhook issue #110

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: mondu-ai, arthurmmoreira, tikohov20
Tags: mondu, woocommerce, e-commerce, ecommerce, store, sales, sell, woo, woo commerce, shop, cart, shopping cart, sell online, checkout, payment, payments, bnpl, b2b
Requires at least: 5.9.0
Tested up to: 6.2.2
Stable tag: 2.1.4
Stable tag: 2.1.5
Requires PHP: 7.4
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -57,6 +57,10 @@ Check out [Frequently Asked Questions](https://www.mondu.ai/faq) in the Mondu we

== Changelog ==

= 2.1.5 =

* Changed webhook signature validation logic

= 2.1.4 =

* Fix deprecated setting $instructions on payments
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
== Changelog ==

= 2.1.5 =

* Changed webhook signature validation logic

= 2.1.4 =

* Fix deprecated setting $instructions on payments
Expand Down
2 changes: 1 addition & 1 deletion mondu-buy-now-pay-later.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
die( 'Direct access not allowed' );
}

define( 'MONDU_PLUGIN_VERSION', '2.1.4' );
define( 'MONDU_PLUGIN_VERSION', '2.1.5' );
define( 'MONDU_PLUGIN_FILE', __FILE__ );
define( 'MONDU_PLUGIN_PATH', __DIR__ );
define( 'MONDU_PLUGIN_BASENAME', plugin_basename(MONDU_PLUGIN_FILE) );
Expand Down
6 changes: 4 additions & 2 deletions src/Mondu/Mondu/Controllers/WebhooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public function register_routes() {
public function index( WP_REST_Request $request ) {
$verifier = new SignatureVerifier();
$params = $request->get_json_params();
$signature_payload = $request->get_header('X-MONDU-SIGNATURE');
$signature = $verifier->create_hmac($params);
$topic = isset($params['topic']) ? $params['topic'] : null;

$body = $request->get_body();
$signature_payload = $request->get_header('X-MONDU-SIGNATURE');
$signature = $verifier->create_hmac($body);

Helper::log([
'webhook_topic' => $topic,
'params' => $params,
Expand Down
2 changes: 1 addition & 1 deletion src/Mondu/Mondu/Models/SignatureVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function set_secret( $secret ) {
}

public function create_hmac( $payload ) {
return hash_hmac('sha256', wp_json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT | JSON_HEX_AMP), $this->secret);
return hash_hmac('sha256', $payload, $this->secret);
}


Expand Down