Example #1
0
 function do_checkout(ET_Order $order)
 {
     global $ae_post_factory, $user_ID;
     /**
      * check session
      */
     $session = et_read_session();
     $ad_id = isset($session['ad_id']) ? $session['ad_id'] : '';
     $post = get_post($ad_id);
     if ($ad_id && !is_wp_error($post)) {
         /**
          * get object by post type and convert
          */
         $post_obj = $ae_post_factory->get($post->post_type);
         $ad = $post_obj->convert($post);
         $ad_package = $ad->et_payment_package;
         // get package info
         $package_obj = $ae_post_factory->get('pack');
         $package = $package_obj->get($ad_package);
         if (is_wp_error($package) || $package->et_price > 0) {
             // check the price is 0?
             return array('ACK' => false, 'payment_type' => 'free', 'msg' => __("Invalid Payment package", ET_DOMAIN));
         }
         if ($user_ID == $ad->post_author || current_user_can('manage_options')) {
             // check permission
             $payment_return = array('ACK' => true, 'payment_type' => 'free');
             return $payment_return;
         }
     }
     return array('ACK' => false, 'payment_type' => 'free', 'msg' => __("Invalid Post ID", ET_DOMAIN));
 }
Example #2
0
 /**
  * send a cash notify to user after purchase by cash
  * @param String $cash_message
  * @return null
  *
  * @package AE Mail
  * @category mail
  *
  * @since 1.0
  * @author Dakachi
  */
 function ae_cash_message($cash_message, $order)
 {
     $products = $order['products'];
     $package = array_pop($products);
     $session = et_read_session();
     $ad_id = $session['ad_id'];
     $mail = AE_Mailing::get_instance();
     $mail->send_cash_message($cash_message, $order['payer'], $package, $ad_id);
 }
<?php

/**
 *	Template Name: Process Accept Bid
 */
$payment_type = get_query_var('paymentType');
$session = et_read_session();
//processs payment
$payment_return = fre_process_escrow($payment_type, $session);
$ad_id = $session['ad_id'];
get_header();
global $ad, $payment_return;
$payment_return = wp_parse_args($payment_return, array('ACK' => false, 'payment_status' => ''));
extract($payment_return);
if ($session['ad_id']) {
    $ad = get_post($session['ad_id']);
} else {
    $ad = false;
}
?>

<section class="blog-header-container">
	<div class="container">
		<!-- blog header -->
		<div class="row">
		    <div class="col-md-12 blog-classic-top">
		        <h2><?php 
the_title();
?>
</h2>
		    </div>
 function do_checkout(ET_Order $order)
 {
     global $ae_post_factory, $user_ID;
     /**
      * check session
      */
     $session = et_read_session();
     $ad_id = isset($session['ad_id']) ? $session['ad_id'] : '';
     if ($ad_id) {
         $post = get_post($ad_id);
         // ad id existed
         /**
          * get object by post type and convert
          */
         $post_obj = $ae_post_factory->get($post->post_type);
         $ad = $post_obj->convert($post);
         if (!is_wp_error($ad)) {
             /**
              * check user is available to use selected package
              */
             $available = AE_Package::check_use_package($ad->et_payment_package, $ad->post_author);
             if ($available) {
                 // process order data
                 $payment_return = array('ACK' => true, 'payment_type' => 'usePackage');
                 /**
                  * get user current order for package
                  */
                 $current_order = AE_Payment::get_current_order($ad->post_author, $ad->et_payment_package);
                 $order = get_post($current_order);
                 if (!$order || is_wp_error($order)) {
                     return array('ACK' => false, 'payment_type' => 'usePackage', 'msg' => __("Invalid Order or Package", ET_DOMAIN));
                 }
                 $ad_data = array();
                 $ad_data['ID'] = $ad->ID;
                 /**
                  * update ad order
                  */
                 $ad_data['et_ad_order'] = $current_order;
                 $ad_data['post_status'] = 'pending';
                 if ($order->post_status == 'publish') {
                     $options = AE_Options::get_instance();
                     $ad_data['et_paid'] = 1;
                     if (!$options->use_pending) {
                         $ad_data['post_status'] = 'publish';
                     }
                 } else {
                     $ad_data['et_paid'] = 0;
                 }
                 $ad_data['change_status'] = 'change_status';
                 $ad_data['method'] = 'update';
                 /**
                  * sync Ad data
                  */
                 $return = wp_update_post($ad_data);
                 // update post paid status
                 update_post_meta($ad->ID, 'et_paid', $ad_data['et_paid']);
                 // update post package order id
                 update_post_meta($ad->ID, 'et_ad_order', $ad_data['et_ad_order']);
                 /**
                  * update seller package quantity
                  */
                 AE_Package::update_package_data($ad->et_payment_package, $ad->post_author);
                 return $payment_return;
             }
         }
     }
     return array('ACK' => false, 'payment_type' => 'usePackage', 'msg' => __("Invalid Ad ID", ET_DOMAIN));
 }
