spivurno
1/17/2014 - 8:03 PM

Gravity Forms: Authorize.net Add-on Payment Merge Tags

Gravity Forms: Authorize.net Add-on Payment Merge Tags

<?php
/**
 * Gravity Forms: Authorize.net Add-on Payment Merge Tags
 */
add_filter( 'gform_replace_merge_tags', 'gform_auth_payment_merge_tags' );
function gform_auth_payment_merge_tags( $text ) {

    if( ! class_exists( 'GFAuthorizeNet' ) || empty( GFAuthorizeNet::$transaction_response ) )
        return $text;

    extract( GFAuthorizeNet::$transaction_response ); // gives us $config, $transaction_id, $amount, $setup_fee, $transaction_id

    $text = str_replace( '{transaction_id}', $transaction_id, $text );
    $text = str_replace( '{payment_date}', date( 'm/d/Y' ), $text );
    $text = str_replace( '{payment_amount}', GFCommon::to_money( $amount + $setup_fee ), $text );

    return $text;
}