Filter reference

Filter reference

There are several action filters available in the Nets Easy plugin. These filters are mainly added so that you as a merchant or developer have the possibility to change what is sent in the requests between your webshop and Nets system.

If you are new to filters in WordPress you can read more in this article.


Modify order / cart data sent in initial create payment request


<?php
/**
 * Filter hook dibs_easy_create_order_args
 * Modify the order/cart data sent to Nets.
 *
 * Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
 */
add_filter( 'dibs_easy_create_order_args', 'my_dibs_easy_create_order_args' );

function my_dibs_easy_create_order_args( $request_args ) {

    // Default value = false, if set to true the checkout will not load any user data.
    $request_args['checkout']['publicDevice'] = true;

    return $request_args;
}

Example how to charge the transaction automatically after reservation have been accepted without calling the Charge API. This will not work if the store offer invoice payments via Nets Easy.

<?php
/**
 * Filter hook dibs_easy_create_order_args
 * Modify the order/cart data sent to Nets.
 *
 * Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
 */
add_filter( 'dibs_easy_create_order_args', 'my_dibs_easy_create_order_args_2' );

function my_dibs_easy_create_order_args_2( $request_args ) {

    // Default value = false, if set to true the transaction will be charged automatically after reservation have been accepted without calling the Charge API.
	// Does not work if payment method is invoice.
    $request_args['checkout']['charge'] = true;

    return $request_args;
}

Modify order / cart data in update payment request


<?php
/**
 * Filter hook dibs_easy_update_order_args
 * Modify the order/cart data sent to Net on update requests.
 *
 * Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
 */
add_filter( 'dibs_easy_update_order_args', 'my_dibs_easy_update_order_args' );

function my_dibs_easy_update_order_args( $request_args ) {

    // Confirm that shipping cost is specified.
    $request_args['shipping']['costSpecified'] = true;

    return $request_args;
}

Modify the timeout time for all http requests sent to Nets


  • nets_easy_set_timeout
  • Usage: Modify the timeout time for all http requests sent to Nets (measured in seconds). Used together with the Nets Easy for WooCommerce plugin.
<?php
/**
 * Filter hook nets_easy_set_timeout
 * Modify the timeout time used during the order creation process in Woocommerce.
 *
 * Used together with Nets Easy for WooCommerce plugin.
 *
 * Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
 */
add_filter( 'nets_easy_set_timeout', 'custom_nets_easy_set_timeout' );
function custom_nets_easy_set_timeout( $time ) {
    return 20;
}
?>