function ae_ppdigital_process_payment($payment_return, $data)
{
    $payment_type = $data['payment_type'];
    $order = $data['order'];
    if ($payment_type == 'ppdigital') {
        $ack = false;
        if (isset($_REQUEST['token']) && isset($_REQUEST['PayerID'])) {
            $token = $_REQUEST['token'];
            $payerID = $_REQUEST['PayerID'];
            $checkout = new AE_PPExpressVisitor();
            // generate order data
            $order_pay = $order->generate_data_to_pay();
            // confirm payment
            $response = $checkout->ConfirmPayment($token, $payerID, $order_pay);
            $ack = strtoupper($response['ACK']);
            if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
                $payment_return = array('ACK' => true, 'payment' => 'ppdigital', 'payment_status' => 'Completed');
                // update order
                $order->set_payment_code($token);
                $order->set_payer_id($payerID);
                $order->set_status('publish');
                $order->update_order();
                $session = et_read_session();
                $link = get_permalink($session['ad_id']);
                echo '
                    <script type="text/javascript">
                        setTimeout (function () {
                            if (window.opener) {
                                window.opener.location.href = "' . $link . '";
                                window.close();
                            } }, 3000 );
                    </script>';
                $ack = true;
            }
        }
        if (!$ack) {
            echo '
                <script type="text/javascript">
                setTimeout (function () {
                    if (window.opener) {
                        window.opener.location.reload();
                        window.close();
                    } }, 3000 );
                </script>
            ';
        }
        echo '<style>
                .redirect-content {
                    position: absolute;
                    left : 100px;
                }
                .main-center {
                    margin: 0 auto;
                    width: auto !important;
                }

            </style>';
    }
    return $payment_return;
}
Example #6
0
 public function confirm_username()
 {
     try {
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         // get data
         $data = $_POST['content'];
         $auth_info = unserialize($_SESSION['et_auth']);
         $username = $data['user_login'];
         if (isset($data['user_role']) && $data['user_role'] != '') {
             $user_roles = ae_get_option('social_user_role', false);
             if (!$user_roles) {
                 $user_roles = ae_get_social_login_user_roles_default();
             }
             if ($user_roles && in_array($data['user_role'], $user_roles) && $data['user_role'] != 'Administrator') {
                 $auth_info['role'] = $data['user_role'];
             }
         }
         $et_session = et_read_session();
         if ($et_session['et_social_id']) {
             $social_id = $et_session['et_social_id'];
         } else {
             $social_id = $_SESSION['et_social_id'];
         }
         // verify username
         $ae_user = get_user_by('login', $username);
         $return = array();
         if ($ae_user != false) {
             throw new Exception(__('Username is existed, please choose another one', ET_DOMAIN));
         } else {
             $auth_info['user_login'] = $username;
             // create user
             $ae_user = AE_Users::get_instance();
             $result = $ae_user->insert($auth_info);
             if (is_wp_error($result)) {
                 throw new Exception($result->get_error_message());
             } else {
                 if (empty($social_id)) {
                     throw new Exception(__("Can't find Social ID", ET_DOMAIN));
                 } else {
                     // creating user successfully
                     update_user_meta((int) $result->ID, $this->social_option, $social_id);
                     do_action('et_after_register', $result);
                     wp_set_auth_cookie((int) $result->ID, 1);
                     unset($_SESSION['et_auth']);
                     $return = array('user_id' => $result, 'redirect_url' => home_url());
                 }
             }
         }
         $resp = array('success' => true, 'msg' => '', 'data' => $return);
     } catch (Exception $e) {
         $resp = array('success' => false, 'msg' => $e->getMessage());
     }
     wp_send_json($resp);
 }
        function process_payment($payment_return, $order, $payment_type)
        {
            if ($payment_type == 'ce_ppexpress') {
                $ack = false;
                if (isset($_REQUEST['token']) && isset($_REQUEST['PayerID'])) {
                    $token = $_REQUEST['token'];
                    $payerID = $_REQUEST['PayerID'];
                    $checkout = new CE_PPExpressVisitor();
                    $order_pay = $order->generate_data_to_pay();
                    $response = $checkout->ConfirmPayment($token, $payerID, $order_pay);
                    $ack = strtoupper($response['ACK']);
                    if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
                        $payment_return = array('ACK' => true, 'payment' => 'ce_ppexpress', 'payment_status' => 'Completed');
                        $order->set_payment_code($token);
                        $order->set_payer_id($payerID);
                        $order->set_status('publish');
                        $order->update_order();
                        $session = et_read_session();
                        $post = get_post($session['ad_id']);
                        if ($post->post_type == 'ad') {
                            $link = get_permalink($session['ad_id']);
                        } elseif (isset($session['resume_id'])) {
                            $link = get_permalink($session['resume_id']);
                        } else {
                            $link = get_post_type_archive_link('resume');
                        }
                        ?>
						<script type="text/javascript">
							setTimeout (function () {
								if (window.opener) {
									window.opener.location.href = '<?php 
                        echo $link;
                        ?>
';
									window.close();
								} }, 3000 );
						</script>
						<?php 
                        $ack = true;
                    }
                }
                if (!$ack) {
                    ?>
					<script type="text/javascript">
					setTimeout (function () {
						if (window.opener) {
							window.opener.location.reload();
							window.close();
						} }, 3000 );
					</script>
				<?php 
                }
                ?>
				<style>
					.redirect-content {
						position: absolute;
						left : 100px;
					}
					.main-center {
						margin: 0 auto;
						width: auto !important;
					}

				</style>
				<?php 
            }
            return $payment_return;
        }
