Filters
// Modify the request before it is sent to the gateway
add_filter( 'nmiwp_request_args', function( $args, $order ) {
$args['order_description'] = 'Order ' . $order->get_order_number();
return $args;
}, 10, 2 );
// Change the transaction type per order
add_filter( 'nmiwp_transaction_type', function( $type, $order ) {
return $order->get_total() > 1000 ? 'auth' : 'sale';
}, 10, 2 );
// Decide whether Level III data is attached
add_filter( 'nmiwp_send_level3', '__return_true' );
// Rewrite the message shown to a customer on decline
add_filter( 'nmiwp_decline_message', function( $message, $code ) {
return __( 'That card was declined. Try another card or use bank transfer.', 'my-theme' );
}, 10, 2 );
Actions
// After a successful transaction
add_action( 'nmiwp_payment_complete', function( $order, $response ) {
// $response contains transaction id, auth code, avs and cvv results
}, 10, 2 );
// After a declined transaction
add_action( 'nmiwp_payment_failed', function( $order, $response ) {
// log, notify, or flag for review
}, 10, 2 );
// When a payment method is vaulted
add_action( 'nmiwp_method_saved', function( $user_id, $token ) {}, 10, 2 );
Styling hosted fields
Card inputs are iframes served by the gateway, so your stylesheet cannot reach inside them. Pass styles through the configuration filter instead.
add_filter( 'nmiwp_field_styles', function( $styles ) {
$styles['input'] = 'font-size:16px;color:#16241F;font-family:inherit;';
return $styles;
} );
Logging
Logs are written through the WooCommerce logger under the nmiwp source, with card numbers, CVV and the security key removed before writing. Do not disable the redaction filter on a production site.