Last active
March 15, 2022 21:59
-
-
Save maxrice/646adbb3bf0b73290d31 to your computer and use it in GitHub Desktop.
WooCommerce Authorize.net CIM: Adjust authorize-only transaction order status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sv_wc_auth_net_cim_tweak_held_order_status( $order_status, $order, $response ) { | |
if ( 'on-hold' === $order_status && $response instanceof SV_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', 'sv_wc_auth_net_cim_tweak_held_order_status', 10, 3 ); |
@wvega that's a good improvement, thanks!
@wvega and @maxrice - Can either of you please tell me where exactly to use this snippet? I am trying to force my auth.net to make the status "processing" instead of "on hold", when "authorization only" is used in the payment plugin. I placed this into my child theme's functions.php, but it does not appear to be working. Any input is appreciated!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this snippet @maxrice, I found it on https://docs.woocommerce.com/document/authorize-net-cim/#section-27.
I noticed that the
SV_WC_Payment_Gateway_API_Response
interface is under the Plugin Framework namespace, at least in Authorize.Net 3.0.5. Theinstanceof
verification is currently failing because that. I'm guessing that we need to use the fully qualified name of the interface, but I also I believe that the Plugin Framework namespace changes frequently between updates, so that makes it a little inconvenient to keep the snippet up to date.As an alternative, I replaced that part of the condition with
$response instanceof WC_Authorize_Net_CIM_API_Transaction_Response
. That fixed the snippet on my end.