function seamless_donations_generate_donation_form() { $form_action = plugins_url('/seamless-donations-payment.php', __FILE__); //$session_id = $GLOBALS['seamless_donations_session_id']; //$session_id = 'dgxdonate_' . substr ( session_id (), 0, 10 ) . '_' . time (); $session_id = seamless_donations_get_guid('sd'); dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('PREPARING DONATION FORM'); dgx_donate_debug_log("Seamless Donations Version: " . dgx_donate_get_version()); dgx_donate_debug_log("User browser: " . seamless_donations_get_browser_name()); dgx_donate_debug_log("Assigning hidden field session ID to {$session_id}"); dgx_donate_debug_log("Form action: {$form_action}"); $form = array('id' => 'seamless-donations-form', 'name' => 'seamless-donations-form', 'action' => $form_action, 'method' => 'post', 'elements' => array('session_id_element' => array('type' => 'hidden', 'group' => '_dgx_donate_session_id', 'value' => $session_id), 'redirect_url_element' => array('type' => 'hidden', 'group' => '_dgx_donate_redirect_url', 'value' => $form_action), 'success_url_element' => array('type' => 'hidden', 'group' => '_dgx_donate_success_url', 'value' => dgx_donate_paypalstd_get_current_url()))); // Start the outermost container $form['outermost_container'] = array('id' => 'dgx-donate-container'); // Pick and choose the built in sections this gateway supports $warning_section = seamless_donations_donation_form_warning_section(); if (is_array($warning_section)) { $form['outermost_container']['warning_section'] = $warning_section; } $form['outermost_container']['donation_section'] = seamless_donations_get_donation_section(); $form['outermost_container']['tribute_section'] = seamless_donations_get_tribute_section(); $form['outermost_container']['donor_section'] = seamless_donations_get_donor_section(); $form['outermost_container']['billing_section'] = seamless_donations_get_billing_section(); $form['outermost_container']['paypal_section'] = seamless_donations_get_paypal_section(); $form['outermost_container']['submit_section'] = seamless_donations_get_submit_section(); $form = apply_filters('seamless_donations_form_section_order', $form); // build and display the form $html = seamless_donations_forms_engine($form); return $html; }
function seamless_donations_generate_donation_form() { $process_form_via = get_option('dgx_donate_form_via_action'); // if the option isn't defined, returns false, if defined = '1' // this option exists for host compatibility, where some hosts won't send a form // to another .php file for processing if ($process_form_via == '1') { $form_action = get_permalink(); $process_form_via_status = 'initiating page'; } else { // redirect to seamless-donations-payment.php, which may cause some hosting errors // but is the default behavior since early 4.0.x releases $form_action = plugins_url('/seamless-donations-payment.php', __FILE__); $process_form_via_status = 'external php file'; } $browser_based_ids = get_option('dgx_donate_browser_uuid'); if ($browser_based_ids == '1') { $session_id = 'browser-uuid'; // generate UUID in JavaScript } else { $session_id = seamless_donations_get_guid('sd'); // UUID on server } dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('PREPARING DONATION FORM'); dgx_donate_debug_log("Seamless Donations Version: " . dgx_donate_get_version()); dgx_donate_debug_log("User browser: " . seamless_donations_get_browser_name()); dgx_donate_debug_log("Assigning hidden field session ID to {$session_id}"); dgx_donate_debug_log("Form action via: {$process_form_via_status}"); dgx_donate_debug_log("Form action: {$form_action}"); $form = array('id' => 'seamless-donations-form', 'name' => 'seamless-donations-form', 'action' => $form_action, 'method' => 'post', 'elements' => array('session_id_element' => array('type' => 'hidden', 'group' => '_dgx_donate_session_id', 'value' => $session_id), 'redirect_url_element' => array('type' => 'hidden', 'group' => '_dgx_donate_redirect_url', 'value' => $form_action), 'success_url_element' => array('type' => 'hidden', 'group' => '_dgx_donate_success_url', 'value' => dgx_donate_paypalstd_get_current_url()), 'process_via' => array('type' => 'hidden', 'group' => '_dgx_donate_form_via', 'value' => $process_form_via))); // Start the outermost container $form['outermost_container'] = array('id' => 'dgx-donate-container'); // Pick and choose the built in sections this gateway supports $warning_section = seamless_donations_donation_form_warning_section(); if (is_array($warning_section)) { $form['outermost_container']['warning_section'] = $warning_section; } $form['outermost_container']['donation_section'] = seamless_donations_get_donation_section(); $form['outermost_container']['tribute_section'] = seamless_donations_get_tribute_section(); $form['outermost_container']['donor_section'] = seamless_donations_get_donor_section(); $form['outermost_container']['billing_section'] = seamless_donations_get_billing_section(); $form['outermost_container']['paypal_section'] = seamless_donations_get_paypal_section(); $form['outermost_container']['submit_section'] = seamless_donations_get_submit_section(); $form = apply_filters('seamless_donations_form_section_order', $form); // build and display the form $html = seamless_donations_forms_engine($form); return $html; }
function validate_page_slug_seamless_donations_admin_settings_callback($_submitted_array, $_existing_array, $_setup_object) { $_submitted_array = apply_filters('validate_page_slug_seamless_donations_admin_settings_callback', $_submitted_array, $_existing_array, $_setup_object); $section = seamless_donations_get_submitted_admin_section($_submitted_array); switch ($section) { case 'seamless_donations_admin_settings_section_emails': // SAVE EMAILS // $email_list = $_submitted_array[$section]['dgx_donate_notify_emails']; $email_array = explode(',', $email_list); $clean_email_array = array(); foreach ($email_array as $email) { $email = trim($email); $email = sanitize_email($email); array_push($clean_email_array, $email); if (!is_email($email)) { $_aErrors[$section]['dgx_donate_notify_emails'] = __('Valid email address required.', 'seamless-donations'); $_setup_object->setFieldErrors($_aErrors); $_setup_object->setSettingNotice(__('There were errors in your submission.', 'seamless-donations')); return $_existing_array; } } $email_list = implode(',', $clean_email_array); update_option('dgx_donate_notify_emails', $email_list); $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_settings_section_paypal': // SAVE PAYPAL // $email = $_submitted_array[$section]['dgx_donate_paypal_email']; $email = sanitize_email($email); $option = $_submitted_array[$section]['dgx_donate_paypal_server']; if (!is_email($email)) { $_aErrors[$section]['dgx_donate_paypal_email'] = __('Valid email address required.', 'seamless-donations'); $_setup_object->setFieldErrors($_aErrors); $_setup_object->setSettingNotice(__('There were errors in your submission.', 'seamless-donations')); return $_existing_array; } update_option('dgx_donate_paypal_email', $email); update_option('dgx_donate_paypal_server', $option); update_option('dgx_donate_obsolete_legacy_ssl_mode', $_submitted_array[$section]['dgx_donate_obsolete_legacy_ssl_mode']); $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_settings_section_hosts': // SAVE HOSTS // $settings_notice = 'Form updated successfully.'; update_option('dgx_donate_form_via_action', $_submitted_array[$section]['dgx_donate_form_via_action']); update_option('dgx_donate_browser_uuid', $_submitted_array[$section]['dgx_donate_browser_uuid']); update_option('dgx_donate_ignore_form_nonce', $_submitted_array[$section]['dgx_donate_ignore_form_nonce']); $_setup_object->setSettingNotice($settings_notice, 'updated'); break; case 'seamless_donations_admin_settings_section_tweaks': // SAVE TWEAKS // $settings_notice = 'Form updated successfully.'; update_option('dgx_donate_compact_menus', $_submitted_array[$section]['dgx_donate_compact_menus']); $_setup_object->setSettingNotice($settings_notice, 'updated'); break; case 'seamless_donations_admin_settings_section_tabs': // SAVE TABS // update_option('dgx_donate_display_admin_donors_tab', 'show'); update_option('dgx_donate_display_admin_donations_tab', 'show'); update_option('dgx_donate_display_admin_funds_tab', 'show'); $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_settings_section_debug': // SAVE DEBUG // $settings_notice = 'Form updated successfully.'; update_option('dgx_donate_debug_mode', $_submitted_array[$section]['dgx_donate_debug_mode']); update_option('dgx_donate_log_obscure_name', $_submitted_array[$section]['dgx_donate_log_settings'][0]); if ($_submitted_array[$section]['dgx_donate_rebuild_xref_by_name'] == "1") { dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('INDEX CROSS-REFERENCE ATTEMPTED'); seamless_donations_rebuild_donor_index(); seamless_donations_rebuild_funds_index(); seamless_donations_rebuild_donor_anon_flag(); $settings_notice .= ' Cross-reference index rebuild by name complete.'; dgx_donate_debug_log('Cross-reference index rebuild by name complete.'); } $_setup_object->setSettingNotice($settings_notice, 'updated'); break; case 'seamless_donations_admin_settings_section_extension': // LET EXTENSIONS DO THE PROCESSING break; default: $_setup_object->setSettingNotice(__('There was an unexpected error in your entry.', 'seamless-donations')); } }
function handle_unrecognized_ipn($paypal_response) { dgx_donate_debug_log("IPN failed (unrecognized response) for sessionID {$this->session_id}"); dgx_donate_debug_log("==> " . $paypal_response); }
function dgx_donate_send_donation_notification($donationID) { $fromEmail = get_option('dgx_donate_reply_email'); $subject = "[Seamless Donations] " . __('A donation has been received', 'dgx-donate'); $body = __('A donation has been received. Here are some details about the donation.', 'dgx-donate') . "\n"; $body .= "\n"; $body .= "Donor:\n"; $firstName = get_post_meta($donationID, '_dgx_donate_donor_first_name', true); $lastName = get_post_meta($donationID, '_dgx_donate_donor_last_name', true); $city = get_post_meta($donationID, '_dgx_donate_donor_city', true); $state = get_post_meta($donationID, '_dgx_donate_donor_state', true); $zip = get_post_meta($donationID, '_dgx_donate_donor_zip', true); $donorEmail = get_post_meta($donationID, '_dgx_donate_donor_email', true); $body .= "{$firstName} {$lastName}\n"; $body .= "{$city} {$state} {$zip}\n"; $body .= "{$donorEmail}\n"; $body .= "\n"; $tributeGift = get_post_meta($donationID, '_dgx_donate_tribute_gift', true); if (!empty($tributeGift)) { $body .= __('NOTE: The donor is making this donation in honor of / in memory of someone.', 'dgx-donate') . " "; $body .= __('Please see the donation details (using the link below) for more information.', 'dgx-donate') . "\n"; $body .= "\n"; } $employer_match = get_post_meta($donationID, '_dgx_donate_employer_match', true); if (!empty($employer_match)) { $body .= __('NOTE: The donor is making this donation with an employer match.', 'dgx-donate') . " "; $body .= __('Please see the donation details (using the link below) for more information.', 'dgx-donate') . "\n"; $body .= "\n"; } $amount = get_post_meta($donationID, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donationID); $formattedDonationAmount = dgx_donate_get_plain_formatted_amount($amount, 2, $currency_code, true); $body .= __('Donation:', 'dgx-donate') . "\n"; $body .= __('Amount:', 'dgx-donate') . " {$formattedDonationAmount}\n"; $body .= "\n"; $body .= __('Click on the following link to view all details for this donation:', 'dgx-donate') . "\n"; $secureDonateLink = dgx_donate_get_donation_detail_link($donationID); $donateLink = str_replace("https:", "http:", $secureDonateLink); $body .= $donateLink; $body .= "\n"; // Loop on addresses $notifyEmails = get_option('dgx_donate_notify_emails'); $notifyEmailAr = explode(',', $notifyEmails); foreach ($notifyEmailAr as $notifyEmail) { $notifyEmail = trim($notifyEmail); if (!empty($notifyEmail)) { $headers = "From: {$fromEmail}\r\n"; $mail_sent = wp_mail($notifyEmail, $subject, $body, $headers); if (!$mail_sent) { dgx_donate_debug_log("Error: Could NOT send mail."); dgx_donate_debug_log("Subject: {$subject}"); dgx_donate_debug_log("To Email: {$notifyEmail}"); } } } }
$paypal_email = get_option('dgx_donate_paypal_email'); $currency_code = get_option('dgx_donate_currency'); // fill in the rest of the form data, overriding if necessary if ($post_data['BUSINESS'] == '') { $post_data['BUSINESS'] = $paypal_email; } if ($post_data['NOTIFY_URL'] == '') { $post_data['NOTIFY_URL'] = $notify_url; } dgx_donate_debug_log("Computed RETURN value: '" . $post_data['RETURN'] . "'"); $post_args .= "business=" . urlencode($post_data['BUSINESS']) . "&"; $post_args .= "return=" . urlencode($post_data['RETURN']) . "&"; $post_args .= "notify_url=" . urlencode($post_data['NOTIFY_URL']) . "&"; $post_args .= "item_name=" . urlencode($post_data['ITEM_NAME']) . "&"; $post_args .= "quantity=" . urlencode('1') . "&"; $post_args .= "currency_code=" . urlencode($currency_code) . "&"; $post_args .= "no_note=" . urlencode('1') . "&"; $payPalServer = get_option('dgx_donate_paypal_server'); if ($payPalServer == "SANDBOX") { $form_action = "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $form_action = "https://www.paypal.com/cgi-bin/webscr"; } // var_dump ( $post_args ); // // die(); // dgx_donate_debug_log ( "Post args: " . $post_args ); dgx_donate_debug_log("Redirecting to PayPal... now!"); wp_redirect($form_action . $post_args); exit; }
function dgx_donate_paypalstd_ajax_checkout() { // Log dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('DONATION TRANSACTION STARTED'); dgx_donate_debug_log('Test mode: B'); $php_version = phpversion(); dgx_donate_debug_log("PHP Version: {$php_version}"); dgx_donate_debug_log("Seamless Donations Version: " . dgx_donate_get_version()); dgx_donate_debug_log("User browser: " . seamless_donations_get_browser_name()); dgx_donate_debug_log('IPN: ' . plugins_url('/dgx-donate-paypalstd-ipn.php', __FILE__)); $nonce = $_POST['nonce']; if (!wp_verify_nonce($nonce, 'dgx-donate-nonce')) { dgx_donate_debug_log('Payment process nonce validation failure.'); die('Access Denied.'); } else { dgx_donate_debug_log("Payment process nonce {$nonce} validated."); } $sd4_mode = get_option('dgx_donate_start_in_sd4_mode'); $session_id = $_POST['sessionID']; dgx_donate_debug_log("Session ID retrieved from _POST: {$session_id}"); // now attempt to retrieve session data to see if it already exists (which would trigger an error) if ($sd4_mode == false) { // use the old transient system $session_data = get_transient($session_id); dgx_donate_debug_log('Looking for pre-existing session data (legacy transient mode): ' . $session_id); } else { // use the new guid/audit db system $session_data = seamless_donations_get_audit_option($session_id); dgx_donate_debug_log('Looking for pre-existing session data (guid/audit db mode): ' . $session_id); } if ($session_data !== false) { dgx_donate_debug_log('Session data already exists, returning false'); die; } else { dgx_donate_debug_log('Duplicate session data not found. Payment process data assembly can proceed.'); if ($_POST['honoreeCountry'] == 'US') { $_POST['honoreeProvince'] = ''; } else { if ($_POST['honoreeCountry'] == 'CA') { $_POST['honoreeState'] = ''; } else { if ($_POST['honoreeCountry'] == '') { //default to US if country blank $_POST['honoreeCountry'] = 'US'; } else { $_POST['honoreeState'] = ''; $_POST['honoreeProvince'] = ''; } } } if ($_POST['country'] == 'US') { $_POST['province'] = ''; } else { if ('CA' == $_POST['country']) { $_POST['state'] = ''; } else { if ($_POST['country'] == '') { $_POST['country'] = 'US'; } else { $_POST['state'] = ''; $_POST['province'] = ''; } } } // Resolve the donation amount if (strcasecmp($_POST['donationAmount'], "OTHER") == 0) { $_POST['amount'] = floatval($_POST['userAmount']); } else { $_POST['amount'] = floatval($_POST['donationAmount']); } if ($_POST['amount'] < 1.0) { $_POST['amount'] = 1.0; } // Repack the POST $acceptedFields = apply_filters('seamless_donations_accepted_fields', array('referringUrl', 'sessionID', 'amount', 'repeating', 'designated', 'designatedFund', 'tributeGift', 'memorialGift', 'honoreeName', 'honoreeEmail', 'honoreeAddress', 'honoreeCity', 'honoreeState', 'honoreeProvince', 'honoreeCountry', 'honoreeZip', 'honoreeEmailName', 'honoreePostName', 'firstName', 'lastName', 'phone', 'email', 'addToMailingList', 'address', 'address2', 'city', 'state', 'province', 'country', 'zip', 'increaseToCover', 'anonymous', 'paymentMethod', 'employerMatch', 'employerName', 'occupation', 'ukGiftAid')); foreach ($acceptedFields as $key => $value) { $upper = strtoupper($value); $post_data[$upper] = $_POST[$value]; } $post_data['PAYMENTMETHOD'] = 'PayPal'; // Sanitize the data (remove leading, trailing spaces quotes, brackets) foreach ($post_data as $key => $value) { $temp = trim($value); $temp = str_replace("\"", "", $temp); $temp = strip_tags($temp); $post_data[$key] = $temp; } if ($sd4_mode == false) { // Save it all in a transient $transient_token = $post_data['SESSIONID']; // Capture the result of the transient update call $transient_status = set_transient($transient_token, $post_data, 7 * 24 * 60 * 60); // 7 days // if transient could not be set, fail and die if ($transient_status === false) { $returnMessage = '1|Failed to save transient'; echo $returnMessage; wp_die(); } dgx_donate_debug_log('Saving transaction data using legacy mode'); } else { seamless_donations_update_audit_option($session_id, $post_data); dgx_donate_debug_log('Saving transaction data using guid/audit db mode'); } // more log data dgx_donate_debug_log('Name: ' . $post_data['FIRSTNAME'] . ' ' . $post_data['LASTNAME']); dgx_donate_debug_log('Amount: ' . $post_data['AMOUNT']); dgx_donate_debug_log("Preparation complete. It is now up to PayPal to return data via IPN."); // Return success to AJAX caller as " code | message " // A return code of 0 indicates success, and the returnMessage is ignored // A return code of 1 indicates failure, and the returnMessage contains the error message $returnMessage = "0|SUCCESS"; echo $returnMessage; wp_die(); // this is required to return a proper result } }
function seamless_donations_init_session() { $session_id = seamless_donations_get_guid('sd'); $GLOBALS['seamless_donations_session_id'] = $session_id; dgx_donate_debug_log('Session ID (guid/audit db mode): ' . $session_id); }
static function show($donation_id) { // Validate User if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.', 'seamless-donations')); } // Get form arguments $delete_donation = ""; if (isset($_POST['delete_donation'])) { $delete_donation = $_POST['delete_donation']; } // If we have form arguments, we must validate the nonce if (count($_POST)) { $nonce = $_POST['dgx_donate_donation_detail_nonce']; if (!wp_verify_nonce($nonce, 'dgx_donate_donation_detail_nonce')) { wp_die(__('You do not have sufficient permissions to access this page.', 'seamless-donations')); } } echo "<div class='wrap'>\n"; echo "<div id='icon-edit-pages' class='icon32'></div>\n"; echo "<h2>" . esc_html__('Donation Detail', 'seamless-donations') . "</h2>\n"; $donation_deleted = false; if ("true" == $delete_donation) { dgx_donate_debug_log("Donation (ID: {$donation_id}) deleted"); wp_delete_post($donation_id, true); /* true = force delete / bypass trash */ $donation_deleted = true; $message = __('Donation deleted', 'seamless-donations'); } // Display any message if (!empty($message)) { echo "<div id='message' class='updated below-h2'>\n"; echo "<p>" . esc_html($message) . "</p>\n"; echo "</div>\n"; } if (!$donation_deleted) { echo "<div id='col-container'>\n"; echo "<div id='col-right'>\n"; echo "<div class='col-wrap'>\n"; echo "<h3>" . esc_html__('Donation Details', 'seamless-donations') . "</h3>\n"; echo "<table class='widefat'><tbody>\n"; $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); echo "<tr>"; echo "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($month . "/" . $day . "/" . $year . " " . $time) . "</td></tr>\n"; $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); echo "<tr>"; echo "<th>" . esc_html__('Amount', 'seamless-donations') . "</th>"; echo "<td>" . $formatted_amount . "</td></tr>\n"; $add_to_mailing_list = get_post_meta($donation_id, '_dgx_donate_add_to_mailing_list', true); if (!empty($add_to_mailing_list)) { $add_to_mailing_list = __('Yes', 'seamless-donations'); } else { $add_to_mailing_list = __('No', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Add to Mailing List?', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($add_to_mailing_list) . "</td></tr>\n"; $anonymous = get_post_meta($donation_id, '_dgx_donate_anonymous', true); if (empty($anonymous)) { $anonymous = __('No', 'seamless-donations'); } else { $anonymous = __('Yes', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Would like to remain anonymous?', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($anonymous) . "</td></tr>\n"; $fund_name = __('Undesignated', 'seamless-donations'); $designated = get_post_meta($donation_id, '_dgx_donate_designated', true); if (!empty($designated)) { $fund_name = get_post_meta($donation_id, '_dgx_donate_designated_fund', true); } echo "<tr><th>" . esc_html__('Designated Fund', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($fund_name) . "</td></tr>\n"; $employer_match = get_post_meta($donation_id, '_dgx_donate_employer_match', true); if (empty($employer_match)) { $employer_match_message = __('No', 'seamless-donations'); } else { $employer_match_message = __('Yes', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Employer Match', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($employer_match_message) . "</td></tr>\n"; $employer_name = get_post_meta($donation_id, '_dgx_donate_employer_name', true); if (empty($employer_name)) { $employer_name_message = '-'; } else { $employer_name_message = $employer_name; } echo "<tr><th>" . esc_html__('Employer', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($employer_name_message) . "</td></tr>\n"; $occupation = get_post_meta($donation_id, '_dgx_donate_occupation', true); if (empty($occupation)) { $occupation_message = '-'; } else { $occupation_message = $occupation; } echo "<tr><th>" . esc_html__('Occupation', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($occupation_message) . "</td></tr>\n"; $donor_country = get_post_meta($donation_id, '_dgx_donate_donor_country', true); if ('GB' == $donor_country) { $uk_gift_aid = get_post_meta($donation_id, '_dgx_donate_uk_gift_aid', true); if (empty($uk_gift_aid)) { $uk_gift_aid_message = __('No', 'seamless-donations'); } else { $uk_gift_aid_message = __('Yes', 'seamless-donations'); } echo "<tr><th>" . esc_html__('UK Gift Aid', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($uk_gift_aid_message) . "</td></tr>\n"; } $tribute_gift_message = __('No', 'seamless-donations'); $tribute_gift = get_post_meta($donation_id, '_dgx_donate_tribute_gift', true); if (!empty($tribute_gift)) { $tribute_gift_message = __('Yes', 'seamless-donations') . " - "; $honoree_name = get_post_meta($donation_id, '_dgx_donate_honoree_name', true); $honor_by_email = get_post_meta($donation_id, '_dgx_donate_honor_by_email', true); $honoree_email_name = get_post_meta($donation_id, '_dgx_donate_honoree_email_name', true); $honoree_post_name = get_post_meta($donation_id, '_dgx_donate_honoree_post_name', true); $honoree_email = get_post_meta($donation_id, '_dgx_donate_honoree_email', true); $honoree_address = get_post_meta($donation_id, '_dgx_donate_honoree_address', true); $honoree_city = get_post_meta($donation_id, '_dgx_donate_honoree_city', true); $honoree_state = get_post_meta($donation_id, '_dgx_donate_honoree_state', true); $honoree_province = get_post_meta($donation_id, '_dgx_donate_honoree_province', true); $honoree_zip = get_post_meta($donation_id, '_dgx_donate_honoree_zip', true); $honoree_country = get_post_meta($donation_id, '_dgx_donate_honoree_country', true); $memorial_gift = get_post_meta($donation_id, '_dgx_donate_memorial_gift', true); if (empty($memorial_gift)) { $tribute_gift_message .= __('in honor of', 'seamless-donations') . ' '; } else { $tribute_gift_message .= __('in memory of', 'seamless-donations') . ' '; } $tribute_gift_message .= $honoree_name . "<br/><br/>"; if ('TRUE' == $honor_by_email) { $tribute_gift_message .= __('Send acknowledgement via email to', 'seamless-donations') . '<br/>'; $tribute_gift_message .= esc_html($honoree_email_name) . "<br/>"; $tribute_gift_message .= esc_html($honoree_email) . "<br/>"; } else { $tribute_gift_message .= __('Send acknowledgement via postal mail to', 'seamless-donations') . '<br/>'; $tribute_gift_message .= esc_html($honoree_post_name) . "<br/>"; $tribute_gift_message .= esc_html($honoree_address) . "<br/>"; if (!empty($honoree_city)) { $tribute_gift_message .= esc_html($honoree_city . " "); } if ('US' == $honoree_country) { $tribute_gift_message .= esc_html($honoree_state . " "); } else { if ('CA' == $honoree_country) { $tribute_gift_message .= esc_html($honoree_province . " "); } } if (dgx_donate_country_requires_postal_code($honoree_country)) { $tribute_gift_message .= esc_html(" " . $honoree_zip); } $tribute_gift_message .= "<br/>"; $countries = dgx_donate_get_countries(); $honoree_country_name = $countries[$honoree_country]; $tribute_gift_message .= esc_html($honoree_country_name) . "<br/><br/>"; } } echo "<tr>"; echo "<th>" . esc_html__('Tribute Gift', 'seamless-donations') . "</th>"; echo "<td>" . $tribute_gift_message . "</td></tr>\n"; $payment_method = get_post_meta($donation_id, '_dgx_donate_payment_method', true); echo "<tr><th>" . esc_html__('Payment Method', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($payment_method) . "</td></tr>\n"; $repeating = get_post_meta($donation_id, '_dgx_donate_repeating', true); $is_repeating_donation = !empty($repeating); if ($is_repeating_donation) { $repeatingText = __('Yes', 'seamless-donations'); } else { $repeatingText = __('No', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Repeating', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($repeatingText) . "</td></tr>\n"; $session_id = get_post_meta($donation_id, '_dgx_donate_session_id', true); echo "<tr><th>" . esc_html__('Session ID', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($session_id) . "</td></tr>\n"; $transaction_id = get_post_meta($donation_id, '_dgx_donate_transaction_id', true); echo "<tr><th>" . esc_html__('Transaction ID', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($transaction_id) . "</td></tr>\n"; echo "</tbody></table>\n"; if ($is_repeating_donation) { // Display links to related (same session ID) donations $related_donation_ids = get_donations_by_meta('_dgx_donate_session_id', $session_id, -1); // Unset this donation if present (it probably will be) if (($index = array_search($donation_id, $related_donation_ids)) !== false) { unset($related_donation_ids[$index]); } echo "<h3>" . esc_html__('Related Donations', 'seamless-donations') . "</h3>\n"; echo "<p class='description'>"; echo esc_html__('For repeating donations, displays a list of other donations in the series (subscription)', 'seamless-donations'); echo "</p>\n"; // Show the array echo "<table class='widefat'><tbody>\n"; if (count($related_donation_ids)) { echo "<tr>"; echo "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; echo "<th>" . esc_html__('Transaction ID', 'seamless-donations') . "</th></tr>"; foreach ((array) $related_donation_ids as $related_donation_id) { $year = get_post_meta($related_donation_id, '_dgx_donate_year', true); $month = get_post_meta($related_donation_id, '_dgx_donate_month', true); $day = get_post_meta($related_donation_id, '_dgx_donate_day', true); $time = get_post_meta($related_donation_id, '_dgx_donate_time', true); $donation_date = $month . "/" . $day . "/" . $year; $transaction_id = get_post_meta($related_donation_id, '_dgx_donate_transaction_id', true); $donation_detail = dgx_donate_get_donation_detail_link($related_donation_id); echo "<tr>"; echo "<td><a href='" . esc_url($donation_detail) . "'>" . esc_html($donation_date . " " . $time) . "</a></td>"; echo "<td>" . esc_html($transaction_id) . "</td></tr>\n"; } } else { echo "<tr>"; echo "<th>" . esc_html__('No related donations found', 'seamless-donations') . "</th>"; echo "</tr>\n"; } echo "</tbody></table>\n"; } do_action('dgx_donate_donation_detail_right', $donation_id); do_action('dgx_donate_admin_footer'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-right -->\n"; echo "<div id=\"col-left\">\n"; echo "<div class=\"col-wrap\">\n"; Dgx_Donate_Admin_Donor_Detail_View::echo_donor_information($donation_id); echo "<h3>" . esc_html__('Delete this Donation', 'seamless-donations') . "</h3>"; echo "<p>" . esc_html__('Click the following button to delete this donation. This will also remove this donation from all reports. This operation cannot be undone.', 'seamless-donations') . "</p>"; if ($is_repeating_donation) { echo "<p><strong>" . esc_html__('This is a repeating donation (subscription). Deleting this donation does NOT end the subscription. The donor will need to log into PayPal to end the subscription.', 'seamless-donations') . "</strong></p>"; } echo "<form method='POST' action=''>\n"; $nonce = wp_create_nonce('dgx_donate_donation_detail_nonce'); echo "<input type='hidden' name='dgx_donate_donation_detail_nonce' value='" . esc_attr($nonce) . "' />\n"; echo "<input type='hidden' name='delete_donation' value='true' />"; echo "<p><input class='button' type='submit' value='" . esc_attr__('Delete Donation', 'seamless-donations') . "'"; echo " onclick=\"return confirm('" . esc_attr('Are you sure you want to delete this donation?', 'seamless-donations') . "');\"></p>\n"; echo "</form>"; do_action('dgx_donate_donation_detail_left', $donation_id); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-left -->\n"; echo "</div> <!-- col-container -->\n"; } echo "</div> <!-- wrap -->\n"; }
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; }
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; }
function seamless_donations_edd_deactivate_license($product, $license, $url) { dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('LICENSE DEACTIVATION STARTED'); // retrieve the license from the database $license = trim($license); dgx_donate_debug_log('Product: ' . $product); dgx_donate_debug_log('License key: ' . seamless_donations_obscurify_string($license)); // Call the custom API. $response = wp_remote_get(add_query_arg(array('edd_action' => 'deactivate_license', 'license' => $license, 'item_name' => urlencode($product)), $url), array('timeout' => 15, 'sslverify' => false)); // make sure the response came back okay if (is_wp_error($response)) { dgx_donate_debug_log('Response error detected: ' . $response->get_error_message()); return false; } // decode the license data $license_data = json_decode(wp_remote_retrieve_body($response)); // $license_data->license will be either "active" or "inactive" <-- "valid" if (isset($license_data->license) && $license_data->license == 'deactivated') { dgx_donate_debug_log('License check value: ' . $license_data->license); dgx_donate_debug_log('License check returning deactivated.'); return 'deactivated'; } dgx_donate_debug_log('License check returning invalid.'); return 'invalid'; }
function seamless_donations_process_payment() { // Log $paypal_server = get_option('dgx_donate_paypal_server'); dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('DONATION TRANSACTION STARTED'); dgx_donate_debug_log('Processing mode: ' . $paypal_server); $php_version = phpversion(); dgx_donate_debug_log("PHP Version: {$php_version}"); dgx_donate_debug_log("Seamless Donations Version: " . dgx_donate_get_version()); dgx_donate_debug_log("User browser: " . seamless_donations_get_browser_name()); $http_ipn_url = plugins_url('/dgx-donate-paypalstd-ipn.php', dirname(__FILE__)); $https_ipn_url = plugins_url('/pay/paypalstd/ipn.php', dirname(__FILE__)); $https_ipn_url = str_ireplace('http://', 'https://', $https_ipn_url); // force https check dgx_donate_debug_log('IPN (http): ' . $http_ipn_url); dgx_donate_debug_log('IPN (https): ' . $https_ipn_url); $nonce_bypass = get_option('dgx_donate_ignore_form_nonce'); if ($nonce_bypass != '1') { $nonce = $_POST['nonce']; if (!wp_verify_nonce($nonce, 'dgx-donate-nonce')) { $nonce_error = 'Payment process nonce validation failure. '; $nonce_error .= 'Consider turning on Ignore Form Nonce Value in the Seamless Donations '; $nonce_error .= 'Settings tab under Host Compatibility Options.'; dgx_donate_debug_log($nonce_error); die('Access Denied. See Seamless Donations log for details.'); } else { dgx_donate_debug_log("Payment process nonce {$nonce} validated."); } } // todo: not getting session ID *************************************************** // todo: reattach the javascript verification code $sd4_mode = get_option('dgx_donate_start_in_sd4_mode'); $session_id = $_POST['_dgx_donate_session_id']; dgx_donate_debug_log("Session ID retrieved from _POST: {$session_id}"); // now attempt to retrieve session data to see if it already exists (which would trigger an error) if ($sd4_mode == false) { // use the old transient system $session_data = get_transient($session_id); dgx_donate_debug_log('Looking for pre-existing session data (legacy transient mode): ' . $session_id); } else { // use the new guid/audit db system $session_data = seamless_donations_get_audit_option($session_id); dgx_donate_debug_log('Looking for pre-existing session data (guid/audit db mode): ' . $session_id); } if ($session_data !== false) { dgx_donate_debug_log('Session data already exists, returning false'); die; } else { dgx_donate_debug_log('Duplicate session data not found. Payment process data assembly can proceed.'); // Repack the POST $post_data = array(); if (isset($_POST['_dgx_donate_redirect_url'])) { $post_data['REFERRINGURL'] = $_POST['_dgx_donate_redirect_url']; } else { $post_data['REFERRINGURL'] = ''; } if (isset($_POST['_dgx_donate_success_url'])) { $post_data['SUCCESSURL'] = $_POST['_dgx_donate_success_url']; } else { $post_data['SUCCESSURL'] = ''; } if (isset($_POST['_dgx_donate_session_id'])) { $post_data['SESSIONID'] = $_POST['_dgx_donate_session_id']; } else { $post_data['SESSIONID'] = ''; } if (isset($_POST['_dgx_donate_repeating'])) { $post_data['REPEATING'] = $_POST['_dgx_donate_repeating']; } else { $post_data['REPEATING'] = ''; } if (isset($_POST['_dgx_donate_designated'])) { $post_data['DESIGNATED'] = $_POST['_dgx_donate_designated']; } else { $post_data['DESIGNATED'] = ''; } if (isset($_POST['_dgx_donate_designated_fund'])) { $post_data['DESIGNATEDFUND'] = $_POST['_dgx_donate_designated_fund']; } else { $post_data['DESIGNATEDFUND'] = ''; } if (isset($_POST['_dgx_donate_tribute_gift'])) { $post_data['TRIBUTEGIFT'] = $_POST['_dgx_donate_tribute_gift']; } else { $post_data['TRIBUTEGIFT'] = ''; } if (isset($_POST['_dgx_donate_memorial_gift'])) { $post_data['MEMORIALGIFT'] = $_POST['_dgx_donate_memorial_gift']; } else { $post_data['MEMORIALGIFT'] = ''; } if (isset($_POST['_dgx_donate_honoree_name'])) { $post_data['HONOREENAME'] = $_POST['_dgx_donate_honoree_name']; } else { $post_data['HONOREENAME'] = ''; } if (isset($_POST['_dgx_donate_honor_by_email'])) { $post_data['HONORBYEMAIL'] = $_POST['_dgx_donate_honor_by_email']; } else { $post_data['HONORBYEMAIL'] = ''; } if (isset($_POST['_dgx_donate_honoree_email'])) { $post_data['HONOREEEMAIL'] = $_POST['_dgx_donate_honoree_email']; } else { $post_data['HONOREEEMAIL'] = ''; } if (isset($_POST['_dgx_donate_honoree_address'])) { $post_data['HONOREEADDRESS'] = $_POST['_dgx_donate_honoree_address']; } else { $post_data['HONOREEADDRESS'] = ''; } if (isset($_POST['_dgx_donate_honoree_city'])) { $post_data['HONOREECITY'] = $_POST['_dgx_donate_honoree_city']; } else { $post_data['HONOREECITY'] = ''; } if (isset($_POST['_dgx_donate_honoree_state'])) { $post_data['HONOREESTATE'] = $_POST['_dgx_donate_honoree_state']; } else { $post_data['HONOREESTATE'] = ''; } if (isset($_POST['_dgx_donate_honoree_province'])) { $post_data['HONOREEPROVINCE'] = $_POST['_dgx_donate_honoree_province']; } else { $post_data['HONOREEPROVINCE'] = ''; } if (isset($_POST['_dgx_donate_honoree_country'])) { $post_data['HONOREECOUNTRY'] = $_POST['_dgx_donate_honoree_country']; } else { $post_data['HONOREECOUNTRY'] = ''; } if (isset($_POST['_dgx_donate_honoree_zip'])) { $post_data['HONOREEZIP'] = $_POST['_dgx_donate_honoree_zip']; } else { $post_data['HONOREEZIP'] = ''; } if (isset($_POST['_dgx_donate_honoree_email_name'])) { $post_data['HONOREEEMAILNAME'] = $_POST['_dgx_donate_honoree_email_name']; } else { $post_data['HONOREEEMAILNAME'] = ''; } if (isset($_POST['_dgx_donate_honoree_post_name'])) { $post_data['HONOREEPOSTNAME'] = $_POST['_dgx_donate_honoree_post_name']; } else { $post_data['HONOREEPOSTNAME'] = ''; } if (isset($_POST['_dgx_donate_donor_first_name'])) { $post_data['FIRSTNAME'] = $_POST['_dgx_donate_donor_first_name']; } else { $post_data['FIRSTNAME'] = ''; } if (isset($_POST['_dgx_donate_donor_last_name'])) { $post_data['LASTNAME'] = $_POST['_dgx_donate_donor_last_name']; } else { $post_data['LASTNAME'] = ''; } if (isset($_POST['_dgx_donate_donor_phone'])) { $post_data['PHONE'] = $_POST['_dgx_donate_donor_phone']; } else { $post_data['PHONE'] = ''; } if (isset($_POST['_dgx_donate_donor_email'])) { $post_data['EMAIL'] = $_POST['_dgx_donate_donor_email']; } else { $post_data['EMAIL'] = ''; } if (isset($_POST['_dgx_donate_add_to_mailing_list'])) { $post_data['ADDTOMAILINGLIST'] = $_POST['_dgx_donate_add_to_mailing_list']; } else { $post_data['ADDTOMAILINGLIST'] = ''; } if (isset($_POST['_dgx_donate_donor_address'])) { $post_data['ADDRESS'] = $_POST['_dgx_donate_donor_address']; } else { $post_data['ADDRESS'] = ''; } if (isset($_POST['_dgx_donate_donor_address2'])) { $post_data['ADDRESS2'] = $_POST['_dgx_donate_donor_address2']; } else { $post_data['ADDRESS2'] = ''; } if (isset($_POST['_dgx_donate_donor_city'])) { $post_data['CITY'] = $_POST['_dgx_donate_donor_city']; } else { $post_data['CITY'] = ''; } if (isset($_POST['_dgx_donate_donor_state'])) { $post_data['STATE'] = $_POST['_dgx_donate_donor_state']; } else { $post_data['STATE'] = ''; } if (isset($_POST['_dgx_donate_donor_province'])) { $post_data['PROVINCE'] = $_POST['_dgx_donate_donor_province']; } else { $post_data['PROVINCE'] = ''; } if (isset($_POST['_dgx_donate_donor_country'])) { $post_data['COUNTRY'] = $_POST['_dgx_donate_donor_country']; } else { $post_data['COUNTRY'] = ''; } if (isset($_POST['_dgx_donate_donor_zip'])) { $post_data['ZIP'] = $_POST['_dgx_donate_donor_zip']; } else { $post_data['ZIP'] = ''; } if (isset($_POST['_dgx_donate_increase_to_cover'])) { $post_data['INCREASETOCOVER'] = $_POST['_dgx_donate_increase_to_cover']; } else { $post_data['INCREASETOCOVER'] = ''; } if (isset($_POST['_dgx_donate_anonymous'])) { $post_data['ANONYMOUS'] = $_POST['_dgx_donate_anonymous']; } else { $post_data['ANONYMOUS'] = ''; } if (isset($_POST['_dgx_donate_employer_match'])) { $post_data['EMPLOYERMATCH'] = $_POST['_dgx_donate_employer_match']; } else { $post_data['EMPLOYERMATCH'] = ''; } if (isset($_POST['_dgx_donate_employer_name'])) { $post_data['EMPLOYERNAME'] = $_POST['_dgx_donate_employer_name']; } else { $post_data['EMPLOYERNAME'] = ''; } if (isset($_POST['_dgx_donate_occupation'])) { $post_data['OCCUPATION'] = $_POST['_dgx_donate_occupation']; } else { $post_data['OCCUPATION'] = ''; } if (isset($_POST['_dgx_donate_uk_gift_aid'])) { $post_data['UKGIFTAID'] = $_POST['_dgx_donate_uk_gift_aid']; } else { $post_data['UKGIFTAID'] = ''; } if (isset($_POST['nonce'])) { $post_data['NONCE'] = $_POST['nonce']; } else { $post_data['NONCE'] = ''; } // pull override data from hidden form (might be modified by users with callbacks) if (isset($_POST['business'])) { $post_data['BUSINESS'] = $_POST['business']; } else { $post_data['BUSINESS'] = ''; } if (isset($_POST['return'])) { $post_data['RETURN'] = $_POST['return']; } else { $post_data['RETURN'] = ''; } if (isset($_POST['notify_url'])) { $post_data['NOTIFY_URL'] = $_POST['notify_url']; } else { $post_data['NOTIFY_URL'] = ''; } if (isset($_POST['item_name'])) { $post_data['ITEM_NAME'] = $_POST['item_name']; } else { $post_data['ITEM_NAME'] = ''; } if (isset($_POST['cmd'])) { $post_data['CMD'] = $_POST['cmd']; } else { $post_data['CMD'] = ''; } if (isset($_POST['p3'])) { $post_data['P3'] = $_POST['p3']; } else { $post_data['P3'] = ''; } if (isset($_POST['t3'])) { $post_data['T3'] = $_POST['t3']; } else { $post_data['T3'] = ''; } if (isset($_POST['a3'])) { $post_data['A3'] = $_POST['a3']; } else { $post_data['A3'] = ''; } // Resolve the donation amount if (strcasecmp($_POST['_dgx_donate_amount'], "OTHER") == 0) { $post_data['AMOUNT'] = floatval($_POST['_dgx_donate_user_amount']); } else { $post_data['AMOUNT'] = floatval($_POST['_dgx_donate_amount']); } if ($post_data['AMOUNT'] < 1.0) { $post_data['AMOUNT'] = 1.0; } if ('US' == $post_data['HONOREECOUNTRY']) { $post_data['PROVINCE'] = ''; } else { if ('CA' == $post_data['HONOREECOUNTRY']) { $post_data['HONOREESTATE'] = ''; } else { $post_data['HONOREESTATE'] = ''; $post_data['HONOREEPROVINCE'] = ''; } } // If no country entered, pull in the default if ($post_data['COUNTRY'] == '') { $post_data['COUNTRY'] = get_option('dgx_donate_default_country'); } if ('US' == $post_data['COUNTRY']) { $post_data['PROVINCE'] = ''; } else { if ('CA' == $post_data['COUNTRY']) { $post_data['STATE'] = ''; } else { $post_data['STATE'] = ''; $post_data['PROVINCE'] = ''; } } $post_data['PAYMENTMETHOD'] = "PayPal"; // $_POST['dgx_donate_payment_method'] $post_data['SDVERSION'] = dgx_donate_get_version(); // Sanitize the data (remove leading, trailing spaces quotes, brackets) foreach ($post_data as $key => $value) { $temp = trim($value); $temp = str_replace("\"", "", $temp); $temp = strip_tags($temp); $post_data[$key] = $temp; } // account for different permalink styles $success_url = $post_data['SUCCESSURL']; $qmark = strpos($success_url, '?'); if ($qmark === false) { $success_url .= "?thanks=true"; } else { $success_url .= "&thanks=true"; } $post_data['RETURN'] = $success_url; dgx_donate_debug_log("Success URL: {$success_url}"); $post_data = apply_filters('seamless_donations_payment_post_data', $post_data); // insert extra validation for GoodByeCaptcha and any other validation $challenge_response_passed = apply_filters('seamless_donations_challenge_response_request', true, $post_data); if (true !== $challenge_response_passed) { if (is_wp_error($challenge_response_passed)) { $error_message = $challenge_response_passed->get_error_message(); } else { $error_message = (string) $challenge_response_passed; } dgx_donate_debug_log('Form challenge-response failed:' . $error_message); die(esc_html__('Invalid response to challenge. Are you human?')); } if ($sd4_mode == false) { // Save it all in a transient $transient_token = $post_data['SESSIONID']; set_transient($transient_token, $post_data, 7 * 24 * 60 * 60); // 7 days dgx_donate_debug_log('Saving transaction data using legacy mode'); } else { seamless_donations_update_audit_option($session_id, $post_data); dgx_donate_debug_log('Saving transaction data using guid/audit db mode'); } // more log data $obscurify = get_option('dgx_donate_log_obscure_name'); // false if not set if ($obscurify == '1') { // obscurify for privacy $donor_name = strtolower($post_data['FIRSTNAME'] . $post_data['LASTNAME']); $donor_name = seamless_donations_obscurify_string($donor_name, '*', false); } else { $donor_name = $post_data['FIRSTNAME'] . ' ' . $post_data['LASTNAME']; } dgx_donate_debug_log('Name: ' . $donor_name); dgx_donate_debug_log('Amount: ' . $post_data['AMOUNT']); dgx_donate_debug_log("Preparation complete. Entering PHP post code."); // new posting code // Build the PayPal query string $post_args = "?"; $post_args .= "first_name=" . urlencode($post_data['FIRSTNAME']) . "&"; $post_args .= "last_name=" . urlencode($post_data['LASTNAME']) . "&"; $post_args .= "address1=" . urlencode($post_data['ADDRESS']) . "&"; $post_args .= "address2=" . urlencode($post_data['ADDRESS2']) . "&"; $post_args .= "city=" . urlencode($post_data['CITY']) . "&"; $post_args .= "zip=" . urlencode($post_data['ZIP']) . "&"; if ('US' == $post_data['COUNTRY']) { $post_args .= "state=" . urlencode($post_data['STATE']) . "&"; } else { if ('CA' == $post_data['COUNTRY']) { $post_args .= "state=" . urlencode($post_data['PROVINCE']) . "&"; } } $post_args .= "country=" . urlencode($post_data['COUNTRY']) . "&"; $post_args .= "email=" . urlencode($post_data['EMAIL']) . "&"; $post_args .= "custom=" . urlencode($post_data['SESSIONID']) . "&"; // fill in repeating data, overriding if necessary dgx_donate_debug_log("Checking for repeat. REPEAT value is [" . $post_data['REPEATING'] . "]."); if ($post_data['REPEATING'] == '') { if ($post_data['CMD'] == '') { $post_data['CMD'] = '_donations'; } $post_args .= "amount=" . urlencode($post_data['AMOUNT']) . "&"; $post_args .= "cmd=" . urlencode($post_data['CMD']) . "&"; } else { if ($post_data['CMD'] == '') { $post_data['CMD'] = '_xclick-subscriptions'; } if ($post_data['P3'] == '') { $post_data['P3'] = '1'; } if ($post_data['T3'] == '') { $post_data['T3'] = 'M'; } $post_args .= "cmd=" . urlencode($post_data['CMD']) . "&"; $post_args .= "p3=" . urlencode($post_data['P3']) . "&"; // 1, M = monthly $post_args .= "t3=" . urlencode($post_data['T3']) . "&"; $post_args .= "src=1&sra=1&"; // repeat until cancelled, retry on failure $post_args .= "a3=" . urlencode($post_data['AMOUNT']) . "&"; $log_msg = "Enabling repeating donation, cmd=" . $post_data['CMD']; $log_msg .= ", p3=" . $post_data['P3'] . ", t3=" . $post_data['T3']; $log_msg .= ", a3=" . $post_data['AMOUNT']; dgx_donate_debug_log($log_msg); } $notify_url = plugins_url('/dgx-donate-paypalstd-ipn.php', __FILE__); $paypal_email = get_option('dgx_donate_paypal_email'); $currency_code = get_option('dgx_donate_currency'); // fill in the rest of the form data, overriding if necessary if ($post_data['BUSINESS'] == '') { $post_data['BUSINESS'] = $paypal_email; } if ($post_data['NOTIFY_URL'] == '') { $post_data['NOTIFY_URL'] = $notify_url; } dgx_donate_debug_log("Computed RETURN value: '" . $post_data['RETURN'] . "'"); $post_args .= "business=" . urlencode($post_data['BUSINESS']) . "&"; $post_args .= "return=" . urlencode($post_data['RETURN']) . "&"; $post_args .= "notify_url=" . urlencode($post_data['NOTIFY_URL']) . "&"; $post_args .= "item_name=" . urlencode($post_data['ITEM_NAME']) . "&"; $post_args .= "quantity=" . urlencode('1') . "&"; $post_args .= "currency_code=" . urlencode($currency_code) . "&"; $post_args .= "no_note=" . urlencode('1') . "&"; if ($paypal_server == "SANDBOX") { $form_action = "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $form_action = "https://www.paypal.com/cgi-bin/webscr"; } // var_dump ( $post_args ); // // die(); // dgx_donate_debug_log ( "Post args: " . $post_args ); dgx_donate_debug_log("Redirecting to PayPal... now!"); wp_redirect($form_action . $post_args); exit; } }
function dgx_donate_paypalstd_ajax_checkout() { $nonce = $_POST['nonce']; if (!wp_verify_nonce($nonce, 'dgx-donate-nonce')) { die('Busted!'); } $referringUrl = $_POST['referringUrl']; $sessionID = $_POST['sessionID']; $donationAmount = $_POST['donationAmount']; $userAmount = $_POST['userAmount']; $repeating = $_POST['repeating']; $designated = $_POST['designated']; $designatedFund = $_POST['designatedFund']; $tributeGift = $_POST['tributeGift']; $memorialGift = $_POST['memorialGift']; $honoreeName = $_POST['honoreeName']; $honorByEmail = $_POST['honorByEmail']; $honoreeEmail = $_POST['honoreeEmail']; $honoreeAddress = $_POST['honoreeAddress']; $honoreeCity = $_POST['honoreeCity']; $honoreeState = $_POST['honoreeState']; $honoreeProvince = $_POST['honoreeProvince']; $honoreeCountry = $_POST['honoreeCountry']; if ('US' == $honoreeCountry) { $honoreeProvince = ''; } else { if ('CA' == $honoreeCountry) { $honoreeState = ''; } else { $honoreeState = ''; $honoreeProvince = ''; } } $honoreeZip = $_POST['honoreeZip']; $honoreeEmailName = $_POST['honoreeEmailName']; $honoreePostName = $_POST['honoreePostName']; $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $phone = $_POST['phone']; $email = $_POST['email']; $addToMailingList = $_POST['addToMailingList']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $province = $_POST['province']; $country = $_POST['country']; if ('US' == $country) { $province = ''; } else { if ('CA' == $country) { $state = ''; } else { $state = ''; $province = ''; } } $zip = $_POST['zip']; $increaseToCover = $_POST['increaseToCover']; $anonymous = $_POST['anonymous']; $employerMatch = $_POST['employerMatch']; $employerName = $_POST['employerName']; $occupation = $_POST['occupation']; $ukGiftAid = $_POST['ukGiftAid']; // Resolve the donation amount if (strcasecmp($donationAmount, "OTHER") == 0) { $amount = floatval($userAmount); } else { $amount = floatval($donationAmount); } if ($amount < 1.0) { $amount = 1.0; } // Repack the POST $postData = array(); $postData['REFERRINGURL'] = $referringUrl; $postData['SESSIONID'] = $sessionID; $postData['AMOUNT'] = $amount; $postData['REPEATING'] = $repeating; $postData['DESIGNATED'] = $designated; $postData['DESIGNATEDFUND'] = $designatedFund; $postData['TRIBUTEGIFT'] = $tributeGift; $postData['MEMORIALGIFT'] = $memorialGift; $postData['HONOREENAME'] = $honoreeName; $postData['HONORBYEMAIL'] = $honorByEmail; $postData['HONOREEEMAIL'] = $honoreeEmail; $postData['HONOREEADDRESS'] = $honoreeAddress; $postData['HONOREECITY'] = $honoreeCity; $postData['HONOREESTATE'] = $honoreeState; $postData['HONOREEPROVINCE'] = $honoreeProvince; $postData['HONOREECOUNTRY'] = $honoreeCountry; $postData['HONOREEZIP'] = $honoreeZip; $postData['HONOREEEMAILNAME'] = $honoreeEmailName; $postData['HONOREEPOSTNAME'] = $honoreePostName; $postData['FIRSTNAME'] = $firstName; $postData['LASTNAME'] = $lastName; $postData['PHONE'] = $phone; $postData['EMAIL'] = $email; $postData['ADDTOMAILINGLIST'] = $addToMailingList; $postData['ADDRESS'] = $address; $postData['ADDRESS2'] = $address2; $postData['CITY'] = $city; $postData['STATE'] = $state; $postData['PROVINCE'] = $province; $postData['COUNTRY'] = $country; $postData['ZIP'] = $zip; $postData['INCREASETOCOVER'] = $increaseToCover; $postData['ANONYMOUS'] = $anonymous; $postData['PAYMENTMETHOD'] = "PayPal"; $postData['EMPLOYERMATCH'] = $employerMatch; $postData['EMPLOYERNAME'] = $employerName; $postData['OCCUPATION'] = $occupation; $postData['UKGIFTAID'] = $ukGiftAid; // Sanitize the data (remove leading, trailing spaces quotes, brackets) foreach ($postData as $key => $value) { $temp = trim($value); $temp = str_replace("\"", "", $temp); $temp = strip_tags($temp); $postData[$key] = $temp; } // Save it all in a transient $transientToken = $postData['SESSIONID']; set_transient($transientToken, $postData, 7 * 24 * 60 * 60); // 7 days // Log dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('Donation transaction started'); $php_version = phpversion(); dgx_donate_debug_log("PHP Version: {$php_version}"); dgx_donate_debug_log('Name: ' . $postData['FIRSTNAME'] . ' ' . $postData['LASTNAME']); dgx_donate_debug_log('Amount: ' . $postData['AMOUNT']); dgx_donate_debug_log('IPN: ' . plugins_url('/dgx-donate-paypalstd-ipn.php', __FILE__)); // Return success to AJAX caller as " code | message " // A return code of 0 indicates success, and the returnMessage is ignored // A return code of 1 indicates failure, and the returnMessage contains the error message $returnMessage = "0|SUCCESS"; echo $returnMessage; die; // this is required to return a proper result }
function dgx_donate_paypalstd_ajax_checkout() { // Log dgx_donate_debug_log('----------------------------------------'); dgx_donate_debug_log('DONATION TRANSACTION STARTED'); dgx_donate_debug_log('Test mode: B'); $php_version = phpversion(); dgx_donate_debug_log("PHP Version: {$php_version}"); dgx_donate_debug_log("Seamless Donations Version: " . dgx_donate_get_version()); dgx_donate_debug_log("User browser: " . seamless_donations_get_browser_name()); dgx_donate_debug_log('IPN: ' . plugins_url('/dgx-donate-paypalstd-ipn.php', __FILE__)); $nonce = $_POST['nonce']; if (!wp_verify_nonce($nonce, 'dgx-donate-nonce')) { dgx_donate_debug_log('Payment process nonce validation failure.'); die('Access Denied.'); } else { dgx_donate_debug_log("Payment process nonce {$nonce} validated."); } $sd4_mode = get_option('dgx_donate_start_in_sd4_mode'); $session_id = $_POST['sessionID']; dgx_donate_debug_log("Session ID retrieved from _POST: {$session_id}"); // now attempt to retrieve session data to see if it already exists (which would trigger an error) if ($sd4_mode == false) { // use the old transient system $session_data = get_transient($session_id); dgx_donate_debug_log('Looking for pre-existing session data (legacy transient mode): ' . $session_id); } else { // use the new guid/audit db system $session_data = seamless_donations_get_audit_option($session_id); dgx_donate_debug_log('Looking for pre-existing session data (guid/audit db mode): ' . $session_id); } if ($session_data !== false) { dgx_donate_debug_log('Session data already exists, returning false'); die; } else { dgx_donate_debug_log('Duplicate session data not found. Payment process data assembly can proceed.'); // all of this no longer necessary for transfer to PayPal, just for storage in local audit table $referringUrl = $_POST['referringUrl']; $donationAmount = $_POST['donationAmount']; $userAmount = $_POST['userAmount']; $repeating = $_POST['repeating']; $designated = $_POST['designated']; $designatedFund = $_POST['designatedFund']; $tributeGift = $_POST['tributeGift']; $memorialGift = $_POST['memorialGift']; $honoreeName = $_POST['honoreeName']; $honorByEmail = $_POST['honorByEmail']; $honoreeEmail = $_POST['honoreeEmail']; $honoreeAddress = $_POST['honoreeAddress']; $honoreeCity = $_POST['honoreeCity']; $honoreeState = $_POST['honoreeState']; $honoreeProvince = $_POST['honoreeProvince']; $honoreeCountry = $_POST['honoreeCountry']; if ('US' == $honoreeCountry) { $honoreeProvince = ''; } else { if ('CA' == $honoreeCountry) { $honoreeState = ''; } else { $honoreeState = ''; $honoreeProvince = ''; } } $honoreeZip = $_POST['honoreeZip']; $honoreeEmailName = $_POST['honoreeEmailName']; $honoreePostName = $_POST['honoreePostName']; $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $phone = $_POST['phone']; $email = $_POST['email']; $addToMailingList = $_POST['addToMailingList']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $province = $_POST['province']; $country = $_POST['country']; if ('US' == $country) { $province = ''; } else { if ('CA' == $country) { $state = ''; } else { $state = ''; $province = ''; } } $zip = $_POST['zip']; $increaseToCover = $_POST['increaseToCover']; $anonymous = $_POST['anonymous']; $employerMatch = $_POST['employerMatch']; $employerName = $_POST['employerName']; $occupation = $_POST['occupation']; $ukGiftAid = $_POST['ukGiftAid']; // Resolve the donation amount if (strcasecmp($donationAmount, "OTHER") == 0) { $amount = floatval($userAmount); } else { $amount = floatval($donationAmount); } if ($amount < 1.0) { $amount = 1.0; } // Repack the POST $post_data = array(); $post_data['REFERRINGURL'] = $referringUrl; $post_data['SESSIONID'] = $session_id; $post_data['AMOUNT'] = $amount; $post_data['REPEATING'] = $repeating; $post_data['DESIGNATED'] = $designated; $post_data['DESIGNATEDFUND'] = $designatedFund; $post_data['TRIBUTEGIFT'] = $tributeGift; $post_data['MEMORIALGIFT'] = $memorialGift; $post_data['HONOREENAME'] = $honoreeName; $post_data['HONORBYEMAIL'] = $honorByEmail; $post_data['HONOREEEMAIL'] = $honoreeEmail; $post_data['HONOREEADDRESS'] = $honoreeAddress; $post_data['HONOREECITY'] = $honoreeCity; $post_data['HONOREESTATE'] = $honoreeState; $post_data['HONOREEPROVINCE'] = $honoreeProvince; $post_data['HONOREECOUNTRY'] = $honoreeCountry; $post_data['HONOREEZIP'] = $honoreeZip; $post_data['HONOREEEMAILNAME'] = $honoreeEmailName; $post_data['HONOREEPOSTNAME'] = $honoreePostName; $post_data['FIRSTNAME'] = $firstName; $post_data['LASTNAME'] = $lastName; $post_data['PHONE'] = $phone; $post_data['EMAIL'] = $email; $post_data['ADDTOMAILINGLIST'] = $addToMailingList; $post_data['ADDRESS'] = $address; $post_data['ADDRESS2'] = $address2; $post_data['CITY'] = $city; $post_data['STATE'] = $state; $post_data['PROVINCE'] = $province; $post_data['COUNTRY'] = $country; $post_data['ZIP'] = $zip; $post_data['INCREASETOCOVER'] = $increaseToCover; $post_data['ANONYMOUS'] = $anonymous; $post_data['PAYMENTMETHOD'] = "PayPal"; $post_data['EMPLOYERMATCH'] = $employerMatch; $post_data['EMPLOYERNAME'] = $employerName; $post_data['OCCUPATION'] = $occupation; $post_data['UKGIFTAID'] = $ukGiftAid; $post_data['SDVERSION'] = dgx_donate_get_version(); // Sanitize the data (remove leading, trailing spaces quotes, brackets) foreach ($post_data as $key => $value) { $temp = trim($value); $temp = str_replace("\"", "", $temp); $temp = strip_tags($temp); $post_data[$key] = $temp; } if ($sd4_mode == false) { // Save it all in a transient $transient_token = $post_data['SESSIONID']; set_transient($transient_token, $post_data, 7 * 24 * 60 * 60); // 7 days dgx_donate_debug_log('Saving transaction data using legacy mode'); } else { seamless_donations_update_audit_option($session_id, $post_data); dgx_donate_debug_log('Saving transaction data using guid/audit db mode'); } // more log data dgx_donate_debug_log('Name: ' . $post_data['FIRSTNAME'] . ' ' . $post_data['LASTNAME']); dgx_donate_debug_log('Amount: ' . $post_data['AMOUNT']); dgx_donate_debug_log("Preparation complete. It is now up to PayPal to return data via IPN."); // Return success to AJAX caller as " code | message " // A return code of 0 indicates success, and the returnMessage is ignored // A return code of 1 indicates failure, and the returnMessage contains the error message $returnMessage = "0|SUCCESS"; echo $returnMessage; die; // this is required to return a proper result } }