Unique id transaction authorizenet (invoice number)

I am using gravityform unique id.
There is an invoice number set by itself.

ex: RI-00001E, RI-00002E, RI-00003E… (sequential type)
Prefix : RI -
Suffix : E
Length : 5
Form ID: 1
Field ID:98

I can check in wordpress Graviryform Entries,
However, it is not possible to check items in authorize.net and email for customer order confirmation.

So I added the php below.

add_filter( 'gform_authorizenet_transaction_pre_capture', 'gpui_set_unique_transaction_id', 10, 5 );
function gpui_set_unique_transaction_id( $transaction, $form_data, $config, $form ) {
 
	$target_form_id = 1; // update "1" to your form ID
	$target_field_id = 98; // update "1" to your field ID
 
	if( $form['id'] == $target_form_id && is_callable( 'gp_unique_id' ) ) {
		$uid = gp_unique_id()->get_sequential_unique_id( $form['id'], $target_field_id );
		$transaction->invoice_num = $uid;
		$_POST[ "input_{$target_field_id}" ] = $uid;
	}
 
	return $transaction;}

Then, the invoice number I set disappears, and it comes out in the form of simple numbers 1,2,3.

The invoice number I set is the invoice number of authorize.net.
I want a transaction.

I don’t know where I went wrong.
Help me plz.

Hi Jeanna,
Can you try updating this line
$uid = gp_unique_id()->get_sequential_unique_id( $form['id'], $target_field_id );
to this
$uid = gp_unique_id()->get_unique( $form['id'], $target_field_id );

If this doesn’t work, can you please get in touch via our support form, so we take a closer look at your request?

Best,

1 Like

Hi Jeanna,

In case you still haven’t been able to get the snippet working, can you give this updated version of the snippet a try and see if it works for you.


add_filter( 'gform_authorizenet_transaction_pre_capture', 'gpui_set_unique_transaction_id', 10, 5 );
function gpui_set_unique_transaction_id( $transaction, $form_data, $config, $form ) {

    $target_form_id = 123; // update "123" to your form ID
    $unique_id_field_id = 4; // update "4" to your Unique ID field ID

    if( $form['id'] == $target_form_id && is_callable( 'gp_unique_id' ) ) {
        foreach ( $form['fields'] as $field ) {
            if ($field->id == $unique_id_field_id){
                $uid = gp_unique_id()->get_unique( $form['id'], $field );
                $transaction->invoice_num = $uid;
                $_POST[ "input_{$unique_id_field_id}" ] = $uid;
            }
        }
    }
    return $transaction;
}
1 Like