Authorize.Net

For Developers

Estimated reading: 2 minutes

If anyone wants to change any features from direct PHP code then here are some examples, If you understand the core correctly and looking for more customization options then you can improve the code directly.


How to change transaction’s order status?

Change authorize-only transaction order status.

<?php

// Transaction Order Status

function iwp_wc_auth_net_cim_tweak_held_order_status( $order_status, $order, $response ) {

	if ( 'on-hold' === $order_status && $response instanceof IWP_WC_Payment_Gateway_API_Response && $response->transaction_approved() ) {
		$order_status = 'processing';
	}

	return $order_status;
}
add_filter( 'wc_payment_gateway_authorize_net_cim_credit_card_held_order_status', 'iwp_wc_auth_net_cim_tweak_held_order_status', 10, 3 );

Add this code snippet in wc-auth-net-cim-adjust-auth-only-order-status.php


How to make save to account default selected?

Default active the checkbox on the payment form.

<?php

// Save to account

function wc_auth_net_cim_save_payment_method_default_checked( $html, $form ) {

	if ( empty( $html ) || $form->tokenization_forced() ) {
		return $html;
	}
	
	return str_replace( 'type="checkbox"', 'type="checkbox" checked="checked"', $html );
}
add_filter( 'wc_authorize_net_cim_credit_card_payment_form_save_payment_method_checkbox_html', 'wc_auth_net_cim_save_payment_method_default_checked', 10, 2 );

add this code snippet in wc-auth-net-cim-save-payment-method-default-checked.php

EASY ACCESS