• 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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author nazrulhassanmca

    (@nazrulhassanmca)

    Check this https://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);
    
    
    Thread Starter Ahmad Karim

    (@ahmadkarim)

    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);

    Plugin Author nazrulhassanmca

    (@nazrulhassanmca)

    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

    Thread Starter Ahmad Karim

    (@ahmadkarim)

    Is there any workaround for that?

    Plugin Author nazrulhassanmca

    (@nazrulhassanmca)

    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);
    Plugin Author nazrulhassanmca

    (@nazrulhassanmca)

    Did workaround worked for you ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘What hook/action should I use to get the Authorization Code’ is closed to new replies.