コード例 #1
0
 public static function handling_request_with_confirmation($email, $profile, $type = NULL)
 {
     $merge_vars = self::parse_profile($profile, $type);
     try {
         Model_MailChimp::subscribe_with_confirmation($email, $merge_vars);
         $json['success'] = __('A notification has been sent to your email. Please confirm your subscription from there.', STM_DOMAIN);
         echo json_encode($json);
         exit;
     } catch (Mailchimp_List_AlreadySubscribed $e) {
         $json['error'] = __('User with this email is already subscribed', STM_DOMAIN);
         echo json_encode($json);
         exit;
     } catch (Mailchimp_List_MergeFieldRequired $e) {
         $json['error'] = __('Please go to http://mailchimp.com/, login, go to your list, then Settings, and put \\"First Name\\" and \\"Last Name\\" not required.', STM_DOMAIN);
         echo json_encode($json);
         exit;
     } catch (Mailchimp_Invalid_ApiKey $e) {
         $json['error'] = __('Your API Key is Invalid!', STM_DOMAIN);
         echo json_encode($json);
         exit;
     } catch (Mailchimp_List_DoesNotExist $e) {
         $json['error'] = __('The list that you provided does not exists!', STM_DOMAIN);
         echo json_encode($json);
         exit;
     } catch (Exception $e) {
         #Send error back to developer
         Handling::sendError(print_r($e, true), "Handling.class.php", "42");
         return self::handling_this("ERRO");
     }
     self::handling_this();
 }
コード例 #2
0
ファイル: mailchimp.php プロジェクト: baochung26/happy-c
function function_stm_subscribe()
{
    $json = array();
    $email = urldecode(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL));
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $json['error'] = __('Enter a valid email', STM_DOMAIN);
        echo json_encode($json);
        exit;
    } else {
        require_once "lib/mailchimp/Handling.class.php";
        Handling::handling_request_with_confirmation($email, NULL);
    }
}
コード例 #3
0
ファイル: donation.php プロジェクト: bogdandobritoiu/aripi
function checkPayment($data)
{
    $donationOptions = get_theme_mod('donation_options');
    $item_name = $data['item_name'];
    $item_number = $data['item_number'];
    $payment_status = $data['payment_status'];
    $payment_amount = $data['mc_gross'];
    $payment_currency = $data['mc_currency'];
    $txn_id = $data['txn_id'];
    $receiver_email = $data['receiver_email'];
    $payer_email = $data['payer_email'];
    $invoice = $data['invoice'];
    $req = 'cmd=_notify-validate';
    foreach ($data as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req .= "&{$key}={$value}";
    }
    $ch = curl_init('https://' . paypal_url() . '/cgi-bin/webscr');
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
    if (!($res = curl_exec($ch))) {
        echo "Got " . curl_error($ch) . " when processing IPN data";
        curl_close($ch);
        return false;
    }
    curl_close($ch);
    if (strcmp($res, "VERIFIED") == 0) {
        $mail_To = get_option('admin_email');
        $mail_Subject = "VERIFIED IPN";
        $mail_Body = $req;
        //wp_mail($mail_To, $mail_Subject, $mail_Body);
        wp_update_post(array('ID' => $invoice, 'post_status' => 'publish'));
        $donors = get_post_meta($item_number, 'donation_donors', true);
        $donors = intval($donors);
        if (!$donors) {
            $donors = 0;
        }
        $donors = $donors + 1;
        update_post_meta($item_number, 'donation_donors', $donors);
        $raised = get_post_meta($item_number, 'donation_raised', true);
        $donor_amount = get_post_meta($invoice, 'donor_amount', true);
        $donor_amount = intval($donor_amount);
        $raised = intval($raised);
        if (!$raised) {
            $raised = 0;
        }
        $raised = $raised + $donor_amount;
        update_post_meta($item_number, 'donation_raised', $raised);
        $donation_options = get_theme_mod('donation_options');
        $email_message_search = array('[name]', '[amount]', '[cause]');
        $email_message_replace = array(get_the_title($invoice), $donor_amount, '<a href="' . get_permalink($item_number) . '">' . get_the_title($item_number) . '</a>');
        $admin_email_subject = $donation_options['admin_email_subject'];
        $admin_email_message = str_replace($email_message_search, $email_message_replace, $donation_options['admin_email_message']);
        $donor_email_subject = $donation_options['donor_email_subject'];
        $donor_email_message = str_replace($email_message_search, $email_message_replace, $donation_options['donor_email_message']);
        add_filter('wp_mail_content_type', 'set_html_content_type');
        $headers[] = 'From: ' . get_bloginfo('blogname') . ' <' . get_bloginfo('admin_email') . '>';
        wp_mail(get_bloginfo('admin_email'), $admin_email_subject, nl2br($admin_email_message), $headers);
        wp_mail(get_post_meta($invoice, 'donor_email', true), $donor_email_subject, nl2br($donor_email_message), $headers);
        remove_filter('wp_mail_content_type', 'set_html_content_type');
        if (get_post_meta($invoice, 'donor_subscribe', true) && get_post_meta($invoice, 'donor_email', true)) {
            require_once "lib/mailchimp/Handling.class.php";
            Handling::handling_request_with_confirmation(get_post_meta($invoice, 'donor_email', true), NULL);
        }
    } else {
        if (strcmp($res, "INVALID") == 0) {
            $mail_To = get_option('admin_email');
            $mail_Subject = "INVALID IPN";
            $mail_Body = $req;
            //wp_mail($mail_To, $mail_Subject, $mail_Body);
        }
    }
}