Example #8
0
/**
 * Generate social connect page template;
 */
function ae_page_social_connect()
{
    global $wp_query, $wp_rewrite, $post, $et_data;
    if (!isset($_SESSION)) {
        ob_start();
        @session_start();
    }
    $labels = $et_data['auth_labels'];
    $et_session = et_read_session();
    if (isset($et_session['et_auth']) && $et_session['et_auth'] != '') {
        $auth = unserialize($et_session['et_auth']);
    } elseif (isset($_SESSION['et_auth']) && $_SESSION['et_auth'] != '') {
        $auth = unserialize($_SESSION['et_auth']);
    }
    $type = isset($_GET['type']) ? $_GET['type'] : '';
    ?>
	<div class="twitter-auth social-auth social-auth-step1">
	<?php 
    if ($type == 'facebook') {
        ?>
	    <p class="text-page-not social-big"><?php 
        _e('SIGN IN WITH FACEBOOK', ET_DOMAIN);
        ?>
</p>
	    <p class="social-small">
	    <?php 
        printf(__("This seems to be your first time signing in using your Facebook account. <br />If you already have an account with %s, please log in using the form below to link it to your Facebook account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.<br />You will only do this step ONCE. Next time, you'll get logged in right away.", ET_DOMAIN), get_bloginfo('name'));
        ?>
	    </p>
	    <?php 
    } else {
        if ($type == 'twitter') {
            ?>
	    <p class="text-page-not social-big"><?php 
            _e('SIGN IN WITH TWITTER', ET_DOMAIN);
            ?>
</p>
	    <p class="social-small">
	        <?php 
            printf(__("This seems to be your first time signing in using your Twitter account.<br />If you already have an account with %s, please log in using the form below to link it to your Twitter account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.<br > You will only do this step ONCE. Next time, you'll get logged in right away.</p>", ET_DOMAIN), get_bloginfo('name'));
            ?>
	    </p>

	<?php 
        } else {
            if ($type == 'google') {
                ?>
		<p class="text-page-not social-big"><?php 
                _e('SIGN IN WITH GOOGLE+', ET_DOMAIN);
                ?>
</p>
	    <p class="social-small">
	        <?php 
                printf(__("This seems to be your first time signing in using your Google+ account.If you already have an account, please log in using the form below to link it to your Google+  account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.You will only do this step ONCE. Next time, you'll get logged in right away.</p>", ET_DOMAIN), get_bloginfo('name'));
                ?>
		</p>
	<?php 
            } else {
                if ($type == 'linkedin') {
                    ?>
		<p class="text-page-not social-big"><?php 
                    _e('SIGN IN WITH LINKEDIN', ET_DOMAIN);
                    ?>
</p>
	    <p class="social-small">
	        <?php 
                    printf(__("This seems to be your first time signing in using your Linkedin account.If you already have an account, please log in using the form below to link it to your Linkedin  account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.You will only do this step ONCE. Next time, you'll get logged in right away.</p>", ET_DOMAIN), get_bloginfo('name'));
                    ?>
		</p>
	<?php 
                }
            }
        }
    }
    ?>
	    <form id="form_auth" method="post" action="">
	        <div class="social-form">
	            <input type="hidden" name="et_nonce" value="<?php 
    echo wp_create_nonce('authentication');
    ?>
">
	            <input type="text" name="user_email" value="<?php 
    if (isset($auth['user_email'])) {
        echo $auth['user_email'];
    }
    ?>
"  placeholder="<?php 
    _e('Email', ET_DOMAIN);
    ?>
">
	            <input type="password" name="user_pass"  placeholder="<?php 
    _e('Password', ET_DOMAIN);
    ?>
">
	            <input type="submit" value="Submit">
	        </div>
	    </form>
	</div>
	<div class="social-auth social-auth-step2">
	    <p class="text-page-not social-big"><?php 
    echo $labels['title'];
    ?>
</p>
	    <p class="social-small"><?php 
    _e('Please provide a username to continue', ET_DOMAIN);
    ?>
</p>
	    <form id="form_username" method="post" action="">
	        <div class="social-form">
	            <input type="hidden" name="et_nonce" value="<?php 
    echo wp_create_nonce('authentication');
    ?>
">
	            <input type="text" name="user_login" value="<?php 
    echo isset($auth['user_login']) ? $auth['user_login'] : "";
    ?>
" placeholder="<?php 
    _e('Username', ET_DOMAIN);
    ?>
">
	            <?php 
    $social_user_roles = ae_get_option('social_user_role', false);
    if (!$social_user_roles) {
        $social_user_roles = ae_get_social_login_user_roles_default();
    }
    if ($social_user_roles && count($social_user_roles) >= 1) {
        ?>
	            	  <select name="user_role" class="sc_user_role">
	            	  	<?php 
        foreach ($social_user_roles as $key => $value) {
            ?>
		            	<option value="<?php 
            echo $value;
            ?>
"><?php 
            echo $value;
            ?>
</option>
		           		<?php 
        }
        ?>
	            	  </select>
	            <?php 
    }
    ?>
	            <input type="submit" value="Submit">
	        </div>
	    </form>
	</div>
<?php 
}
Example #9
0
 /**
  * Redirect and auth twitter account
  */
 public function redirect()
 {
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'twitterauth') {
         // request token
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         require_once dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
         // create connection
         $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret);
         // request token
         $request_token = $connection->getRequestToken($this->oath_callback);
         //
         if ($request_token) {
             // var_dump($request_token);
             // exit;
             if (isset($request_token['oauth_token']) && $request_token['oauth_token_secret']) {
                 $token = $request_token['oauth_token'];
                 $_SESSION['oauth_token'] = $token;
                 $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
                 // try et session
                 et_write_session('oauth_token', $token);
                 et_write_session('oauth_token_secret', $request_token['oauth_token_secret']);
             }
             // redirect to twitter
             switch ($connection->http_code) {
                 case 200:
                     $url = $connection->getAuthorizeURL($request_token);
                     //redirect to Twitter .
                     header('Location: ' . $url);
                     exit;
                     break;
                 default:
                     _e("Conection with twitter Failed", ET_DOMAIN);
                     exit;
                     break;
             }
         } else {
             echo __("Error Receiving Request Token", ET_DOMAIN);
             exit;
         }
     } else {
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'twitterauth_callback' && $_GET['oauth_token']) {
             // request access token and
             // create account here
             if (!isset($_SESSION)) {
                 ob_start();
                 @session_start();
             }
             require_once dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
             $et_session = et_read_session();
             if (isset($et_session['oauth_token'])) {
                 $oauth_token = $et_session['oauth_token'];
                 $oauth_token_secret = $et_session['oauth_token_secret'];
             } else {
                 $oauth_token = $_SESSION['oauth_token'];
                 $oauth_token_secret = $_SESSION['oauth_token_secret'];
             }
             // create connection
             $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $oauth_token, $oauth_token_secret);
             // request access token
             $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
             //
             if ($access_token && isset($access_token['oauth_token'])) {
                 // recreate connection
                 $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
                 $account = $connection->get('account/verify_credentials');
                 // create account
                 if ($account && isset($account->screen_name) && isset($account->name)) {
                     // find
                     $users = get_users(array('meta_key' => 'et_twitter_id', 'meta_value' => $account->id));
                     if (!empty($users) && is_array($users)) {
                         $ae_user = $users[0];
                         wp_set_auth_cookie($ae_user->ID, 1);
                         wp_redirect(home_url());
                         exit;
                     }
                     $avatars = array();
                     $sizes = get_intermediate_image_sizes();
                     foreach ($sizes as $size) {
                         $avatars[$size] = array($account->profile_image_url);
                     }
                     $params = array('user_login' => $account->screen_name, 'display_name' => $account->name, 'user_location' => $account->location, 'description' => $account->description, 'et_avatar' => $avatars);
                     // save user info for saving later
                     $_SESSION['user_login'] = $account->screen_name;
                     $_SESSION['display_name'] = $account->name;
                     $_SESSION['et_twitter_id'] = $account->id;
                     $_SESSION['user_location'] = $account->location;
                     $_SESSION['description'] = $account->description;
                     $_SESSION['profile_image_url'] = $account->profile_image_url;
                     $_SESSION['et_auth'] = serialize(array('user_login' => $account->screen_name, 'display_name' => $account->name, 'user_location' => $account->location, 'description' => $account->description, 'et_avatar' => $avatars));
                     $_SESSION['et_social_id'] = $account->id;
                     $_SESSION['et_auth_type'] = 'twitter';
                     // try to user et session
                     et_write_session('et_auth', serialize($params));
                     et_write_session('et_social_id', $account->id);
                     et_write_session('et_auth_type', 'twitter');
                     wp_redirect($this->auth_url);
                     exit;
                 }
             }
             exit;
         } else {
             if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'twitterauth_login') {
                 if (!isset($_SESSION)) {
                     ob_start();
                     @session_start();
                 }
                 if (!empty($_POST['user_email'])) {
                     $password = wp_generate_password();
                     $new_account = array('user_login' => $_SESSION['user_login'], 'display_name' => $_SESSION['display_name'], 'et_twitter_id' => $_SESSION['et_twitter_id'], 'user_location' => $_SESSION['user_location'], 'description' => $_SESSION['description'], 'user_email' => $_POST['user_email'], 'user_pass' => $password, 'et_avatar' => array('thumbnail' => array($_SESSION['profile_image_url'])));
                     $ae_user = get_user_by('login', $new_account['user_login']);
                     if ($ae_user != false) {
                         $new_account['user_login'] = str_replace('@', '', $_POST['user_email']);
                     }
                     $ae_user = AE_Users::get_instance();
                     $result = $ae_user->insert($new_account);
                     if (!is_wp_error($result)) {
                         // send email here
                         //
                         do_action('et_after_register', $result);
                         // wp_mail( $_POST['user_email'],
                         //  __("You have been logged in via Twitter", ET_DOMAIN),
                         //  "Hi, <br/> your pasword on our site is {$password}");
                         // login
                         $ae_user = wp_signon(array('user_login' => $new_account['user_login'], 'user_password' => $new_account['user_pass']));
                         if (is_wp_error($ae_user)) {
                             global $et_error;
                             $et_error = $ae_user->get_error_message();
                             //echo $user->get_error_message();
                         } else {
                             wp_redirect(home_url());
                             exit;
                         }
                     } else {
                         global $et_error;
                         $et_error = $result->get_error_message();
                     }
                 }
                 // ask people for password
                 include TEMPLATEPATH . '/page-twitter-auth.php';
                 exit;
             }
         }
     }
 }