Exemplo n.º 1
0
 public function notifyAction($type = NULL)
 {
     if (empty($_POST)) {
         return;
     }
     $paymentId = isset($_GET['oid']) ? $_GET['oid'] : null;
     if (isset($_POST) && !isset($_POST['stripeToken'])) {
         // PayPal Verify
         $payment_crc = $_POST['custom'];
         try {
             $timestamp = time();
             $data = json_encode($_POST);
             $this->wpdb->update($this->getTableName('ads'), array('p_time' => $timestamp, 'p_data' => $data), array('id' => $paymentId));
             if ($payment_crc != md5($_POST['item_number'] . bsa_number_format($_POST['mc_gross']))) {
                 throw new \Exception('price changed');
             }
             if ($_POST['payment_status'] == 'Pending') {
                 throw new \Exception('payment is pending');
             }
             if ($_POST['payment_status'] == 'Denied') {
                 throw new \Exception('payment is denied');
             }
         } catch (\Exception $e) {
             $error = $e->getMessage();
         }
         if (isset($error)) {
             $this->wpdb->update($this->getTableName('ads'), array('paid' => 0, 'p_error' => $error), array('id' => $paymentId));
         }
         if (isset($_POST) && isset($_POST['payment_status']) && $_POST['payment_status'] == 'Completed' && !isset($error)) {
             // change status
             $this->wpdb->update($this->getTableName('ads'), array('paid' => 1, 'status' => (get_option('bsa_pro_plugin_auto_accept') == 'no' or $type == 'agency') ? 'pending' : 'active'), array('id' => $paymentId));
             // change affiliate status
             if ($this->validReferral($paymentId)) {
                 $this->wpdb->update($this->getTableName('referrals'), array('order_status' => 'paid'), array('order_id' => $paymentId));
             }
         }
         // reset cache sessions
         unset($_SESSION['bsa_ad_' . $paymentId]);
     }
     if (isset($_POST) && isset($_POST['stripeToken'])) {
         // Stripe Verify
         if (isset($_POST['stripeToken']) && isset($_GET['oid'])) {
             require_once 'Stripe/init.php';
             // Set your API key
             \Stripe\Stripe::setApiKey(get_option('bsa_pro_plugin_secret_key'));
             try {
                 \Stripe\Charge::create(array('amount' => number_format(bsa_ad($_GET['oid'], 'cost'), 2, '', ''), 'currency' => 'usd', 'card' => $_POST['stripeToken'], 'description' => bsa_ad($_GET['oid'], 'buyer_email') . ' (' . number_format(bsa_ad($_GET['oid'], 'cost'), 2, '', '') . ')'));
                 $timestamp = time();
                 $this->wpdb->update($this->getTableName('ads'), array('paid' => 1, 'p_time' => $timestamp, 'p_data' => $_POST['stripeToken'], 'status' => (get_option('bsa_pro_plugin_auto_accept') == 'no' or $type == 'agency') ? 'pending' : 'active'), array('id' => $paymentId));
                 // change affiliate status
                 if ($this->validReferral($paymentId)) {
                     $this->wpdb->update($this->getTableName('referrals'), array('order_status' => 'paid'), array('order_id' => $paymentId));
                 }
                 echo 'TRUE';
             } catch (\Stripe\Error\Card $e) {
                 // The card has been declined
                 //					$error = $e->getMessage();
                 //					$this->wpdb->update(
                 //						$this->getTableName('ads'),
                 //						array(
                 //							'paid' => 0,
                 //							'p_error' => $error
                 //						),
                 //						array('id' => $paymentId)
                 //					);
                 //					echo 'FALSE';
             }
         }
         // change status to pending if pending cron task
         if ($this->getPendingTask($paymentId, 'ad')) {
             $this->wpdb->update($this->getTableName('ads'), array('status' => 'pending'), array('id' => $paymentId));
         }
         // reset cache sessions
         unset($_SESSION['bsa_ad_' . $paymentId]);
     }
     if (isset($error)) {
         echo FALSE;
     } else {
         // email sender
         $sender = get_option('bsa_pro_plugin_trans_email_sender');
         $email = get_option('bsa_pro_plugin_trans_email_address');
         // buyer sender
         $paymentEmail = bsa_ad($paymentId, 'buyer_email');
         $subject = get_option('bsa_pro_plugin_trans_buyer_subject');
         $message = get_option('bsa_pro_plugin_trans_buyer_message');
         $search = '[STATS_URL]';
         if ($type == 'agency') {
             $replace = get_option('bsa_pro_plugin_agency_ordering_form_url') . (strpos(get_option('bsa_pro_plugin_agency_ordering_form_url'), '?') == TRUE ? '&' : '?') . "bsa_pro_stats=1&bsa_pro_email=" . str_replace('@', '%40', $paymentEmail) . "&bsa_pro_id=" . $paymentId . "#bsaStats\r\n";
         } else {
             $replace = get_option('bsa_pro_plugin_ordering_form_url') . (strpos(get_option('bsa_pro_plugin_ordering_form_url'), '?') == TRUE ? '&' : '?') . "bsa_pro_stats=1&bsa_pro_email=" . str_replace('@', '%40', $paymentEmail) . "&bsa_pro_id=" . $paymentId . "#bsaStats\r\n";
         }
         $message = str_replace($search, $replace, $message);
         $headers = 'From: ' . $sender . ' <' . $email . '>' . "\r\n";
         wp_mail($paymentEmail, $subject, $message, $headers);
         if ($type == 'agency') {
             // seller sender
             $sellerSubject = get_option('bsa_pro_plugin_trans_seller_subject');
             $sellerMessage = get_option('bsa_pro_plugin_trans_seller_message');
             $sellerHeaders = 'From: ' . $sender . ' <' . $email . '>' . "\r\n";
             $getUserId = bsa_site(bsa_space(bsa_ad($paymentId, 'space_id'), 'site_id'), 'user_id');
             $userInfo = get_userdata($getUserId);
             $userEmail = $userInfo->user_email;
             wp_mail($userEmail, $sellerSubject, $sellerMessage, $sellerHeaders);
         }
         if (!isset($_POST['stripeToken'])) {
             echo TRUE;
         }
     }
 }
