function create_from_supporter($dia_supporter_key)
 {
     $dia = new DemocracyInAction_API(DIA_API_NODE, DIA_API_USERNAME, DIA_API_PASSWORD);
     $dia->authenticate();
     $supporter = $dia->get('supporter', $dia_supporter_key);
     if (empty($supporter)) {
         WinMember::dia_supporter_not_found();
     }
     $member = WinMember::find_by_email($supporter['Email']);
     if (!$member) {
         $member = new WinMember($supporter['uid']);
     }
     $member->dia =& $dia;
     if (empty($supporter['uid'])) {
         trigger_error('no supporter UID');
         $member->data->mergeData(array(WIN_USERNAME => $supporter['Email'], WIN_DIA_SUPPORTER_KEY => $supporter['supporter_KEY'], 'Email' => $supporter['Email'], 'First_Name' => $supporter['First_Name'], 'Last_Name' => $supporter['Last_Name'], 'Street' => $supporter['Street'], 'City' => $supporter['City'], 'State' => $supporter['State'], 'Zip' => $supporter['Zip'], 'modin' => 20));
         $member->data->save();
         trigger_error(var_export($member->data->id, true));
         trigger_error(var_export($member->data->getData('Email'), true));
         $member->dia->save('supporter', array('Email' => $member->data->getData('Email'), 'email_trigger_KEYS' => '0,' . WIN_SET_PASSWORD_EMAIL_KEY, 'USERNAME' => $member->data->getData('Email')));
         $message = 'You must set your password before you can log in.  <a href="http://www.winonline.org/forgot_password.php?login_type=content">Click here to set your password now </a>';
         AMP_flashMessage($message, $error = 'true');
     }
     return $member;
 }
function dia_connection( $dia_config ) {
    static $dia;
    if( $dia ) return $dia;

    $dia = new DemocracyInAction_API( $dia_config['node'], $dia_config['login'], $dia_config['password'] );

    $dia->authenticate( );

    $dia_groups = $dia->get( 'groups', array( 'limit' => 1) );
    if( !$dia_groups ) { 
        print "auth failed";
        exit;
    }
    return $dia;
}
    $member = WinMember::create_from_supporter($dia_supporter_key);
    $member->create_or_renew($donation_key);
    $member->mark_as_paid_in_dia($dia_supporter_key);
    $member->set_membership_status('active');
    $member->add_to_group($dia_supporter_key, WIN_CURRENT_MEMBERS);
    $member->sync_to_dia();
    if ($winpay->donation_amount >= $sustainer_amount) {
        $member->set_membership_status('sustainer');
        $member->add_to_group($dia_supporter_key, WIN_SUSTAINERS);
    }
    if ($combo || $winpay->donation_amount == '75' || $winpay->donation_amount == '80') {
        trigger_error('combo payment');
        if ($winpay->donation_amount == '75' || $winpay->donation_amount == '80') {
            trigger_error(var_export($member->dia, true));
            $dia = new DemocracyInAction_API(DIA_API_NODE, DIA_API_USERNAME, DIA_API_PASSWORD);
            $dia->authenticate();
            $member->dia =& $dia;
            $member->dia->save('supporter', array('Email' => $member->data->getData('Email'), 'email_trigger_KEYS' => '0,12374', 'USERNAME' => $member->data->getData('Email')));
        }
        //$member->add_to_group($dia_supporter_key, WIN_COMBO_GROUP );
        $member->data->mergeData(array('region' => true));
    }
    ampredirect(WIN_LOGIN_URL);
} else {
    AmpUtility::bail('Sorry, your payment is no longer valid.  Please contact WIN to resolve this issue.');
}
class WinPaymentVerifier
{
    var $membership_cost = 15;
    function WinPaymentVerifier()
    {