Adding a rewrite rule to an existing page


I’m trying to add two GET parameters to an existing page, it seems basic and well documented, but I can’t get it right.

I have this existing page (with manually added parameters):

This URL shows the first GET parameter successfully (Amount: x).

I want to rewrite it with:

This URL doesn’t show the first GET parameter.

This is my latest attempt:

function add_rewrites() {
add_rewrite_rule( '^paiement/[0-9]+/[0-9]+?', 'index.php?page_id=1387&amount=$matches[1]&invoice=$matches[2]', 'top' );
add_action( 'init', 'add_rewrites' );

function get_amount_shortcode() {
if ( isset( $_GET['amount'] ) ) {
return $_GET['amount'];
add_shortcode( 'get_amount', 'get_amount_shortcode' );

Between each attempt, I saved the Permalinks settings’ page and emptied the WP Rocket cache.

I also tried by registering the “query vars”, but it had the same result. Does anyone see what I could be missing?