Support » Plugin: Authorize.Net Payment Gateway WooCommerce Addon » What hook/action should I use to get the Authorization Code
What hook/action should I use to get the Authorization Code
-
Hello!
What hook/action should I use to get the Authorize.net Authorization Code. I am using the “woocommerce_payment_complete” action but it seems like the Authorization Code is not yet stored to the database within that time. Any ideas?
Thanks!
-
Check this http://imgur.com/a/7A5Xo
Also there is a bunch of code just after payment complete on plugin as below so you can fetch all metas from db if you have transaction id and order id
$transactionmetas = array( 'approved' => $response->approved, 'declined' => $response->declined, 'error' => $response->error, 'held' => $response->held, 'response_code' => $response->response_code, 'response_subcode' => $response->response_subcode, 'response_reason_code' => $response->response_reason_code, 'authorization_code' => $response->authorization_code, 'card_type' => $response->card_type, 'transaction_type' => $response->transaction_type, 'account_number' => $response->account_number, 'cavv_response' => $response->cavv_response, 'card_code_response' => $response->card_code_response ); add_post_meta( $order_id, '_'.$order_id.'_'.$response->transaction_id.'_metas', $transactionmetas);
-
This reply was modified 4 years, 12 months ago by
nazrulhassanmca.
function create_expandable_order( $order_id ) { $transaction_id = 1234; // I have the actual transaction ID $order_metas = get_post_meta($order_id, "_{$order_id}_{$transaction_id}_metas", true); // the rest of code } add_action( 'woocommerce_payment_complete', 'create_expandable_order', 10 );
This is my code, I am using the woocommerce_payment_complete hook and it seems like the order_meta has not been added to the database yet. What am I doing wrong? When I use this code after the order creation is complete it returns the order_meta
$order_metas = get_post_meta($order_id, "_{$order_id}_{$transaction_id}_metas", true);
Metas are being added to database after order complete
This is entire flow
$wc_order->payment_complete($response->transaction_id); WC()->cart->empty_cart(); $transactionmetas = array( 'approved' => $response->approved, 'declined' => $response->declined, 'error' => $response->error, 'held' => $response->held, 'response_code' => $response->response_code, 'response_subcode' => $response->response_subcode, 'response_reason_code' => $response->response_reason_code, 'authorization_code' => $response->authorization_code, 'card_type' => $response->card_type, 'transaction_type' => $response->transaction_type, 'account_number' => $response->account_number, 'cavv_response' => $response->cavv_response, 'card_code_response' => $response->card_code_response ); add_post_meta( $order_id, '_'.$order_id.'_'.$response->transaction_id.'_metas', $transactionmetas);
So it seems your hook is not going to work
-
This reply was modified 4 years, 12 months ago by
nazrulhassanmca.
-
This reply was modified 4 years, 12 months ago by
nazrulhassanmca.
Is there any workaround for that?
Place below line of code above payment complete
$transactionmetas = array( 'approved' => $response->approved, 'declined' => $response->declined, 'error' => $response->error, 'held' => $response->held, 'response_code' => $response->response_code, 'response_subcode' => $response->response_subcode, 'response_reason_code' => $response->response_reason_code, 'authorization_code' => $response->authorization_code, 'card_type' => $response->card_type, 'transaction_type' => $response->transaction_type, 'account_number' => $response->account_number, 'cavv_response' => $response->cavv_response, 'card_code_response' => $response->card_code_response ); add_post_meta( $order_id, '_'.$order_id.'_'.$response->transaction_id.'_metas', $transactionmetas);
Did workaround worked for you ?
-
This reply was modified 4 years, 12 months ago by
- The topic ‘What hook/action should I use to get the Authorization Code’ is closed to new replies.