PTNUSASATUINTIARTHA-DOKU / doku-woocommerce-plugin

Official WooCommerce Plugin for DOKU. Visit https://jokul.doku.com for more information about the product and https://jokul.doku.com/docs for the technical documentation.
6 stars 8 forks source link

Notification doesn't work in root domain site #1

Closed ariefrizkyr closed 3 years ago

ariefrizkyr commented 3 years ago

I tried to install the plugin to the root domain, however, the notification handling is not working and it didn't update the order status.

I found that the Common/JokulUtils.php code looks like this:

public function generateSignatureNotification($headers, $body, $secret)
    {
        $digest = base64_encode(hash('sha256', $body, true));
        $rawSignature = "Client-Id:" . $headers['Client-Id'] . "\n"
            . "Request-Id:" . $headers['Request-Id'] . "\n"
            . "Request-Timestamp:" . $headers['Request-Timestamp'] . "\n"
            . "Request-Target:" ."/wordpress/wp-json/jokul/notification". "\n"
            . "Digest:" . $digest;

        $signature = base64_encode(hash_hmac('sha256', $rawSignature, htmlspecialchars_decode($secret), true));
        return 'HMACSHA256=' . $signature;
    }

The Request-Target is set fixed into the /wordpress/ path. I will make a pull request to set the path relative.

So, if my website is https://example.com/ then it will not work. Also, if my website is https://example.com/other-path/ It will not work neither.