Why does my custom html code (for a donation form) appear in a preview but not in the published post?

WordPress strips out iframes by default. Which is why you can see it in the editor but not when you try to save/publish this on your site.

Try enabling iframes by adding this to your themes functions.php file

    /**
     * Add iFrame to allowed wp_kses_post tags
     *
     * @param string $tags Allowed tags, attributes, and/or entities.
     * @param string $context Context to judge allowed tags by. Allowed values are 'post',
     *
     * @return mixed
     */

add_filter( 'wp_kses_allowed_html', 'allow_iframe_in_editor', 10, 2 );
    
function allow_iframe_in_editor( $tags, $context ) {
        if( 'post' === $context ) {
            $tags['iframe'] = array(
                'allowfullscreen' => TRUE,
                'frameborder' => TRUE,
                'height' => TRUE,
                'src' => TRUE,
                'style' => TRUE,
                'width' => TRUE,
            );
        }
        return $tags;
    }