Пример #1
0
function seamless_donations_create_donation_from_paypal_data($post_data)
{
    // Create a new donation record from paypal data (if transient no longer exists for some reason)
    dgx_donate_debug_log("About to create donation from paypal post data");
    $new_donation_id = dgx_donate_create_empty_donation_record();
    dgx_donate_debug_log("New donation id = {$new_donation_id}");
    // @todo - loop over the meta map translating paypal keys into our keys
    // @todo ADDRESS
    $payment_gross = isset($_POST['payment_gross']) ? $_POST['payment_gross'] : '';
    $mc_gross = isset($_POST['mc_gross']) ? $_POST['mc_gross'] : '';
    $amount = empty($payment_gross) ? $mc_gross : $payment_gross;
    update_post_meta($new_donation_id, '_dgx_donate_donor_first_name', $_POST['first_name']);
    update_post_meta($new_donation_id, '_dgx_donate_donor_last_name', $_POST['last_name']);
    update_post_meta($new_donation_id, '_dgx_donate_donor_email', $_POST['payer_email']);
    update_post_meta($new_donation_id, '_dgx_donate_amount', $amount);
    // Now build in the donor data
    $first = get_post_meta($new_donation_id, '_dgx_donate_donor_first_name', true);
    $last = get_post_meta($new_donation_id, '_dgx_donate_donor_last_name', true);
    // now move that data into a donor post type
    $donor_name = sanitize_text_field($first . ' ' . $last);
    $donor_slug = sanitize_title($donor_name);
    $post = get_page_by_path($donor_slug, OBJECT, 'donor');
    if ($post == NULL) {
        // create the new custom donor post
        $post_array = array('post_title' => $donor_name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'donor');
        $post_id = wp_insert_post($post_array, true);
    } else {
        $post_id = $post->ID;
    }
    // record the donor id in the donation record
    update_post_meta($new_donation_id, '_dgx_donate_donor_id', $post_id);
    // update the donor detail options
    $email = get_post_meta($new_donation_id, '_dgx_donate_donor_email', true);
    if ($email !== false) {
        update_post_meta($post_id, '_dgx_donate_donor_email', $email);
    }
    // update the donations to point to this donor id
    $donations_list = get_post_meta($post_id, '_dgx_donate_donor_donations', true);
    if ($donations_list !== false) {
        $donations_list .= ',' . $new_donation_id;
    } else {
        // this is the first donation for this donor
        $donations_list = $new_donation_id;
    }
    update_post_meta($post_id, '_dgx_donate_donor_donations', $donations_list);
    dgx_donate_debug_log("Done with dgx_donate_create_donation_from_paypal_data, returning new id {$new_donation_id}");
    return $new_donation_id;
}
Пример #2
0
function dgx_donate_create_donation_from_paypal_data($post_data)
{
    // Create a new donation record from paypal data (if transient no longer exists for some reason)
    dgx_donate_debug_log("about to create donation from paypal post data");
    $new_donation_id = dgx_donate_create_empty_donation_record();
    dgx_donate_debug_log("new donation id = {$new_donation_id}");
    // @todo - loop over the meta map translating paypal keys into our keys
    // @todo ADDRESS
    $payment_gross = isset($_POST['payment_gross']) ? $_POST['payment_gross'] : '';
    $mc_gross = isset($_POST['mc_gross']) ? $_POST['mc_gross'] : '';
    $amount = empty($payment_gross) ? $mc_gross : $payment_gross;
    update_post_meta($new_donation_id, '_dgx_donate_donor_first_name', $_POST['first_name']);
    update_post_meta($new_donation_id, '_dgx_donate_donor_last_name', $_POST['last_name']);
    update_post_meta($new_donation_id, '_dgx_donate_donor_email', $_POST['payer_email']);
    update_post_meta($new_donation_id, '_dgx_donate_amount', $amount);
    dgx_donate_debug_log("done with dgx_donate_create_donation_from_paypal_data, returning new id {$new_donation}");
    return $new_donation_id;
}
Пример #3
0
function seamless_donations_create_donation_from_paypal_data()
{
    // PROBABLY DEPRECATED
    // Create a new donation record from paypal data (if transient no longer exists for some reason)
    // with the addition of the transaction audit table in 4.0.5, this will probably not ever be called
    dgx_donate_debug_log("About to create donation from paypal post data");
    $new_donation_id = dgx_donate_create_empty_donation_record();
    dgx_donate_debug_log("New donation id = {$new_donation_id}");
    // @todo - loop over the meta map translating paypal keys into our keys
    // @todo ADDRESS
    $payment_gross = isset($_POST['payment_gross']) ? $_POST['payment_gross'] : '';
    $mc_gross = isset($_POST['mc_gross']) ? $_POST['mc_gross'] : '';
    $amount = empty($payment_gross) ? $mc_gross : $payment_gross;
    update_post_meta($new_donation_id, '_dgx_donate_donor_first_name', $_POST['first_name']);
    update_post_meta($new_donation_id, '_dgx_donate_donor_last_name', $_POST['last_name']);
    update_post_meta($new_donation_id, '_dgx_donate_donor_email', $_POST['payer_email']);
    update_post_meta($new_donation_id, '_dgx_donate_amount', $amount);
    $donor_id = seamless_donations_update_donor_data($new_donation_id);
    // update the donor detail options
    $email = get_post_meta($new_donation_id, '_dgx_donate_donor_email', true);
    if ($email !== false) {
        update_post_meta($donor_id, '_dgx_donate_donor_email', $email);
    }
    dgx_donate_debug_log("Done with dgx_donate_create_donation_from_paypal_data, returning new id {$new_donation_id}");
    return $new_donation_id;
}