Exemplo n.º 2
0
            } elseif ($type == 'template') {
                echo bsa_space($id, 'template');
            } elseif ($type == 'domain') {
                echo plugins_url();
            } else {
                echo '(error 707) No access to the API.';
            }
        } else {
            echo '(error 706) No access to the API.';
        }
    } else {
        echo '(error 705) No access to the API.';
    }
} elseif (isset($_GET['i'])) {
    // iframe
    if (isset($id) && $id != '' && bsa_space($id, 'id') != NULL && bsa_space($id, 'status') == 'active' && bsa_site(bsa_space($id, 'site_id'), 'status') == 'active') {
        echo bsa_pro_ad_space($id, $max_width, $delay, $padding_top, $attachment, $crop);
        // Print items
        ?>
<style>
	.bsaProContainer .bsaProItemInner__copy { font-family: Verdana, Arial, sans-serif; }
	<?php 
        echo get_option('bsa_pro_plugin_custom_css') != '' ? get_option('bsa_pro_plugin_custom_css') : null;
        ?>
	<?php 
        echo file_get_contents(plugin_dir_path(__FILE__) . '/../frontend/css/asset/style.css');
        ?>
	<?php 
        if (strpos(bsa_space($id, 'template'), 'material-design') !== false) {
            ?>
		<?php 
Exemplo n.º 3
0
function bsa_option_exists($id, $table, $column)
{
    if (isset($id) && $id != '' && isset($table) && $table != '' && isset($column) && $column != '') {
        if ($table == 'sites') {
            if (bsa_site($id, $column) != NULL || bsa_site($id, $column) != '') {
                return TRUE;
            } else {
                return FALSE;
            }
        } elseif ($table == 'spaces') {
            if (bsa_space($id, $column) != NULL || bsa_space($id, $column) != '') {
                return TRUE;
            } else {
                return FALSE;
            }
        } elseif ($table == 'ads') {
            if (bsa_ad($id, $column) != NULL || bsa_ad($id, $column) != '') {
                return TRUE;
            } else {
                return FALSE;
            }
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}