Loading...
X

Add transaction ID to notifications

5 0

The transaction id can be used in notifications via a custom merge tag, put this code in your theme’s functions.php file (choose the one for your payment gateway).

Pay Pal Pro

add_filter( 'gform_replace_merge_tags', 'replace_transaction_id', 10, 7 );
function replace_transaction_id( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
    $transaction_id = class_exists( 'GFPayPalPro' ) ? GFPayPalPro::$transaction_response['transaction_id'] : '';
    $transaction_id = empty( $transaction_id ) ? rgar( $entry, 'transaction_id' ) : $transaction_id;
    $text = str_replace( '{transaction_id}', $transaction_id, $text );

    return $text;
}

PayPal Payments Pro

add_filter( 'gform_replace_merge_tags', 'replace_transaction_id', 10, 7 );
function replace_transaction_id( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
   $transaction_id = esc_html( rgar( $entry, 'transaction_id' ) ); // updated for PayPal Payments Pro 2.0 and newer
   $text = str_replace( '{transaction_id}', $transaction_id, $text );

    return $text;
}

Authorize.Net

add_filter( 'gform_replace_merge_tags', 'replace_transaction_id', 10, 7 );
function replace_transaction_id( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
// NOTE: This function will only work for Authorize.net add-on 2.0.x


    // name of our custom merge tag
    $merge_tag = '{transaction_id}';

    // added for GF 1.9.x
    if ( strpos( $text, $merge_tag ) === false || empty( $entry ) || empty( $form ) ) {
        return $text;
    }

    $transaction_id = rgar( $entry, 'transaction_id' );
    $text = str_replace( $merge_tag, $transaction_id, $text );

    return $text;
}
One observation on “Add transaction ID to notifications

Leave Your Observation

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site!